config

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: May 18, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const ConfigFileName = ".skret.yaml"

ConfigFileName is the expected config file name.

Variables

View Source
var ErrConfigNotFound = errors.New("config: .skret.yaml not found")

ErrConfigNotFound is returned when .skret.yaml cannot be found.

Functions

func Discover

func Discover(startDir string) (string, error)

Discover walks from startDir upward to find .skret.yaml, stopping at git root or filesystem root.

func NormalizeSSMPath added in v1.3.0

func NormalizeSSMPath(p string) string

NormalizeSSMPath ensures a path prefix has the leading slash SSM requires. Operators on Git Bash should pass --path without a leading slash (e.g. --path=myapp/prod) so MSYS does not rewrite it into a Windows path; this restores the canonical "/myapp/prod" form. A drive-lettered value (C:\...) is left untouched so a genuinely shell-mangled path fails visibly instead of silently querying the wrong prefix.

func ResolveKey added in v1.3.0

func ResolveKey(resolvedPath, key string) (string, bool)

ResolveKey maps a user-supplied key to a fully-qualified provider key using the resolved path prefix. It accepts a bare leaf ("DB_PASSWORD"), an already-qualified key ("/myapp/prod/DB_PASSWORD"), a genuine absolute key outside the configured path (passed through), and recovers keys mangled by POSIX-emulation shells on Windows — Git Bash/MSYS rewrites a leading "/arg" into "C:/.../<arg>". The bool reports whether mangling was recovered so the caller can warn the operator.

Types

type Config

type Config struct {
	Version      string                 `yaml:"version"`
	DefaultEnv   string                 `yaml:"default_env"`
	Project      string                 `yaml:"project"`
	Environments map[string]Environment `yaml:"environments"`
	Required     []string               `yaml:"required"`
	Exclude      []string               `yaml:"exclude"`
}

Config is the root schema for .skret.yaml.

func EphemeralConfig added in v1.3.0

func EphemeralConfig(opts ResolveOpts) *Config

EphemeralConfig builds an in-memory single-environment config from CLI flags so commands can run without a .skret.yaml when --path is supplied. Region and profile are left to the provider SDK's own resolution chain unless explicitly given (skret is a public tool — no hardcoded regional default).

func Load

func Load(path string) (*Config, error)

Load reads and validates a .skret.yaml from the given path.

func (*Config) Validate

func (c *Config) Validate() error

Validate checks all required fields and cross-references.

type Environment

type Environment struct {
	Provider string `yaml:"provider"`
	Path     string `yaml:"path"`
	Region   string `yaml:"region"`
	Profile  string `yaml:"profile"`
	KMSKeyID string `yaml:"kms_key_id"`
	File     string `yaml:"file"`
}

Environment defines provider configuration for one environment.

type ResolveOpts

type ResolveOpts struct {
	Env      string // --env flag or SKRET_ENV
	Provider string // --provider flag
	Path     string // --path flag
	Region   string // --region flag
	Profile  string // --profile flag
	File     string // --file flag
}

ResolveOpts holds CLI flag overrides for config resolution.

type ResolvedConfig

type ResolvedConfig struct {
	EnvName  string
	Provider string
	Path     string
	Region   string
	Profile  string
	KMSKeyID string
	File     string
	Required []string
	Exclude  []string
}

ResolvedConfig is the final resolved configuration after precedence resolution.

func Resolve

func Resolve(cfg *Config, opts ResolveOpts) (*ResolvedConfig, error)

Resolve applies the precedence chain: CLI flags > env vars > config file > defaults.

Jump to

Keyboard shortcuts

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