secrets

package
v0.0.73 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: Apache-2.0 Imports: 18 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. It never substitutes a named secret or evaluates default strings.

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 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 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 to prevent disclosure across tasks. It has no name-to-value lookup and is cleared when the local execution ends.

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) NewTask added in v0.0.67

func (s *Redactor) NewTask() *Session

func (*Redactor) Redact added in v0.0.67

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

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. Cross-task reuse belongs to JobDB; the shared Redactor 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 task-context API; JobDB owns execution-scoped caching and coalescing.

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

type Sessions

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

Sessions shares redaction tracking across a local job execution. It never stores names or values for materializing task inputs.

func NewSessions

func NewSessions() *Sessions

func (*Sessions) Close

func (m *Sessions) Close(key jobdb.JobKey)

func (*Sessions) CloseExecution added in v0.0.72

func (m *Sessions) CloseExecution(key jobdb.JobKey, redactor *Redactor)

CloseExecution cannot close a newer activation of the same job.

func (*Sessions) Get

func (m *Sessions) Get(key jobdb.JobKey) *Redactor

func (*Sessions) GetExecution added in v0.0.72

func (m *Sessions) GetExecution(ctx context.Context, key jobdb.JobKey) *Redactor

func (*Sessions) Open

func (m *Sessions) Open(key jobdb.JobKey) (*Redactor, error)

func (*Sessions) OpenExecution added in v0.0.72

func (m *Sessions) OpenExecution(ctx context.Context, key jobdb.JobKey) (*Redactor, error)

OpenExecution allows recovery once the previous activation is cancelled, even while its abandoned callbacks are still unwinding.

Jump to

Keyboard shortcuts

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