ward

package
v0.1.68 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package ward provides the application engine layer between the CLI and the secrets package. All orchestration logic lives here; the CLI layer only handles flag parsing and output formatting.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Encryptor

type Encryptor interface {
	Encrypt(path string, plaintext []byte) error
}

Encrypt writes content back to path using the configured encryptor. For SopsDecryptor this calls "sops encrypt"; for MockDecryptor it writes plain.

type Engine

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

Engine orchestrates secret discovery, loading, merging and env-var resolution. The zero value is not usable; construct via NewEngine.

func NewEngine

func NewEngine(cfg *config.Config, dec sops.Decryptor) *Engine

NewEngine returns an Engine backed by cfg and dec.

func (*Engine) Decrypt

func (e *Engine) Decrypt(path string) ([]byte, error)

Decrypt returns the plain-text YAML bytes of a .ward file using the configured decryptor. For plain (unencrypted) files this is a passthrough.

func (*Engine) Encrypt

func (e *Engine) Encrypt(path string, plaintext []byte) error

Encrypt re-encrypts plaintext and writes it to path. Falls back to a plain write when no real encryptor is configured.

func (*Engine) EnvVars

func (e *Engine) EnvVars(r *MergeResult, prefixed bool) (map[string]secrets.EnvEntry, error)

EnvVars resolves env vars from the merged result. Flat leaf names (DATABASE_URL), or full path if --prefixed.

func (*Engine) EnvVarsMap

func (e *Engine) EnvVarsMap(r *MergeResult, prefixed bool) (map[string]string, error)

EnvVarsMap is like EnvVars but returns plain string values (for injection into a child process environment).

func (*Engine) EnvVarsPrefer

func (e *Engine) EnvVarsPrefer(r *MergeResult, prefixed bool, preferPrefix string) (map[string]secrets.EnvEntry, error)

EnvVarsPrefer is like EnvVars but resolves env var collisions in favour of entries whose dot-path is under preferPrefix. All other vars from the full tree are still included.

func (*Engine) GetAtPath

func (e *Engine) GetAtPath(r *MergeResult, dotPath string) (*secrets.Node, error)

GetAtPath navigates the merged tree by dot-path and returns the node at that location, or an error if the path does not exist.

func (*Engine) Inspect

func (e *Engine) Inspect() error

Inspect runs a conflict-only merge and returns a ConflictError if any conflicts exist, or nil when the set of files is clean.

func (*Engine) Merge

func (e *Engine) Merge() (*MergeResult, error)

Merge loads all .ward files from all vaults and merges them using the on_conflict mode from the configuration. Merge loads all vaults and merges them. Any conflict is an error.

func (*Engine) MergeForView

func (e *Engine) MergeForView() (*MergeResult, error)

MergeForView is like Merge but always produces a complete tree even when conflicts exist. Conflict information is attached to the result so the presentation layer can highlight conflicting keys.

func (*Engine) MergeScoped

func (e *Engine) MergeScoped(scopePrefix string) (*MergeResult, error)

MergeScoped is like Merge but scopes conflict detection to a dot-path prefix. Conflicts outside that prefix are silently resolved so the scoped path can be used without being blocked by unrelated conflicts.

func (*Engine) SourcePaths

func (e *Engine) SourcePaths() []string

SourcePaths returns the configured source directory paths.

type MergeResult

type MergeResult struct {
	Tree        map[string]*secrets.Node
	ConflictErr *secrets.ConflictError // non-nil only when called via MergeForView
}

MergeResult is the outcome of a load-and-merge operation.

Jump to

Keyboard shortcuts

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