secrets

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package secrets holds a run's resolved credentials.

This package resolves nothing: mamori does, before senro.Run is called, and this package takes the values out of the struct mamori.Load returned. senro defines no provider interface, hence no registry, pinning or watch loop anywhere.

A value is unexported inside a Secret and leaves this package through exactly one accessor, Value, so every route to a plaintext credential is one grep away.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Identity

type Identity struct {
	Name    string `json:"name"`
	Source  string `json:"source,omitempty"`
	Version string `json:"version,omitempty"`
}

Identity is a Secret with no value at all: the form that leaves this package for an event payload or a cache key, making "no value here" a property of the type rather than of a caller's discipline.

func (Identity) String

func (i Identity) String() string

String renders an Identity, which by construction has nothing to hide.

type Secret

type Secret struct {
	// Name is the Go struct field a step references with SecretEnv. A field
	// inside a named nested struct is qualified with a dot ("Registry.Token");
	// a field promoted from an embedded struct keeps its bare name, matching
	// Go's own promotion.
	Name string
	// Source is the mamori source: tag with any userinfo and any query
	// removed (see sourceIdentity). It is identity, never content, and it is
	// what reaches a secret.resolved event and a cache key's Secrets
	// component.
	Source string
	// Version is the provider's version for this value. Always "": mamori
	// surfaces Value.Version to a provider, not to Load's caller. Declared
	// because the cache key's secret identity keys on it and
	// api.SecretResolvedBody already publishes the field.
	Version string
	// contains filtered or unexported fields
}

Secret is one resolved credential and the identity of where it came from.

func (Secret) LogValue

func (s Secret) LogValue() slog.Value

LogValue keeps a Secret out of a structured log line, the same way mamori's own secret.String does.

func (Secret) String

func (s Secret) String() string

String renders a Secret for a %v, a %s and a panic dump without its value.

type Set

type Set struct {
	// contains filtered or unexported fields
}

Set is a run's resolved secrets. The nil *Set is a run with none, and every method treats it as empty so the engine's call sites never branch.

func FromConfig

func FromConfig(cfg any) (*Set, error)

FromConfig walks the struct mamori.Load returned and collects every secret in it: the whole seam between mamori and senro's redaction. This is the only place Reveal() should appear; reveal_static_test.go at the repository root mechanises that grep and fails the build on a second call site.

cfg may be a struct or a pointer to one; anything else is refused by name, rather than a run that starts with an empty set and delivers nothing.

func (*Set) Has

func (s *Set) Has(name string) bool

Has reports whether name resolved to a value, which is what the engine's reference check asks before a step declares it needs one.

func (*Set) Identities

func (s *Set) Identities() []Identity

Identities is every secret's identity, sorted by name. This is what the engine emits as secret.resolved and what the cache key builder folds in.

func (*Set) Identity

func (s *Set) Identity(name string) (Identity, bool)

Identity looks one secret's identity up by name, for the cache key builder, which needs source and version beside a digest of the value and must never hold the two in one struct.

func (*Set) Len

func (s *Set) Len() int

Len is how many secrets resolved to a non-empty value.

func (*Set) Names

func (s *Set) Names() []string

Names is every resolved secret's name, sorted, so an error message that lists them is stable.

func (*Set) RedactValues

func (s *Set) RedactValues() []redact.Value

RedactValues is the seed for the run's redactor: every value labelled by name, so redact.Set.Match can say which secret it found without printing it. Called once in engine.Run, before the first event, so redaction is live before anything can write to the ledger.

func (*Set) Value

func (s *Set) Value(name string) ([]byte, bool)

Value is the one accessor that hands back a plaintext credential.

It has THREE callers, all in package engine, none keeping a copy beyond immediate use; TestSetValueCallSitesAreAllowlisted (reveal_static_test.go at the repository root) pins them by name, so a fourth caller fails the build. It returns a copy, so a caller that mutates or retains the slice cannot reach back into this Set.

Jump to

Keyboard shortcuts

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