Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add default value to output format flag description #3713

Merged
merged 2 commits into from
Dec 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions cmd/spire-server/cli/agent/agent_posix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,37 +8,37 @@ var (
-matchSelectorsOn string
The match mode used when filtering by selectors. Options: exact, any, superset and subset (default "superset")
-output value
Desired output format (pretty, json)
Desired output format (pretty, json); default: pretty.
-selector value
A colon-delimited type:value selector. Can be used more than once
-socketPath string
Path to the SPIRE Server API socket (default "/tmp/spire-server/private/api.sock")
`
banUsage = `Usage of agent ban:
-output value
Desired output format (pretty, json)
Desired output format (pretty, json); default: pretty.
-socketPath string
Path to the SPIRE Server API socket (default "/tmp/spire-server/private/api.sock")
-spiffeID string
The SPIFFE ID of the agent to ban (agent identity)
`
evictUsage = `Usage of agent evict:
-output value
Desired output format (pretty, json)
Desired output format (pretty, json); default: pretty.
-socketPath string
Path to the SPIRE Server API socket (default "/tmp/spire-server/private/api.sock")
-spiffeID string
The SPIFFE ID of the agent to evict (agent identity)
`
countUsage = `Usage of agent count:
-output value
Desired output format (pretty, json)
Desired output format (pretty, json); default: pretty.
-socketPath string
Path to the SPIRE Server API socket (default "/tmp/spire-server/private/api.sock")
`
showUsage = `Usage of agent show:
-output value
Desired output format (pretty, json)
Desired output format (pretty, json); default: pretty.
-socketPath string
Path to the SPIRE Server API socket (default "/tmp/spire-server/private/api.sock")
-spiffeID string
Expand Down
10 changes: 5 additions & 5 deletions cmd/spire-server/cli/agent/agent_windows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,37 +10,37 @@ var (
-namedPipeName string
Pipe name of the SPIRE Server API named pipe (default "\\spire-server\\private\\api")
-output value
Desired output format (pretty, json)
Desired output format (pretty, json); default: pretty.
-selector value
A colon-delimited type:value selector. Can be used more than once
`
banUsage = `Usage of agent ban:
-namedPipeName string
Pipe name of the SPIRE Server API named pipe (default "\\spire-server\\private\\api")
-output value
Desired output format (pretty, json)
Desired output format (pretty, json); default: pretty.
-spiffeID string
The SPIFFE ID of the agent to ban (agent identity)
`
evictUsage = `Usage of agent evict:
-namedPipeName string
Pipe name of the SPIRE Server API named pipe (default "\\spire-server\\private\\api")
-output value
Desired output format (pretty, json)
Desired output format (pretty, json); default: pretty.
-spiffeID string
The SPIFFE ID of the agent to evict (agent identity)
`
countUsage = `Usage of agent count:
-namedPipeName string
Pipe name of the SPIRE Server API named pipe (default "\\spire-server\\private\\api")
-output value
Desired output format (pretty, json)
Desired output format (pretty, json); default: pretty.
`
showUsage = `Usage of agent show:
-namedPipeName string
Pipe name of the SPIRE Server API named pipe (default "\\spire-server\\private\\api")
-output value
Desired output format (pretty, json)
Desired output format (pretty, json); default: pretty.
-spiffeID string
The SPIFFE ID of the agent to show (agent identity)
`
Expand Down
10 changes: 5 additions & 5 deletions cmd/spire-server/cli/bundle/bundle_posix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ var (
-id string
SPIFFE ID of the trust domain
-output value
Desired output format (pretty, json)
Desired output format (pretty, json); default: pretty.
-path string
Path to the bundle data
-socketPath string
Path to the SPIRE Server API socket (default "/tmp/spire-server/private/api.sock")
`
countUsage = `Usage of bundle count:
-output value
Desired output format (pretty, json)
Desired output format (pretty, json); default: pretty.
-socketPath string
Path to the SPIRE Server API socket (default "/tmp/spire-server/private/api.sock")
`
Expand All @@ -28,7 +28,7 @@ var (
-mode string
Deletion mode: one of restrict, delete, or dissociate (default "restrict")
-output value
Desired output format (pretty, json)
Desired output format (pretty, json); default: pretty.
-socketPath string
Path to the SPIRE Server API socket (default "/tmp/spire-server/private/api.sock")
`
Expand All @@ -38,15 +38,15 @@ var (
-id string
SPIFFE ID of the trust domain
-output value
Desired output format (pretty, json)
Desired output format (pretty, json); default: pretty.
-socketPath string
Path to the SPIRE Server API socket (default "/tmp/spire-server/private/api.sock")
`
showUsage = `Usage of bundle show:
-format string
The format to show the bundle (only pretty output format supports this flag). Either "pem" or "spiffe". (default "pem")
-output value
Desired output format (pretty, json)
Desired output format (pretty, json); default: pretty.
-socketPath string
Path to the SPIRE Server API socket (default "/tmp/spire-server/private/api.sock")
`
Expand Down
10 changes: 5 additions & 5 deletions cmd/spire-server/cli/bundle/bundle_windows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var (
-namedPipeName string
Pipe name of the SPIRE Server API named pipe (default "\\spire-server\\private\\api")
-output value
Desired output format (pretty, json)
Desired output format (pretty, json); default: pretty.
-path string
Path to the bundle data
`
Expand All @@ -22,13 +22,13 @@ var (
-namedPipeName string
Pipe name of the SPIRE Server API named pipe (default "\\spire-server\\private\\api")
-output value
Desired output format (pretty, json)
Desired output format (pretty, json); default: pretty.
`
countUsage = `Usage of bundle count:
-namedPipeName string
Pipe name of the SPIRE Server API named pipe (default "\\spire-server\\private\\api")
-output value
Desired output format (pretty, json)
Desired output format (pretty, json); default: pretty.
`
listUsage = `Usage of bundle list:
-format string
Expand All @@ -38,7 +38,7 @@ var (
-namedPipeName string
Pipe name of the SPIRE Server API named pipe (default "\\spire-server\\private\\api")
-output value
Desired output format (pretty, json)
Desired output format (pretty, json); default: pretty.
`
deleteUsage = `Usage of bundle delete:
-id string
Expand All @@ -48,6 +48,6 @@ var (
-namedPipeName string
Pipe name of the SPIRE Server API named pipe (default "\\spire-server\\private\\api")
-output value
Desired output format (pretty, json)
Desired output format (pretty, json); default: pretty.
`
)
10 changes: 5 additions & 5 deletions cmd/spire-server/cli/entry/util_posix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const (
-node
If set, this entry will be applied to matching nodes rather than workloads
-output value
Desired output format (pretty, json)
Desired output format (pretty, json); default: pretty.
-parentID string
The SPIFFE ID of this record's parent
-selector value
Expand Down Expand Up @@ -50,7 +50,7 @@ const (
-matchSelectorsOn string
The match mode used when filtering by selectors. Options: exact, any, superset and subset (default "superset")
-output value
Desired output format (pretty, json)
Desired output format (pretty, json); default: pretty.
-parentID string
The Parent ID of the records to show
-selector value
Expand Down Expand Up @@ -78,7 +78,7 @@ const (
-jwtSVIDTTL int
The lifetime, in seconds, for JWT-SVIDs issued based on this registration entry. Overrides ttl flag
-output value
Desired output format (pretty, json)
Desired output format (pretty, json); default: pretty.
-parentID string
The SPIFFE ID of this record's parent
-selector value
Expand All @@ -98,13 +98,13 @@ const (
-entryID string
The Registration Entry ID of the record to delete
-output value
Desired output format (pretty, json)
Desired output format (pretty, json); default: pretty.
-socketPath string
Path to the SPIRE Server API socket (default "/tmp/spire-server/private/api.sock")
`
countUsage = `Usage of entry count:
-output value
Desired output format (pretty, json)
Desired output format (pretty, json); default: pretty.
-socketPath string
Path to the SPIRE Server API socket (default "/tmp/spire-server/private/api.sock")
`
Expand Down
10 changes: 5 additions & 5 deletions cmd/spire-server/cli/entry/util_windows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const (
-node
If set, this entry will be applied to matching nodes rather than workloads
-output value
Desired output format (pretty, json)
Desired output format (pretty, json); default: pretty.
-parentID string
The SPIFFE ID of this record's parent
-selector value
Expand Down Expand Up @@ -52,7 +52,7 @@ const (
-namedPipeName string
Pipe name of the SPIRE Server API named pipe (default "\\spire-server\\private\\api")
-output value
Desired output format (pretty, json)
Desired output format (pretty, json); default: pretty.
-parentID string
The Parent ID of the records to show
-selector value
Expand Down Expand Up @@ -80,7 +80,7 @@ const (
-namedPipeName string
Pipe name of the SPIRE Server API named pipe (default "\\spire-server\\private\\api")
-output value
Desired output format (pretty, json)
Desired output format (pretty, json); default: pretty.
-parentID string
The SPIFFE ID of this record's parent
-selector value
Expand All @@ -100,12 +100,12 @@ const (
-namedPipeName string
Pipe name of the SPIRE Server API named pipe (default "\\spire-server\\private\\api")
-output value
Desired output format (pretty, json)
Desired output format (pretty, json); default: pretty.
`
countUsage = `Usage of entry count:
-namedPipeName string
Pipe name of the SPIRE Server API named pipe (default "\\spire-server\\private\\api")
-output value
Desired output format (pretty, json)
Desired output format (pretty, json); default: pretty.
`
)
12 changes: 6 additions & 6 deletions cmd/spire-server/cli/federation/util_posix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const (
-endpointSpiffeID string
SPIFFE ID of the SPIFFE bundle endpoint server. Only used for 'spiffe' profile.
-output value
Desired output format (pretty, json)
Desired output format (pretty, json); default: pretty.
-socketPath string
Path to the SPIRE Server API socket (default "/tmp/spire-server/private/api.sock")
-trustDomain string
Expand All @@ -28,27 +28,27 @@ const (
-id string
SPIFFE ID of the trust domain
-output value
Desired output format (pretty, json)
Desired output format (pretty, json); default: pretty.
-socketPath string
Path to the SPIRE Server API socket (default "/tmp/spire-server/private/api.sock")
`
listUsage = `Usage of federation list:
-output value
Desired output format (pretty, json)
Desired output format (pretty, json); default: pretty.
-socketPath string
Path to the SPIRE Server API socket (default "/tmp/spire-server/private/api.sock")
`
refreshUsage = `Usage of federation refresh:
-id string
SPIFFE ID of the trust domain
-output value
Desired output format (pretty, json)
Desired output format (pretty, json); default: pretty.
-socketPath string
Path to the SPIRE Server API socket (default "/tmp/spire-server/private/api.sock")
`
showUsage = `Usage of federation show:
-output value
Desired output format (pretty, json)
Desired output format (pretty, json); default: pretty.
-socketPath string
Path to the SPIRE Server API socket (default "/tmp/spire-server/private/api.sock")
-trustDomain string
Expand All @@ -64,7 +64,7 @@ const (
-endpointSpiffeID string
SPIFFE ID of the SPIFFE bundle endpoint server. Only used for 'spiffe' profile.
-output value
Desired output format (pretty, json)
Desired output format (pretty, json); default: pretty.
-socketPath string
Path to the SPIRE Server API socket (default "/tmp/spire-server/private/api.sock")
-trustDomain string
Expand Down
12 changes: 6 additions & 6 deletions cmd/spire-server/cli/federation/util_windows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const (
-namedPipeName string
Pipe name of the SPIRE Server API named pipe (default "\\spire-server\\private\\api")
-output value
Desired output format (pretty, json)
Desired output format (pretty, json); default: pretty.
-trustDomain string
Name of the trust domain to federate with (e.g., example.org)
-trustDomainBundleFormat string
Expand All @@ -30,27 +30,27 @@ const (
-namedPipeName string
Pipe name of the SPIRE Server API named pipe (default "\\spire-server\\private\\api")
-output value
Desired output format (pretty, json)
Desired output format (pretty, json); default: pretty.
`
listUsage = `Usage of federation list:
-namedPipeName string
Pipe name of the SPIRE Server API named pipe (default "\\spire-server\\private\\api")
-output value
Desired output format (pretty, json)
Desired output format (pretty, json); default: pretty.
`
refreshUsage = `Usage of federation refresh:
-id string
SPIFFE ID of the trust domain
-namedPipeName string
Pipe name of the SPIRE Server API named pipe (default "\\spire-server\\private\\api")
-output value
Desired output format (pretty, json)
Desired output format (pretty, json); default: pretty.
`
showUsage = `Usage of federation show:
-namedPipeName string
Pipe name of the SPIRE Server API named pipe (default "\\spire-server\\private\\api")
-output value
Desired output format (pretty, json)
Desired output format (pretty, json); default: pretty.
-trustDomain string
The trust domain name of the federation relationship to show
`
Expand All @@ -66,7 +66,7 @@ const (
-namedPipeName string
Pipe name of the SPIRE Server API named pipe (default "\\spire-server\\private\\api")
-output value
Desired output format (pretty, json)
Desired output format (pretty, json); default: pretty.
-trustDomain string
Name of the trust domain to federate with (e.g., example.org)
-trustDomainBundleFormat string
Expand Down
9 changes: 8 additions & 1 deletion pkg/common/cliprinter/flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ import (

const defaultFlagName = "output"

var flagDescription = fmt.Sprintf(
"Desired output format (%s, %s); default: %s.",
formatTypeToStr(pretty),
formatTypeToStr(json),
formatTypeToStr(defaultFormatType),
)

// AppendFlag adds the -format flag to the provided flagset, and populates
// the referenced Printer interface with a properly configured printer.
func AppendFlag(p *Printer, fs *flag.FlagSet, env *commoncli.Env) *FormatterFlag {
Expand All @@ -34,7 +41,7 @@ func AppendFlagWithCustomPretty(p *Printer, fs *flag.FlagSet, env *commoncli.Env
customPretty: cp,
}

fs.Var(f, defaultFlagName, "Desired output format (pretty, json)")
fs.Var(f, defaultFlagName, flagDescription)
return f
}

Expand Down