Resolve the config path; print help on a bare invocation #3
Reference in New Issue
Block a user
Delete Branch "benvin/legacy-invocation"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Puppet calls the binary from generate() as the puppet user, which has no usable HOME, so only the baked-in /opt/certmanager/config.yaml can resolve — but an operator running it by hand wants their own config, and a bare invocation currently errors on the missing positional instead of explaining itself.
cmd/certmanager/main.go:63— a bare invocation now exits 0 with help text on stdout. Undergenerate(..., combine: true)the exit code is the only failure signal, so any argv that loses the common name turns a loud compile failure into 15 lines of help spliced into the catalog. Gate the help path on stdout being a TTY and exit non-zero otherwise.internal/config/config.go:42— the XDG/HOME lookup runs on the Puppet path too; "the puppet user has no usable HOME" is an assumption the code does not enforce. A~/.config/certmanager/config.yamlunder the puppetserver's HOME silently repoints every compile estate-wide, and nothing can report which config was used because stderr is spliced. Consult XDG/HOME only when stdout is a TTY, or behind an explicit opt-in.cmd/certmanager/main_test.go:779—run(nil, ...)does not test a bare invocation:SetArgs(nil)makes cobra fall back toos.Args[1:], and it only passes because pflag silently swallows-test.*shorthands.go test ./cmd/certmanager -args foofails it. Pass[]string{}.test/integration/certmanager_test.go:277—exec.Command(bin, args...)inheritsHOME/XDG_CONFIG_HOME, so the comment's "exactly the argv Puppet uses -- no--config" no longer holds: a developer's~/.config/certmanager/config.yamlshadows the baked path and the test talks to the wrong Vault. Setcmd.Envwith both cleared.config.go,config_test.go, the twoconfig.Resolvecall sites, README Configuration); (2) bare-invocation help (Args, theRunEguard,TestRunNoArgsPrintsHelp, README/AGENTS CLI lines).internal/config/config.go:43— a relativeXDG_CONFIG_HOMEis joined against the cwd instead of being ignored, and undergenerate()the cwd is puppetserver's. Requirefilepath.IsAbs(base).cmd/certmanager/main.go:94—--config ''used to fail on the empty path and now silently falls through to resolution. Undocumented contract change.internal/config/config_test.go:215—Resolve("") == explicitis vacuous (explicitis a tempfile elsewhere); it passes whatever the fallback does. Assert it equalsDefaultPath().