secretsauce

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package secretsauce resolves secret values from either a literal plain-text value or the standard output of an external command.

A Source carries both a literal Value and a Command. Resolution prefers the literal value and otherwise executes the command, capturing its standard output as the secret. Commands are executed directly via argv without a shell, must reference an absolute-path executable, run under a timeout, and have their output size capped.

The package is self-contained and free of any application-specific naming so it can be reused independently.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Source

type Source struct {
	// Value is a literal plain-text secret. When non-empty (after trimming
	// surrounding whitespace) it is returned as-is.
	Value string
	// Command is a command line whose standard output provides the secret. It
	// is parsed into argv and executed directly, without a shell. The
	// executable must be an absolute path.
	Command string
}

Source describes how to obtain a single secret value. Value takes precedence over Command when both are set.

func FromEnv

func FromEnv(name string) Source

FromEnv builds a Source from environment variables using a conventional naming scheme. The literal value is read from name, and the command from name+"_COMMAND" (falling back to name+"_CMD").

func (Source) Resolve

func (s Source) Resolve(ctx context.Context, name string) (string, error)

Resolve returns the secret value for the source. If Value is set it is returned directly; otherwise Command is executed and its standard output is returned. The name is used only to produce descriptive error messages and may be empty. When neither Value nor Command is set, Resolve returns an empty string and a nil error.

Jump to

Keyboard shortcuts

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