Documentation ¶
Overview ¶
Package cloudruntime provides primitives for loading data from the cloud runtime.
Index ¶
- func Configuration() (string, bool)
- func Port() (int, bool)
- func ProjectID() (string, bool)
- func Revision() (string, bool)
- func Service() (string, bool)
- func ServiceAccount() (string, bool)
- func ServiceVersion() (string, bool)
- func ServiceVersionFromBuildInfo() (string, bool)
- func ServiceVersionFromLinkerFlags() string
- func WithConfig(ctx context.Context, config Config) context.Context
- type Config
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Configuration ¶
Configuration returns the service configuration of the current runtime.
func ServiceAccount ¶
ServiceAccount returns the default service account of the current runtime.
func ServiceVersion ¶
ServiceVersion returns the service version of the current runtime. The service version is taken from, in order of precedence: - the "SERVICE_VERSION" environment variable - the go.einride.tech/cloudrunner/cloudruntime.serviceVersion variable (must be set at build-time) - the "K_REVISION" environment variable - no version.
func ServiceVersionFromBuildInfo ¶ added in v0.23.0
ServiceVersionFromBuildInfo returns the VCS revision from the embedded build info.
func ServiceVersionFromLinkerFlags ¶
func ServiceVersionFromLinkerFlags() string
ServiceVersionFromLinkerFlags returns the exact value of the variable:
go.einride.tech/cloudrunner/cloudruntime.serviceVersion
This variable can be set during build-time to provide a default value for the service version.
Example:
go build -ldflags="-X 'go.einride.tech/cloudrunner/cloudruntime.serviceVersion=v1.0.0'"
Types ¶
type Config ¶
type Config struct { // Port is the port the service is listening on. Port int `env:"PORT" default:"8080"` // Service is the name of the service. Service string `env:"K_SERVICE"` // Revision of the service, as assigned by a Knative runtime. Revision string `env:"K_REVISION"` // Configuration of the service, as assigned by a Knative runtime. Configuration string `env:"K_CONFIGURATION"` // ProjectID is the GCP project ID the service is running in. // In production, defaults to the project where the service is deployed. ProjectID string `env:"GOOGLE_CLOUD_PROJECT"` // ServiceAccount is the service account used by the service. // In production, defaults to the default service account of the running service. ServiceAccount string // ServiceVersion is the version of the service. ServiceVersion string `env:"SERVICE_VERSION"` }
Config is the runtime config for the service.