config

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RunAsLocal = "local" // Running in local will not save test results to the DB
	RunAsJob   = "job"   // Set run_as ENV to "job" if you want to save test results to the DB
)

Variables

View Source
var (
	KubernetesServiceHostKey = "KUBERNETES_SERVICE_HOST"
	TelepresenceRootKey      = "TELEPRESENCE_ROOT"
)

Functions

func RunAs

func RunAs(env *Env) string

RunAs returns a string containing the type of environment the tests should run as.

- service: run as a gRPC service pod (save results to database) - local: run using the standard Go runner (do not save results to database) - job: run as a k8 job (run-once, save results to database)

func RunningInKubernetes

func RunningInKubernetes() bool

Detects if test service is running in a Kubernetes pod

func RunningInTelepresence

func RunningInTelepresence() bool

Detects if test service is running in Telepresence

Types

type Env

type Env struct {
	// Env is environment where application is running. This value is used to
	// annotate datadog metrics or sentry error reporting. The value should always
	// be "development"
	Env string `envconfig:"ENV" default:"development"`

	// GCPProjectID is you service GCP project ID
	GCPProjectID string `envconfig:"GCP_PROJECT_ID"`

	// Whether or not to print test realtime output to the event log
	PrintOutputToEventLog bool `envconfig:"PRINT_OUTPUT_TO_EVENT_LOG" default:"false"`

	// RunAs is an override to force testdeck to run as local tests or gRPC service
	// If RunAs is set as "service" then testdeck-service will always run as a gRPC service.
	// If RunAs is set as "local" then testdeck-service will always run as a normal local test.
	// For other values testdeck-service will fallback to its automatic sensing logic:
	//  - kubernetes with no teleprecense: gRPC service
	//  - otherwise: local
	RunAs string `envconfig:"RUN_AS"`

	// The URL of the DB to save test results to. If not declared, tests will still run but results can only be viewed through Kubernetes pod logs
	DbUrl string `envconfig:"DB_URL"`
}

Env stores configuration settings extract from environmental variables by using https://github.com/kelseyhightower/envconfig

The practice getting from environmental variables comes from https://12factor.net.

func ReadFromEnv

func ReadFromEnv() (*Env, error)

ReadFromEnv reads configuration from environmental variables defined by Env struct

Jump to

Keyboard shortcuts

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