detector

package
v0.0.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 26, 2023 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// EnvAppEngineFlexService is the service name specified in your application's app.yaml file, or if no service name is specified, it is set to default.
	EnvAppEngineFlexService = "GAE_SERVICE"

	// EnvAppEngineFlexVersion is the version label of the current application.
	EnvAppEngineFlexVersion = "GAE_VERSION"

	// EnvAppEngineFlexInstance is the name of the current instance.
	EnvAppEngineFlexInstance = "GAE_INSTANCE"
)

List of App Engine Flex env vars:

https://cloud.google.com/appengine/docs/flexible/python/runtime#environment_variables

View Source
const (
	// EnvCloudRunService is the name of the Cloud Run service being run.
	EnvCloudRunService = "K_SERVICE"

	// EnvCloudRunRevision is the name of the Cloud Run revision being run.
	EnvCloudRunRevision = "K_REVISION"

	// EnvCloudRunConfig is	the name of the Cloud Run configuration that created the revision.
	EnvCloudRunConfig = "K_CONFIGURATION"
)

List of Cloud Run env vars:

https://cloud.google.com/run/docs/container-contract#env-vars

View Source
const (
	// EnvCloudRunJobsService is the name of the Cloud Run job being run.
	EnvCloudRunJobsService = "CLOUD_RUN_JOB"

	// EnvCloudRunJobsRevision is the name of the Cloud Run execution being run.
	EnvCloudRunJobsRevision = "CLOUD_RUN_EXECUTION"

	// EnvCloudRunJobsTaskIndex for each task, this will be set to a unique value between 0 and the number of tasks minus 1.
	EnvCloudRunJobsTaskIndex = "CLOUD_RUN_TASK_INDEX"

	// cloudRunJobsTaskAttempt is the number of times this task has been retried.
	//
	// Starts at 0 for the first attempt; increments by 1 for every successive retry, up to the maximum retries value.
	EnvCloudRunJobsTaskAttempt = "CLOUD_RUN_TASK_ATTEMPT"

	// cloudRunJobsRevisionEnv is the number of tasks defined in the --tasks parameter.
	EnvCloudRunJobsTaskCount = "CLOUD_RUN_TASK_COUNT"
)

List of Cloud Run jobs env vars:

https://cloud.google.com/run/docs/container-contract#jobs-env-vars

View Source
const (
	// EnvCloudFunctionsTarget is the function to be executed.
	EnvCloudFunctionsTarget = "FUNCTION_TARGET"

	// EnvCloudFunctionsSignatureType is the type of the function: http for HTTP functions, and event for event-driven functions.
	EnvCloudFunctionsSignatureType = "FUNCTION_SIGNATURE_TYPE"

	// EnvCloudFunctionsKService is the name of the function resource.
	//
	// Note that this envvar is also present in Cloud Run environments.
	EnvCloudFunctionsKService = "K_SERVICE"

	// EnvCloudFunctionsKRevision is the version identifier of the function.
	//
	// Note that this envvar is also present in Cloud Run environments.
	EnvCloudFunctionsKRevision = "K_REVISION"
)

List of Cloud Functions newer runtimes env vars:

https://cloud.google.com/functions/docs/configuring/env-var#newer_runtimes

View Source
const (
	// EnvAppEngineEnv is the App Engine environment. Set to "standard".
	EnvAppEngineEnv = "GAE_ENV"
)

List of App Engine Standard env vars:

https://cloud.google.com/appengine/docs/standard/go/runtime#environment_variables

Variables

This section is empty.

Functions

This section is empty.

Types

type Detector

type Detector struct {
	// contains filtered or unexported fields
}

Detector collects resource information for all GCP platforms.

func NewDetector

func NewDetector(attrs ResourceAttributesFetcher) *Detector

NewDetector returns the new Detector based by attrs.

func (*Detector) CloudPlatform

func (d *Detector) CloudPlatform() Platform

CloudPlatform returns the platform on which this program is running.

type MetadataProvider

type MetadataProvider interface {
	ProjectID() (string, error)
	InstanceID() (string, error)
	Get(string) (string, error)
	InstanceName() (string, error)
	Zone() (string, error)
	InstanceAttributeValue(string) (string, error)
}

MetadataProvider contains the subset of the metadata.Client functions used by this resource Detector to allow testing with a fake implementation.

type OSProvider

type OSProvider interface {
	LookupEnv(string) (string, bool)
}

OSProvider contains the subset of the os package functions used by.

type Platform

type Platform uint8

Platform represents a GCP service platforms.

const (
	// UnknownPlatform is the unknown platform.
	UnknownPlatform Platform = iota

	// GKE is the Kubernetes Engine platform.
	// TODO(zchee): not implemented yet.
	GKE

	// GCE is the Google Compute Engine platform.
	// TODO(zchee): not implemented yet.
	GCE

	// CloudRun is the Cloud Run platform.
	CloudRun

	// CloudRunJobs is the Cloud Run jobs platform.
	CloudRunJobs

	// CloudFunctions is the Cloud Functions platform.
	CloudFunctions

	// AppEngineStandard is the App Engine Standard 2nd platform.
	AppEngineStandard

	// AppEngineFlex is the App Engine Flex platform.
	AppEngineFlex
)

type ResourceAttributesFetcher

type ResourceAttributesFetcher interface {
	EnvVar(name string) string
	Metadata(path string) string
	ReadAll(path string) string
}

ResourceAttributesFetcher abstracts environment lookup methods to query for environment variables, metadata attributes and file content.

func ResourceAttributes

func ResourceAttributes() ResourceAttributesFetcher

ResourceAttributes provides read-only access to the ResourceAttributesFetcher interface implementation.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL