cloudruntime

package
v0.37.2 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package cloudruntime provides primitives for loading data from the cloud runtime.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Configuration

func Configuration() (string, bool)

Configuration returns the service configuration of the current runtime.

func Port

func Port() (int, bool)

Port returns the service port of the current runtime.

func ProjectID

func ProjectID() (string, bool)

ProjectID returns the Google Cloud Project ID of the current runtime.

func Revision

func Revision() (string, bool)

Revision returns the service revision of the current runtime.

func Service

func Service() (string, bool)

Service returns the service name of the current runtime.

func ServiceAccount

func ServiceAccount() (string, bool)

ServiceAccount returns the default service account of the current runtime.

func ServiceVersion

func ServiceVersion() (string, bool)

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

func ServiceVersionFromBuildInfo() (string, bool)

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'"

func WithConfig

func WithConfig(ctx context.Context, config Config) context.Context

WithConfig adds the provided runtime Config to the current context.

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.

func GetConfig

func GetConfig(ctx context.Context) (Config, bool)

GetConfig gets the runtime Config from the current context.

func (*Config) Autodetect

func (c *Config) Autodetect() error

Autodetect the runtime config.

Jump to

Keyboard shortcuts

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