Help us shape the future of Go! Take the 2026 Go Developer Survey

envresolve

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package envresolve is the single config+secret env-resolver shared by the Function reconciler and the provider framework (ADR-0093, relocating ADR-0092's helper to a neutral leaf). It reads bound ConfigMaps (non-sensitive, a plain store read) and Secrets (sensitive, PDP-resolved), guarded-merging both into one worker-env map, config first then secrets (so a secret overrides a config default). It imports only internal/secrets (the pure reserved-key and env-value guards) + internal/store — never internal/function or internal/provider — so both consumers can depend on it without inverting the layering.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrConfig = errors.New("config resolution failed") // wraps a ConfigMap read failure
	ErrSecret = errors.New("secret resolution failed") // wraps a Secret resolution failure
)

Sentinels so a caller can attribute a failure to the config vs secret side (errors.Is), for a Ready reason (ADR-0093 §4). ErrConfig wraps a ConfigMap-read failure; ErrSecret wraps a Secret-resolution failure. The returned error still carries its underlying fault kind, so fault.KindOf(err) is preserved — the sentinel is joined alongside, not in place of, the fault.

Functions

func ResolveEnv

func ResolveEnv(ctx context.Context, d Deps, ns v1.NamespaceName, config, secretNames []v1.ObjectName) (map[string]string, error)

ResolveEnv returns Resolve's Env, for providers, which run no handler.

Types

type Deps

type Deps struct {
	Secrets  SecretResolver                       // ADR-0057 PDP-authorized secret resolution (nil ⇒ secrets unsupported)
	Store    store.Store                          // ConfigMap reads
	Identity func(v1.NamespaceName) auth.Identity // the secret-injector identity for the read
	Logger   *slog.Logger                         // nil-tolerated (the guarded-merge silently drops)
}

Deps carries what env-resolution needs; a consumer supplies its own instances.

type Resolved added in v0.15.0

type Resolved struct {
	Env        map[string]string
	ConfigKeys []string // sorted; minus the keys a secret overrides
	SecretKeys []string // sorted
}

Resolved is a binding's guarded env plus the keys of each kind that reach it (ADR-0245): the shims tell config from secrets by these lists, which a worker receives as FUNCD_CONFIG_KEYS and FUNCD_SECRET_KEYS.

func Resolve added in v0.15.0

func Resolve(ctx context.Context, d Deps, ns v1.NamespaceName, config, secretNames []v1.ObjectName) (Resolved, error)

Resolve assembles env from bound ConfigMaps (config, non-sensitive — each read via store.Get(ctx, v1.KindConfigMap.GVK(), ns, name) → *v1.ConfigMap, merging cm.Spec.Data) + Secrets (sensitive, PDP-resolved via d.Secrets under d.Identity(ns)), guarded against reserved FUNCD_ keys (ADR-0092). Config is merged first, then secrets (so a secret may override a config default). Returns fault.Invalid if secrets are declared but d.Secrets is nil (unchanged catalog semantics), or if a value cannot be delivered as env (EnvDataProblem). On failure the returned error is joined with ErrConfig or ErrSecret (ADR-0093 §4) so a caller can attribute it via errors.Is while keeping the fault kind. This is the single resolver for Functions AND providers.

type SecretResolver

type SecretResolver interface {
	ResolveEnv(ctx context.Context, id auth.Identity, ns v1.NamespaceName, names []string) (map[string]string, error)
}

SecretResolver is the consumer-side seam (ADR-0002 interface placement) env-resolution depends on: Deps takes this INTERFACE, not the concrete *secrets.Resolver — the per-consumer controller's SecretResolver interface value + its test fakes satisfy it structurally, so both call sites (and their fakes) compile and the existing tests pass unchanged (ADR-0092).

Jump to

Keyboard shortcuts

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