Documentation
¶
Index ¶
- Constants
- type CFSecrets
- func (c *CFSecrets) Get(ctx context.Context, provider string, ref Ref) ([]byte, error)
- func (c *CFSecrets) GetDependencies() []string
- func (c *CFSecrets) GetInitOrderStage() cf.Stage
- func (c *CFSecrets) GetString(ctx context.Context, provider string, ref Ref) (string, error)
- func (c *CFSecrets) Health(ctx context.Context) error
- func (c *CFSecrets) Init(ctx context.Context, fw *cf.CaerusFramework) error
- func (c *CFSecrets) Metrics() []cf_observability.Metric
- func (c *CFSecrets) Name() string
- func (c *CFSecrets) OnConfigReload(source string, cfg any)
- func (c *CFSecrets) RegisterConfigSources(conf any) error
- func (c *CFSecrets) Shutdown(ctx context.Context) error
- type Option
- type ProviderConfig
- type Ref
- type SecretsConfig
- type SourceOption
Constants ¶
const ( // ComponentName is the framework registry identity. Peers list this in // GetDependencies. It is not the configuration source name (that comes // from WithConfigSource). ComponentName = "secrets" )
const ComponentStage = cf.SecretsStage
ComponentStage is the bootstrap secrets stage (after logs, configuration, observability; before data). The framework already registers this stage; this component is still declared in main — it is not auto-inserted like logs.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CFSecrets ¶
type CFSecrets struct {
// contains filtered or unexported fields
}
CFSecrets is the secrets chassis: named providers, one Get API.
func (*CFSecrets) Get ¶
Get fetches a secret from the named provider. The name is the map key in config (e.g. "openbao"), not the kind. Callers must not switch on kind.
func (*CFSecrets) GetDependencies ¶
GetDependencies implements cf.Dependencies.
func (*CFSecrets) GetInitOrderStage ¶
GetInitOrderStage implements cf.CaerusComponent.
func (*CFSecrets) GetString ¶
GetString is Get decoded as text (not trimmed — callers own whitespace).
func (*CFSecrets) Health ¶
Health implements cf.HealthProvider. Unhealthy before Init, after Shutdown, and when a provider ping last failed (unless health_when_degraded=ready).
func (*CFSecrets) Metrics ¶
func (c *CFSecrets) Metrics() []cf_observability.Metric
Metrics implements cf_observability.MetricsProvider.
func (*CFSecrets) OnConfigReload ¶
OnConfigReload implements cf.ConfigReloader. Failed rebuild keeps last-good drivers.
func (*CFSecrets) RegisterConfigSources ¶
RegisterConfigSources implements cf.ConfigSourceRegistrar.
type Option ¶
type Option func(*options)
Option configures the secrets component at construction time.
func WithConfig ¶
func WithConfig(cfg SecretsConfig) Option
WithConfig sets a static configuration snapshot (tests, embedded use).
func WithConfigSource ¶
func WithConfigSource(name, path string, opts ...SourceOption) Option
WithConfigSource binds this component to a named configuration source and registers that source with the configuration component during argv absorption.
cf_secrets.New(cf_secrets.WithConfigSource("secrets", "config/secrets.json"))
func WithDegradedMode ¶
func WithDegradedMode() Option
WithDegradedMode lets Init succeed when a provider ping fails.
func WithLogger ¶
WithLogger overrides the framework logger (tests / embedded).
type ProviderConfig ¶
type ProviderConfig struct {
// Kind is the driver: vault, openbao, aws, gcp, file.
Kind string `json:"kind" yaml:"kind"`
// Address is the Vault/OpenBao API base URL (https://host:8200).
Address string `json:"address,omitempty" yaml:"address,omitempty"`
// Namespace is a Vault Enterprise namespace. Unused for OpenBao.
Namespace string `json:"namespace,omitempty" yaml:"namespace,omitempty"`
// KVMount is the KV secrets engine mount (default "secret").
KVMount string `json:"kv_mount,omitempty" yaml:"kv_mount,omitempty"`
// Token is a Vault/OpenBao token (dev/break-glass). Prefer TokenPath.
Token string `json:"token,omitempty" yaml:"token,omitempty" secret:"redact"`
// TokenPath is a file whose contents are the Vault/OpenBao token
// (Kubernetes-rotated file).
TokenPath string `json:"token_path,omitempty" yaml:"token_path,omitempty"`
// K8sRole is the Vault/OpenBao Kubernetes auth role. When set, Init
// logs in with the JWT at K8sJWTPath instead of Token/TokenPath.
K8sRole string `json:"k8s_role,omitempty" yaml:"k8s_role,omitempty"`
// K8sMount is the Kubernetes auth mount (default "kubernetes").
K8sMount string `json:"k8s_mount,omitempty" yaml:"k8s_mount,omitempty"`
// K8sJWTPath is the service-account token file (default
// /var/run/secrets/kubernetes.io/serviceaccount/token).
K8sJWTPath string `json:"k8s_jwt_path,omitempty" yaml:"k8s_jwt_path,omitempty"`
// TLSCAFile is an optional PEM CA for Vault/OpenBao HTTPS.
TLSCAFile string `json:"tls_ca_file,omitempty" yaml:"tls_ca_file,omitempty"`
// TLSInsecureSkipVerify skips TLS verify (lab only).
TLSInsecureSkipVerify *bool `json:"tls_insecure_skip_verify,omitempty" yaml:"tls_insecure_skip_verify,omitempty"`
// Region is the AWS region (required for kind aws).
Region string `json:"region,omitempty" yaml:"region,omitempty"`
// Endpoint overrides the AWS Secrets Manager endpoint (LocalStack / tests).
Endpoint string `json:"endpoint,omitempty" yaml:"endpoint,omitempty"`
// Project is the GCP project id (required for kind gcp).
Project string `json:"project,omitempty" yaml:"project,omitempty"`
// CredentialsFile is an optional Google service-account JSON path.
// Empty uses Application Default Credentials.
CredentialsFile string `json:"credentials_file,omitempty" yaml:"credentials_file,omitempty"`
// Root is the directory for kind file (local / tests).
Root string `json:"root,omitempty" yaml:"root,omitempty"`
// TimeoutSec bounds each provider HTTP/SDK call (default 10s).
TimeoutSec float64 `json:"timeout_sec,omitempty" yaml:"timeout_sec,omitempty"`
}
ProviderConfig is one named backend. Kind selects the API; the rest of the fields are interpreted by that kind. Unused fields for another kind are ignored (so one struct can hold vault, aws, gcp, and file settings).
Credential fields will grow (AppRole, IRSA-specific, GCP SA JSON path). v1: token/token_path or Kubernetes JWT for vault/openbao; AWS default credential chain; GCP Application Default Credentials.
type Ref ¶
Ref names one secret inside a provider. Callers always pass a provider name plus a Ref; they never choose the API (vault vs aws) themselves.
Path meanings by kind:
- vault / openbao: KV path under kv_mount (e.g. "caerus-framework/release-train-gh-app")
- aws: Secrets Manager name or ARN
- gcp: secret id (short name, or full "projects/…/secrets/…" resource)
- file: path relative to the provider root
Key, when set, selects a field: Vault/OpenBao KV property, or a JSON object key for AWS/GCP string payloads. Empty Key returns the whole payload.
Version is optional (GCP version id, AWS version id/stage, Vault KV version). Empty means the provider default (usually latest).
type SecretsConfig ¶
type SecretsConfig struct {
// Providers is the named set of backends. The map key is the provider
// name callers pass to Get (e.g. "openbao", "aws-prod"). It is not the
// kind.
Providers map[string]ProviderConfig `json:"providers" yaml:"providers"`
// DegradedMode — when true, a failed Init ping of a provider does not
// abort the process. Get still fails until that backend is reachable.
// Default off (hard Init). Pointer so omitted ≠ explicit false.
DegradedMode *bool `json:"degraded_mode,omitempty" yaml:"degraded_mode,omitempty" env:"DEGRADED_MODE"`
// HealthWhenDegraded: "not_ready" (default) or "ready". Controls Health()
// (and thus /readyz) while a configured provider cannot ping.
HealthWhenDegraded string `json:"health_when_degraded,omitempty" yaml:"health_when_degraded,omitempty" env:"HEALTH_WHEN_DEGRADED"`
}
SecretsConfig is the file/env-drivable configuration for the secrets chassis. Load it through the configuration component and pass it via WithConfigSource. The file is the canonical place to declare providers (Kubernetes: a mounted ConfigMap/Secret). Env overlay of the providers map is not the rotation plane.
type SourceOption ¶
type SourceOption func(*sourceOptions)
SourceOption configures the self-registered configuration source created by WithConfigSource.
func WithSourceEnvPrefix ¶
func WithSourceEnvPrefix(prefix string) SourceOption
WithSourceEnvPrefix sets the environment overlay prefix for the source (default: the uppercase source name with "-" replaced by "_", plus "_"). An empty prefix disables env overlay.
func WithSourceFormat ¶
func WithSourceFormat(f cf_configuration.Format) SourceOption
WithSourceFormat forces the file format instead of inferring it from the path extension.