secret

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: MIT Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package secret has the type of a secret in the three DSLs: Value, a reference, secret://<vault>/<key>, or a literal value. A field of this type is a secret: the spec makes it write-only, validate keeps it out of a span and a URL, the CLI refuses a literal in a flag, and each record shows the reference, or [redacted] for a literal. Only Reveal gives the value.

Index

Constants

View Source
const Redacted = "[redacted]"

Redacted is what a literal value shows as, in each record.

View Source
const Scheme = "secret://"

Scheme starts each reference: secret://<vault>/<key>.

View Source
const Takes = "A secret: a reference, secret://<vault>/<key>, or the value."

Takes is what a secret field takes, as its description in the spec, the docs and method get says.

Variables

This section is empty.

Functions

func Describe

func Describe(
	doc string,
) string

Describe is doc, the description of a secret field, with Takes.

func Fields

func Fields(
	t reflect.Type,
) []string

Fields are the JSON names of the fields of t, a struct or a pointer to one, that hold a secret, at each depth: the names that the audit redacts.

func Has

func Has(
	x any,
) bool

Has reports whether x holds a Value that is not empty, at each depth.

func Is

func Is(
	t reflect.Type,
) bool

Is reports whether a field of type t holds a secret: a Value, or a pointer, a slice, an array or a map of them, such as map[string]secret.Value.

func Map

func Map(
	x any,
	fn func(v Value) (Value, error),
) error

Map replaces each Value in *x that is not empty, at each depth, with the Value that fn gives for it: the agent opens each sealed value with it. x is a pointer. The first error of fn stops it, and is its error, and the Value that failed stays as it was.

func Parse

func Parse(
	ref string,
) (string, string, error)

Parse is the vault and the key of the reference ref, secret://<vault>/<key>. A ref that is not a reference, or that has no vault or no key, is an error that gives the form.

func Plain

func Plain(
	x any,
) any

Plain is a copy of x in which each Value is a string, so it marshals its value: the CLI sends the request with it, and the dispatch of a behavior queues the job with it. Each other marshal of x gives the reference, or Redacted. A struct that holds a secret becomes a struct of the same fields and tags, so JSON reads it as it reads x. x is as it is when it holds no secret.

func PlainFunc

func PlainFunc(
	x any,
	fn func(v Value) string,
) any

PlainFunc is Plain, with each Value that is not empty as fn gives it: the job client seals each value of a job with it. An empty Value stays empty.

func References

func References(
	x any,
) []string

References are the references in x, at each depth, in the order of its fields, with the keys of a map in order.

func Resolve

func Resolve(
	x any,
	fn func(ref string) (string, error),
) error

Resolve replaces each reference in *x, at each depth, with the value that fn gives for it. x is a pointer. The first error of fn stops it, and is its error.

func Unresolved

func Unresolved(
	ref string,
) error

Unresolved is the error of the reference ref, which no vault resolves. A command of the command DSL has no vault yet, so it refuses each reference with it: a reference is never sent as the value.

Types

type Value

type Value string

Value is a secret: a reference, such as secret://default/registry-token, or a literal value. String, Format, MarshalJSON and LogValue give the reference, or Redacted for a literal, so a log line, a span, a chain record or an audit entry never has the value. Reveal gives it, where a provider gives it to a command's standard input, an environment or a file. The route of each method resolves a reference from its vault, before the handler gets the input.

It is a string to JSON and to the validate tags, so a request carries it as a string and no_linebreak checks it as one. A conversion to string gives the value too: use Reveal, which a reader can find.

func (Value) Format

func (v Value) Format(
	f fmt.State,
	verb rune,
)

Format prints String with each verb, so %v, %s, %q and %#v never print a literal value.

func (Value) IsReference

func (v Value) IsReference() bool

IsReference reports whether v is a reference, secret://<vault>/<key>, and not a literal value.

func (Value) IsZero

func (v Value) IsZero() bool

IsZero reports whether v is empty.

func (Value) LogValue

func (v Value) LogValue() slog.Value

LogValue is String, so slog never logs a literal value.

func (Value) MarshalJSON

func (v Value) MarshalJSON() ([]byte, error)

MarshalJSON is String as a JSON string. Plain gives a copy of an input whose secrets marshal their values, for the request and the job.

func (Value) Reveal

func (v Value) Reveal() string

Reveal is the value: the literal, or the reference as it is.

func (Value) String

func (v Value) String() string

String is the reference, Redacted for a literal, or "" when v is empty.

Directories

Path Synopsis
Package seal keeps the secret values of a job from each reader but its target agents.
Package seal keeps the secret values of a job from each reader but its target agents.
Package vault is the store of secrets that the controller resolves a secret://<vault>/<key> reference from.
Package vault is the store of secrets that the controller resolves a secret://<vault>/<key> reference from.
mocks
Package mocks provides mock implementations for testing.
Package mocks provides mock implementations for testing.
natsvault
Package natsvault is the nats type of vault, the one that osapi ships.
Package natsvault is the nats type of vault, the one that osapi ships.
natsvault/mocks
Package mocks provides mock implementations for testing.
Package mocks provides mock implementations for testing.

Jump to

Keyboard shortcuts

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