Documentation
¶
Overview ¶
Package config implements the "config" CLI command and its subcommands for programmatic read/write access to individual configuration keys. It is intended for CI automation and scripted setup rather than interactive use (for interactive reconfiguration, use "init <subsystem>" instead).
Index ¶
- func NewCmdConfig(props *p.Props, opts ...MaskerOption) *cobra.Command
- func NewCmdGet(props *p.Props, masker *Masker) *cobra.Command
- func NewCmdList(props *p.Props, masker *Masker) *cobra.Command
- func NewCmdSet(props *p.Props) *cobra.Command
- func NewCmdValidate(props *p.Props) *cobra.Command
- type Masker
- type MaskerOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewCmdConfig ¶
func NewCmdConfig(props *p.Props, opts ...MaskerOption) *cobra.Command
NewCmdConfig returns the top-level "config" command with all subcommands attached. MaskerOptions extend the built-in sensitive key and value patterns, allowing tool authors to register their own credential formats.
func NewCmdList ¶
NewCmdList returns the "config list" subcommand.
Types ¶
type Masker ¶
type Masker struct {
// contains filtered or unexported fields
}
Masker detects and masks sensitive configuration values using two independent strategies: key-name pattern matching and value content regular expressions. The zero value is not useful; construct with NewMasker.
func NewMasker ¶
func NewMasker(opts ...MaskerOption) *Masker
NewMasker constructs a Masker with built-in key patterns and value regexes, extended by any provided options. Built-in defaults are never mutated.
func (*Masker) IsSensitive ¶
IsSensitive returns true if the key's leaf segment matches a sensitive key pattern OR the value matches a sensitive value pattern.
func (*Masker) Mask ¶
Mask returns the value with all but the last 4 characters replaced by asterisks. Returns a fully asterisked string if the value is 4 characters or fewer.
func (*Masker) MaskIfSensitive ¶
MaskIfSensitive applies Mask only when IsSensitive returns true for the given key/value pair; otherwise returns the value unchanged.
type MaskerOption ¶
type MaskerOption func(*Masker)
MaskerOption configures a Masker.
func WithKeyPattern ¶
func WithKeyPattern(pattern string) MaskerOption
WithKeyPattern registers an additional key-name substring (case-insensitive) that marks a key as sensitive. Extends the built-in list; does not replace it.
func WithValuePattern ¶
func WithValuePattern(re *regexp.Regexp) MaskerOption
WithValuePattern registers an additional compiled regexp that, when matched against a value, marks it as sensitive regardless of the key name.