Documentation
¶
Overview ¶
Package configcmd implements the `vigolium config` command group.
It is the first command group split out of the flat pkg/cli package into its own subpackage. Rather than self-registering via init() into a package-private rootCmd, it exposes an explicit NewCommand(deps, examples) constructor that pkg/cli wires onto the root command. All of the implicit package-global state the commands previously reached for (the --config / --force flag values and the first-run reinitializer) is passed in explicitly via Deps, so this package has no dependency back on pkg/cli.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsBadSetting ¶ added in v0.5.7
IsBadSetting reports whether a failed write names no setting or a value that cannot be stored under it (a list that does not parse, a bool that is not true/false, a scope pattern that validation rejects): a mistake on the command line (exit 2), not a failure to write the config. Nothing was written.
Types ¶
type Deps ¶
type Deps struct {
// ConfigFlag returns the raw --config flag value (may be empty).
ConfigFlag func() string
// Force returns the --force flag value.
Force func() bool
// Reinitialize regenerates ~/.vigolium with fresh defaults (used by `config clean`).
Reinitialize func() error
// JSON reports whether the caller asked for machine output. The config
// commands accepted the persistent --json flag and ignored it, printing
// ANSI-colored prose to stdout and exiting 0 — so a consumer's parse failed
// for a reason the exit code did not describe.
JSON func() bool
// WriteJSON emits a result through the CLI's shared envelope writer, so a
// config result has the same schema_version/items/generated_at spine as every
// other -j payload rather than a second shape invented here. total is the row
// count, which the caller already knows — passing it avoids reflecting over
// the slice on the other side of the seam. cmd names the document.
WriteJSON func(cmd *cobra.Command, legacyKey string, items any, total int, extra map[string]any) error
// WriteMutation emits a state-changing command's result through the CLI's
// mutation spine (kind "mutation", changed, action, dry_run). changed and
// action are arguments, not extras: the envelope owns those keys, and an
// extra named "changed" is dropped rather than rendered.
WriteMutation func(cmd *cobra.Command, items any, changed bool, action string, extra map[string]any) error
// WriteDryRunMutation is WriteMutation for a --dry-run: dry_run true and
// changed false.
WriteDryRunMutation func(cmd *cobra.Command, items any, action string, extra map[string]any) error
// RecentScanTargets returns the targets of the n most recent scans in the
// given project ("" = the project the CLI resolves by default), for
// `config validate`'s scope_include_matches_no_recent_target rule. Injected
// because this package cannot reach the database. nil, or an error (no
// database yet), skips the rule.
RecentScanTargets func(projectUUID string, n int) ([]string, error)
// ProjectSettings loads the settings a scan in the invocation's project
// runs under (global config, then the project overlay) and names that
// project ("" = no overlay). nil falls back to the global config alone.
ProjectSettings func() (*config.Settings, string, error)
// FlagKeys lists the settings keys a global flag of this invocation sets
// (--db → database.sqlite.path), for the provenance column.
FlagKeys func() []string
}
Deps carries the runtime dependencies the config commands need, injected by pkg/cli so this package stays decoupled from the CLI's global flag state.
type EntryView ¶ added in v0.5.7
type EntryView struct {
Key string `json:"key"`
Value any `json:"value"`
Display string `json:"display"`
Default any `json:"default"`
Type string `json:"type"`
Source string `json:"source"`
Sensitive bool `json:"sensitive"`
Empty bool `json:"empty"`
Redacted bool `json:"redacted"`
}
EntryView is one setting in the shape a machine consumer reads.
Value is typed (bool, number, string, list, object) and REDACTED under the default policy when the key is a string credential; Display is the string the human table prints. `sensitive` is carried so a consumer can tell a genuinely empty setting from one that was withheld.
type EnvView ¶ added in v0.5.7
type EnvView struct {
Name string `json:"name"`
Set bool `json:"set"`
Value string `json:"value,omitempty"`
Redacted bool `json:"redacted"`
Sensitive bool `json:"sensitive"`
OverridesKey string `json:"overrides_key,omitempty"`
Template bool `json:"template,omitempty"`
Description string `json:"description"`
}
EnvView is one `config env` row.
type UnsetResult ¶ added in v0.5.7
type UnsetResult struct {
Key string `json:"key"`
Removed bool `json:"removed"`
ConfigPath string `json:"config_path"`
}
UnsetResult is the `config unset -j` row.