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

secrets

package
v0.0.102 Latest Latest
Warning

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

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

Documentation

Overview

Package secrets carries opaque references across durable boundaries. Only a live runner session may replace them with plaintext.

Index

Constants

View Source
const WireKey = "$c2j_secret"

Variables

This section is empty.

Functions

func ApplySchemaDefaults added in v0.0.67

func ApplySchemaDefaults(schema map[string]any, value any) (any, error)

ApplySchemaDefaults attaches fallbacks to secret bindings, including omitted inputs. Named default bindings stay opaque until task-time materialization.

func Contains

func Contains(v any) bool

func ExpandSchema

func ExpandSchema(schema map[string]any) (map[string]any, error)

ExpandSchema admits a reference as the deferred representation of a secret string. ValidateSchema separately enforces that submission uses references.

func HasAnnotation

func HasAnnotation(value any) bool

func HasOmission added in v0.0.67

func HasOmission(v any) bool

func InvocationNames

func InvocationNames(t reflect.Type, input any) ([]string, error)

Forwarding fields carry references to a child job and never materialize them in the parent. The child validates its own recipe schema before executing.

func MaskLogger added in v0.0.90

func MaskLogger(logger *slog.Logger, redactor *Redactor) *slog.Logger

MaskLogger binds masking to one task's redactor. It never changes global loggers. Bind before With/WithGroup so later-resolved values are also masked.

func MaterializeInput

func MaterializeInput(s *Session, t reflect.Type, input any) (any, error)

func MaterializeInputWithUnsetEnv added in v0.0.67

func MaterializeInputWithUnsetEnv(s *Session, t reflect.Type, input any) (any, []string, error)

func Names

func Names(v any) ([]string, error)

func Placeholder

func Placeholder(v any) (any, error)

Placeholder is for type validation only and is never used for execution.

func Transform

func Transform(v any, f func(Reference) (any, error)) (any, error)

Transform clones JSON-shaped data; a reserved reference object is atomic.

func ValidateDefault added in v0.0.67

func ValidateDefault(value any) error

ValidateDefault checks public literal defaults; they are never evaluated.

func ValidateSchema

func ValidateSchema(schema map[string]any, v any, materialized bool) error

Schema annotations apply to string leaves. Unsupported schema constructs cannot implicitly grant permission to a reference.

func ValidateType

func ValidateType(t reflect.Type, v any) error

ValidateType permits native ops to opt in with secret:"true" on string inputs, or secret:"env" on a map of environment variables. Extension payloads use secret:"schema" and are checked against their manifest before invocation.

func WithRedactor added in v0.0.99

func WithRedactor(ctx context.Context, redactor *Redactor) context.Context

func WithSession

func WithSession(ctx context.Context, s *Session) context.Context

Types

type Redactor added in v0.0.67

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

Redactor remembers secret material only for one task invocation. It has no name-to-value lookup and is never shared between task attempts.

func NewRedactor added in v0.0.99

func NewRedactor() *Redactor

func RedactorFromContext added in v0.0.99

func RedactorFromContext(ctx context.Context) *Redactor

func (*Redactor) CheckOutput added in v0.0.67

func (s *Redactor) CheckOutput(v any) error

func (*Redactor) Close added in v0.0.67

func (s *Redactor) Close()

func (*Redactor) Error added in v0.0.67

func (s *Redactor) Error(err error) error

Errors with secret-bearing messages lose their unwrap chain: retaining it would let error-chain diagnostics serialize the original plaintext.

func (*Redactor) GoString added in v0.0.67

func (*Redactor) GoString() string

func (*Redactor) MarshalJSON added in v0.0.67

func (*Redactor) MarshalJSON() ([]byte, error)

func (*Redactor) NewSession added in v0.0.99

func (s *Redactor) NewSession() *Session

NewSession retains the masks and provides a private value cache within this invocation.

func (*Redactor) Redact added in v0.0.67

func (s *Redactor) Redact(text string) string

func (*Redactor) Register added in v0.0.93

func (s *Redactor) Register(value string) error

Register adds dynamically acquired credentials before they reach subprocesses.

func (*Redactor) String added in v0.0.67

func (*Redactor) String() string

type Reference

type Reference struct {
	Name              string  `json:"$c2j_secret" yaml:"$c2j_secret"`
	Default           *string `json:"default,omitempty" yaml:"default,omitempty"`
	OmitIfUnavailable bool    `json:"omit_if_unavailable,omitempty" yaml:"omit_if_unavailable,omitempty"`
	// Required preserves a recipe's constraint when a null fallback is forwarded.
	Required bool `json:"required,omitempty" yaml:"required,omitempty"`
}

Reference holds an opaque name and an optional public fallback. An empty name with a fallback represents an omitted input with a schema default.

func Expression

func Expression(expr string) (Reference, bool)

func InvocationReferences added in v0.0.67

func InvocationReferences(t reflect.Type, input any) ([]Reference, error)

InvocationReferences excludes references forwarded to child jobs.

func Parse

func Parse(v any) (Reference, bool, error)

func Template

func Template(text string) (Reference, bool)

func WithDefault added in v0.0.67

func WithDefault(r Reference, value any) Reference

WithDefault attaches a public fallback without overriding an explicit fallback.

type Resolver

type Resolver func(context.Context, []string) (jobdb.SecretResolveResult, error)

type Session

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

Session contains only one task attempt's transient secret values. Its redactor is shared only within that invocation and cannot resolve names.

func FromContext

func FromContext(ctx context.Context) *Session

func NewSession

func NewSession() *Session

func (*Session) CheckOutput

func (s *Session) CheckOutput(value any) error

func (*Session) Close

func (s *Session) Close()

func (*Session) Error

func (s *Session) Error(err error) error

func (*Session) GoString

func (*Session) GoString() string

func (*Session) MarshalJSON

func (*Session) MarshalJSON() ([]byte, error)

func (*Session) Materialize

func (s *Session) Materialize(v any) (any, error)

func (*Session) Prepare

func (s *Session) Prepare(ctx context.Context, names []string, resolve Resolver) error

func (*Session) PrepareReferences added in v0.0.67

func (s *Session) PrepareReferences(ctx context.Context, refs []Reference, resolve Resolver) error

PrepareReferences batches only the current task's names. Every preparation calls the supplied resolver; any underlying caching belongs to JobDB.

func (*Session) Ready

func (s *Session) Ready(names []string) bool

func (*Session) Redact

func (s *Session) Redact(text string) string

func (*Session) String

func (*Session) String() string

Jump to

Keyboard shortcuts

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