Documentation
¶
Overview ¶
Package cli builds the patchy command tree.
The grammar is Kubernetes-standard: patchy <verb> <noun> [name...]. Verbs are cobra commands, nouns are resolved through the resource registry, and adding a noun never adds a verb. This keeps the surface predictable as new nouns arrive alongside the pipeline ones.
Two rules hold everywhere in this package:
- stdout is data, stderr is narration. Anything a script might parse goes to stdout and nothing else does, so `patchy get findings -o json | jq` works with logging turned all the way up.
- presentation is decided once, from the output format and whether stdout is a terminal, never per call site. See internal/printer.
Index ¶
- Constants
- func Execute() int
- func NewRoot(opts *Options) *cobra.Command
- type Options
- func (o *Options) Connect() (*kubecfg.Env, error)
- func (o *Options) Printer() (*printer.Printer, error)
- func (o *Options) Timeout(ctx context.Context) (context.Context, context.CancelFunc)
- func (o *Options) WithAccess(fn func(context.Context, *kubecfg.Env, string, string) (bool, error))
- func (o *Options) WithArchive(fn func(context.Context, archive.Config) (archive.Store, error))
- func (o *Options) WithEnv(env *kubecfg.Env)
- func (o *Options) WithIdentity(fn func() string)
Constants ¶
const ( // ExitOK reports success. ExitOK = 0 // ExitError reports a runtime failure: unreachable cluster, bad response. ExitError = 1 // ExitUsage reports a malformed invocation. Cobra's own errors land here. ExitUsage = 2 // ExitNotFound reports that a named resource does not exist. ExitNotFound = 3 // ExitDenied reports that RBAC refused the action, or that the finding's // current phase (or the backfill request's state) has no use for it. Both // mean nothing was done, which is what a script needs to know. ExitDenied = 4 )
Exit codes. A CLI that only ever returns 1 forces scripts to grep stderr, so the cases a caller might reasonably branch on get their own code.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Options ¶
type Options struct {
Kubeconfig string
Context string
Namespace string
AllNamespaces bool
Output string
NoColor bool
RequestTimeout time.Duration
Verbose bool
// Out and ErrOut are the streams commands write to. They live here rather
// than as globals so tests can capture them.
Out io.Writer
ErrOut io.Writer
// contains filtered or unexported fields
}
Options carries the persistent flags and the lazily-resolved cluster connection. One instance is shared by the whole command tree.
func (*Options) WithAccess ¶
WithAccess pins the access-review answer. The fn receives (resource, verb).
func (*Options) WithArchive ¶ added in v0.14.0
WithArchive pins the archive store the CLI reads, bypassing the cloud SDK credential chains.
func (*Options) WithIdentity ¶
WithIdentity pins the identity actions are recorded under.