envresolve

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: Apache-2.0 Imports: 8 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 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.

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