Documentation
¶
Overview ¶
Package config loads and validates the process's configuration from the environment.
It sits outside the tree §36 of the plan describes, which did not foresee a package for this. The alternative was scattering os.Getenv across cmd/ and infrastructure/; a single point of reading and validation is worth the detour, and rule 7 asks that decisions like this one be explicit rather than silent.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func TaskEnvFromEnvironment ¶ added in v0.7.0
func TaskEnvFromEnvironment() []string
TaskEnvFromEnvironment reads BREVIS_TASK_ENV for whoever did not load the whole Config.
func TasksEnvironment ¶ added in v0.7.0
TasksEnvironment builds the environment each local step receives.
A task does NOT inherit the orchestrator's environment. The reason is concrete: the Brevis process carries BREVIS_DATABASE_URL with the Postgres user and password, and a workflow is an arbitrary command written by somebody else -- inheriting by default would hand the database credential to every step of every pipeline.
What the task needs is therefore declared: `BREVIS_TASK_ENV=GOOGLE_PROJECT_ID,STAGE` passes those two from the process's environment. `NAME=value` sets a literal. `*` passes everything EXCEPT the BREVIS_* ones -- the wildcard exists for those who need it, and the exception exists because the orchestrator's configuration is never the task's business.
PATH and HOME always go in: without PATH no command resolves, and the error would be a "not found" that explains nothing.
A package function and not a method: `brevis run` runs without a database and therefore without a Config -- but needs the same environment.
Types ¶
type Config ¶
type Config struct {
Env string
HTTPAddr string
DatabaseURL string
LogLevel string
ShutdownTimeout time.Duration
// BrandFile points at the visual identity YAML. Optional: without it the
// interface uses the default identity.
BrandFile string
// MetricsAddr is where /metrics listens, and it is a SEPARATE address from
// HTTPAddr on purpose. The API pod is the one behind an Ingress, and a
// scrape endpoint on the same port would either sit behind the login --
// where no scraper can reach it -- or publish every workflow and step name
// to whoever finds the path.
//
// It defaults to :9090 rather than to empty, because a metrics endpoint
// that has to be turned on is a metrics endpoint nobody has. Setting
// BREVIS_METRICS_ADDR to the empty string serves nothing -- which is why it
// is read with LookupEnv and not with `get`, where empty and unset are the
// same thing.
MetricsAddr string
// TaskEnv lists what the process passes on to local tasks. See
// TasksEnvironment -- the default does NOT inherit the environment, and
// that is deliberate.
TaskEnv []string
// SlackWebhook receives the alert for a definitive failure. Empty means
// nobody is told. It comes from the environment and never from the YAML:
// whoever holds the URL posts in the channel as if they were the
// platform.
SlackWebhook string
// Auth is the operator credential that closes the interface. See internal/auth.
Auth auth.Credential
// UIURL builds the run's link in the alert. Without it the alert says what
// failed but makes the reader hunt for the run by hand.
UIURL string
// Pods parameterises execution in Kubernetes. These are the INSTALLATION's
// decisions -- which identity and credentials the pods start with -- which
// is why they come from the environment and not the workflow's YAML: a
// pipeline must not get to pick the service account it runs as.
Pods PodsConfig
}
Config is the immutable state derived from the environment. Everything the process needs to start is here -- nothing reads the environment after boot.
type PodsConfig ¶
type PodsConfig struct {
// Mode: auto (use pods when a cluster is there), on (require) or off (never).
Modo string
Namespace string
ServiceAccount string
PullSecrets []string
EnvFromSecrets []string
EnvFromConfigMaps []string
// AllowedSecrets limits what a YAML's `secrets:` may name. Empty denies
// everything: the installation decides which secrets exist for workflows,
// and the YAML decides which step receives each one.
AllowedSecrets []string
// CredencialPVC and CredencialPath mount the volume where the SDK keeps the
// credential it rotates. Without the PVC, nothing changes.
CredentialPVC string
CredentialPath string
NodeSelector map[string]string
// Tolerations in "key=value:effect" form, comma separated. An arm64 pool
// commonly carries a taint, and without a toleration the task's pod stays
// Pending forever -- no error, just stopped.
Tolerations []Grace
KeepOnFailure bool
}