config

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2026 License: MIT Imports: 6 Imported by: 0

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 AmbienteDasTasks

func AmbienteDasTasks(nomes []string) map[string]string

AmbienteDasTasks 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.

func TaskEnvDoAmbiente

func TaskEnvDoAmbiente() []string

TaskEnvDoAmbiente le BREVIS_TASK_ENV para quem nao carregou a Config inteira.

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

	// TaskEnv lists what the process passes on to local tasks. See
	// AmbienteDasTasks -- 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.Credencial

	// 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.

func Load

func Load() (Config, error)

Load builds the Config and fails at boot if something required is missing. Failing early is deliberate: a process that starts without DATABASE_URL only finds out on the first request, and by then readiness has already lied to the orchestrator.

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

	// SecretsPermitidos 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.
	SecretsPermitidos []string

	// CredencialPVC and CredencialPath mount the volume where the SDK keeps the
	// credential it rotates. Without the PVC, nothing changes.
	CredencialPVC  string
	CredencialPath 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.
	Toleracoes    []Toleracao
	ManterEmFalha bool
}

type Toleracao

type Toleracao struct {
	Chave  string
	Valor  string
	Efeito string
}

Toleracao mirrors the pod's field, without importing Kubernetes' type.

Jump to

Keyboard shortcuts

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