Skip to content
Draft
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
4 changes: 2 additions & 2 deletions cmd/spire-agent/cli/healthcheck/healthcheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ func (c *healthCheckCommand) Run(args []string) int {
func (c *healthCheckCommand) parseFlags(args []string) error {
fs := flag.NewFlagSet("health", flag.ContinueOnError)
fs.SetOutput(c.env.Stderr)
fs.BoolVar(&c.shallow, "shallow", false, "Perform a less stringent health check")
fs.BoolVar(&c.verbose, "verbose", false, "Print verbose information")
common_cli.BoolVar(fs, &c.shallow, "shallow", "s", false, "Perform a less stringent health check")
common_cli.BoolVar(fs, &c.verbose, "verbose", "v", false, "Print verbose information")
c.addOSFlags(fs)
return fs.Parse(args)
}
Expand Down
2 changes: 2 additions & 0 deletions cmd/spire-agent/cli/healthcheck/healthcheck_posix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ import (

var (
usage = `Usage of health:
-s Perform a less stringent health check
-shallow
Perform a less stringent health check
-socketPath string
Path to the SPIRE Agent API socket (default "/tmp/spire-agent/public/api.sock")
-v Print verbose information
-verbose
Print verbose information
`
Expand Down
2 changes: 2 additions & 0 deletions cmd/spire-agent/cli/healthcheck/healthcheck_windows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ var (
usage = `Usage of health:
-namedPipeName string
Pipe name of the SPIRE Agent API named pipe (default "\\spire-agent\\public\\api")
-s Perform a less stringent health check
-shallow
Perform a less stringent health check
-v Print verbose information
-verbose
Print verbose information
`
Expand Down
6 changes: 3 additions & 3 deletions cmd/spire-agent/cli/run/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,13 +339,13 @@ func parseFlags(name string, args []string, output io.Writer) (*agentConfig, err
flags.SetOutput(output)
c := &agentConfig{}

flags.StringVar(&c.ConfigPath, "config", defaultConfigPath, "Path to a SPIRE config file")
flags.StringVar(&c.DataDir, "dataDir", "", "A directory the agent can use for its runtime data")
common_cli.StringVar(flags, &c.ConfigPath, "config", "c", defaultConfigPath, "Path to a SPIRE config file")
common_cli.StringVar(flags, &c.DataDir, "dataDir", "d", "", "A directory the agent can use for its runtime data")
flags.StringVar(&c.JoinToken, "joinToken", "", "An optional token which has been generated by the SPIRE server")
flags.StringVar(&c.JoinTokenFile, "joinTokenFile", "", "Path to a file containing an optional join token which has been generated by the SPIRE server")
flags.StringVar(&c.LogFile, "logFile", "", "File to write logs to")
flags.StringVar(&c.LogFormat, "logFormat", "", "'text' or 'json'")
flags.StringVar(&c.LogLevel, "logLevel", "", "'debug', 'info', 'warn', or 'error'")
common_cli.StringVar(flags, &c.LogLevel, "logLevel", "v", "", "'debug', 'info', 'warn', or 'error'")
flags.BoolVar(&c.LogSourceLocation, "logSourceLocation", false, "Include source file, line number and function name in log lines")
flags.StringVar(&c.ServerAddress, "serverAddress", "", "IP address or DNS name of the SPIRE server")
flags.IntVar(&c.ServerPort, "serverPort", 0, "Port number of the SPIRE server")
Expand Down
2 changes: 1 addition & 1 deletion cmd/spire-agent/cli/run/run_posix.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
)

func (c *agentConfig) addOSFlags(flags *flag.FlagSet) {
flags.StringVar(&c.SocketPath, "socketPath", "", "Path to bind the SPIRE Agent API socket to")
common_cli.StringVar(flags, &c.SocketPath, "socketPath", "s", "", "Path to bind the SPIRE Agent API socket to")
}

func (c *agentConfig) setPlatformDefaults() {
Expand Down
13 changes: 13 additions & 0 deletions cmd/spire-agent/cli/run/run_posix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,3 +374,16 @@ func newAgentConfigCasesOS(t *testing.T) []newAgentConfigCase {
},
}
}
func TestParseFlagsShorthand(t *testing.T) {
c, err := parseFlags("run", []string{
"-c", "conf/agent/agent.conf",
"-d", "/data/dir",
"-v", "DEBUG",
"-s", "/tmp/spire-agent/public/api.sock",
}, os.Stderr)
require.NoError(t, err)
assert.Equal(t, "conf/agent/agent.conf", c.ConfigPath)
assert.Equal(t, "/data/dir", c.DataDir)
assert.Equal(t, "DEBUG", c.LogLevel)
assert.Equal(t, "/tmp/spire-agent/public/api.sock", c.SocketPath)
}
3 changes: 2 additions & 1 deletion cmd/spire-agent/cli/run/run_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ import (

"github.com/spiffe/spire/cmd/spire-agent/cli/common"
"github.com/spiffe/spire/pkg/agent"
common_cli "github.com/spiffe/spire/pkg/common/cli"
"github.com/spiffe/spire/pkg/common/namedpipe"
)

func (c *agentConfig) addOSFlags(flags *flag.FlagSet) {
flags.StringVar(&c.Experimental.NamedPipeName, "namedPipeName", "", "Pipe name to bind the SPIRE Agent API named pipe")
common_cli.StringVar(flags, &c.Experimental.NamedPipeName, "namedPipeName", "p", "", "Pipe name to bind the SPIRE Agent API named pipe")
}

func (c *agentConfig) setPlatformDefaults() {
Expand Down
13 changes: 13 additions & 0 deletions cmd/spire-agent/cli/run/run_windows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,3 +282,16 @@ func newAgentConfigCasesOS(*testing.T) []newAgentConfigCase {
},
}
}
func TestParseFlagsShorthand(t *testing.T) {
c, err := parseFlags("run", []string{
"-c", "conf/agent/agent.conf",
"-d", "/data/dir",
"-v", "DEBUG",
"-p", "spire-agent-pipe",
}, os.Stderr)
require.NoError(t, err)
assert.Equal(t, "conf/agent/agent.conf", c.ConfigPath)
assert.Equal(t, "/data/dir", c.DataDir)
assert.Equal(t, "DEBUG", c.LogLevel)
assert.Equal(t, "spire-agent-pipe", c.Experimental.NamedPipeName)
}
14 changes: 14 additions & 0 deletions cmd/spire-server/cli/bundle/bundle_posix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,18 @@ package bundle

var (
setUsage = `Usage of bundle set:
-f string
The format of the bundle data. Either "pem" or "spiffe". (default "pem")
-format string
The format of the bundle data. Either "pem" or "spiffe". (default "pem")
-i string
SPIFFE ID of the trust domain
-id string
SPIFFE ID of the trust domain
-output value
Desired output format (pretty, json); default: pretty.
-p string
Path to the bundle data
-path string
Path to the bundle data
-socketPath string
Expand All @@ -22,6 +28,8 @@ var (
Path to the SPIRE Server API socket (default "/tmp/spire-server/private/api.sock")
`
deleteUsage = `Usage of bundle delete:
-i string
SPIFFE ID of the trust domain
-id string
SPIFFE ID of the trust domain
-mode string
Expand All @@ -32,8 +40,12 @@ var (
Path to the SPIRE Server API socket (default "/tmp/spire-server/private/api.sock")
`
listUsage = `Usage of bundle list:
-f string
The format to list federated bundles (only pretty output format supports this flag). Either "pem" or "spiffe". (default "pem")
-format string
The format to list federated bundles (only pretty output format supports this flag). Either "pem" or "spiffe". (default "pem")
-i string
SPIFFE ID of the trust domain
-id string
SPIFFE ID of the trust domain
-output value
Expand All @@ -42,6 +54,8 @@ var (
Path to the SPIRE Server API socket (default "/tmp/spire-server/private/api.sock")
`
showUsage = `Usage of bundle show:
-f string
The format to show the bundle (only pretty output format supports this flag). Either "pem" or "spiffe". (default "pem")
-format string
The format to show the bundle (only pretty output format supports this flag). Either "pem" or "spiffe". (default "pem")
-output value
Expand Down
14 changes: 14 additions & 0 deletions cmd/spire-server/cli/bundle/bundle_windows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,26 @@ package bundle

var (
setUsage = `Usage of bundle set:
-f string
The format of the bundle data. Either "pem" or "spiffe". (default "pem")
-format string
The format of the bundle data. Either "pem" or "spiffe". (default "pem")
-i string
SPIFFE ID of the trust domain
-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); default: pretty.
-p string
Path to the bundle data
-path string
Path to the bundle data
`
showUsage = `Usage of bundle show:
-f string
The format to show the bundle (only pretty output format supports this flag). Either "pem" or "spiffe". (default "pem")
-format string
The format to show the bundle (only pretty output format supports this flag). Either "pem" or "spiffe". (default "pem")
-namedPipeName string
Expand All @@ -30,8 +38,12 @@ var (
Desired output format (pretty, json); default: pretty.
`
listUsage = `Usage of bundle list:
-f string
The format to list federated bundles (only pretty output format supports this flag). Either "pem" or "spiffe". (default "pem")
-format string
The format to list federated bundles (only pretty output format supports this flag). Either "pem" or "spiffe". (default "pem")
-i string
SPIFFE ID of the trust domain
-id string
SPIFFE ID of the trust domain
-namedPipeName string
Expand All @@ -40,6 +52,8 @@ var (
Desired output format (pretty, json); default: pretty.
`
deleteUsage = `Usage of bundle delete:
-i string
SPIFFE ID of the trust domain
-id string
SPIFFE ID of the trust domain
-mode string
Expand Down
2 changes: 1 addition & 1 deletion cmd/spire-server/cli/bundle/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func (c *deleteCommand) Synopsis() string {
}

func (c *deleteCommand) AppendFlags(fs *flag.FlagSet) {
fs.StringVar(&c.id, "id", "", "SPIFFE ID of the trust domain")
commoncli.StringVar(fs, &c.id, "id", "i", "", "SPIFFE ID of the trust domain")
fs.StringVar(&c.mode, "mode", deleteBundleRestrict, fmt.Sprintf("Deletion mode: one of %s, %s, or %s", deleteBundleRestrict, deleteBundleDelete, deleteBundleDissociate))
cliprinter.AppendFlagWithCustomPretty(&c.printer, fs, c.env, prettyPrintDelete)
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/spire-server/cli/bundle/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ func (c *listCommand) Synopsis() string {
}

func (c *listCommand) AppendFlags(fs *flag.FlagSet) {
fs.StringVar(&c.id, "id", "", "SPIFFE ID of the trust domain")
fs.StringVar(&c.bundleFormat, "format", util.FormatPEM, fmt.Sprintf("The format to list federated bundles (only pretty output format supports this flag). Either %q or %q.", util.FormatPEM, util.FormatSPIFFE))
commoncli.StringVar(fs, &c.id, "id", "i", "", "SPIFFE ID of the trust domain")
commoncli.StringVar(fs, &c.bundleFormat, "format", "f", util.FormatPEM, fmt.Sprintf("The format to list federated bundles (only pretty output format supports this flag). Either %q or %q.", util.FormatPEM, util.FormatSPIFFE))
cliprinter.AppendFlagWithCustomPretty(&c.printer, fs, c.env, c.prettyPrintList)
}

Expand Down
6 changes: 3 additions & 3 deletions cmd/spire-server/cli/bundle/set.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ func (c *setCommand) Synopsis() string {
}

func (c *setCommand) AppendFlags(fs *flag.FlagSet) {
fs.StringVar(&c.id, "id", "", "SPIFFE ID of the trust domain")
fs.StringVar(&c.path, "path", "", "Path to the bundle data")
fs.StringVar(&c.bundleFormat, "format", util.FormatPEM, fmt.Sprintf("The format of the bundle data. Either %q or %q.", util.FormatPEM, util.FormatSPIFFE))
common_cli.StringVar(fs, &c.id, "id", "i", "", "SPIFFE ID of the trust domain")
common_cli.StringVar(fs, &c.path, "path", "p", "", "Path to the bundle data")
common_cli.StringVar(fs, &c.bundleFormat, "format", "f", util.FormatPEM, fmt.Sprintf("The format of the bundle data. Either %q or %q.", util.FormatPEM, util.FormatSPIFFE))
cliprinter.AppendFlagWithCustomPretty(&c.printer, fs, c.env, prettyPrintSet)
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/spire-server/cli/bundle/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func (c *showCommand) Synopsis() string {
}

func (c *showCommand) AppendFlags(fs *flag.FlagSet) {
fs.StringVar(&c.bundleFormat, "format", util.FormatPEM, fmt.Sprintf("The format to show the bundle (only pretty output format supports this flag). Either %q or %q.", util.FormatPEM, util.FormatSPIFFE))
common_cli.StringVar(fs, &c.bundleFormat, "format", "f", util.FormatPEM, fmt.Sprintf("The format to show the bundle (only pretty output format supports this flag). Either %q or %q.", util.FormatPEM, util.FormatSPIFFE))
cliprinter.AppendFlagWithCustomPretty(&c.printer, fs, c.env, c.prettyPrintBundle)
}

Expand Down
8 changes: 4 additions & 4 deletions cmd/spire-server/cli/entry/count.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,11 @@ func (c *countCommand) Run(ctx context.Context, _ *commoncli.Env, serverClient u
}

func (c *countCommand) AppendFlags(fs *flag.FlagSet) {
fs.StringVar(&c.parentID, "parentID", "", "The Parent ID of the records to count")
fs.StringVar(&c.spiffeID, "spiffeID", "", "The SPIFFE ID of the records to count")
commoncli.StringVar(fs, &c.parentID, "parentID", "p", "", "The Parent ID of the records to count")
commoncli.StringVar(fs, &c.spiffeID, "spiffeID", "s", "", "The SPIFFE ID of the records to count")
fs.BoolVar(&c.downstream, "downstream", false, "A boolean value that, when set, indicates that the entry describes a downstream SPIRE server")
fs.Var(&c.selectors, "selector", "A colon-delimited type:value selector. Can be used more than once")
fs.Var(&c.federatesWith, "federatesWith", "SPIFFE ID of a trust domain an entry is federate with. Can be used more than once")
commoncli.Var(fs, &c.selectors, "selector", "l", "A colon-delimited type:value selector. Can be used more than once")
commoncli.Var(fs, &c.federatesWith, "federatesWith", "f", "SPIFFE ID of a trust domain an entry is federate with. Can be used more than once")
fs.StringVar(&c.matchFederatesWithOn, "matchFederatesWithOn", "superset", "The match mode used when filtering by federates with. Options: exact, any, superset and subset")
fs.StringVar(&c.matchSelectorsOn, "matchSelectorsOn", "superset", "The match mode used when filtering by selectors. Options: exact, any, superset and subset")
fs.StringVar(&c.hint, "hint", "", "The Hint of the records to count (optional)")
Expand Down
20 changes: 10 additions & 10 deletions cmd/spire-server/cli/entry/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,16 @@ func (*createCommand) Synopsis() string {
}

func (c *createCommand) AppendFlags(f *flag.FlagSet) {
f.StringVar(&c.entryID, "entryID", "", "A custom ID for this registration entry (optional). If not set, a new entry ID will be generated")
f.StringVar(&c.parentID, "parentID", "", "The SPIFFE ID of this record's parent")
f.StringVar(&c.spiffeID, "spiffeID", "", "The SPIFFE ID that this record represents")
f.IntVar(&c.x509SVIDTTL, "x509SVIDTTL", 0, "The lifetime, in seconds, for x509-SVIDs issued based on this registration entry.")
f.IntVar(&c.jwtSVIDTTL, "jwtSVIDTTL", 0, "The lifetime, in seconds, for JWT-SVIDs issued based on this registration entry.")
f.StringVar(&c.path, "data", "", "Path to a file containing registration JSON (optional). If set to '-', read the JSON from stdin.")
f.Var(&c.selectors, "selector", "A colon-delimited type:value selector. Can be used more than once")
f.Var(&c.federatesWith, "federatesWith", "SPIFFE ID of a trust domain to federate with. Can be used more than once")
f.BoolVar(&c.node, "node", false, "If set, this entry will be applied to matching nodes rather than workloads")
f.BoolVar(&c.admin, "admin", false, "If set, the SPIFFE ID in this entry will be granted access to the SPIRE Server's management APIs")
commoncli.StringVar(f, &c.entryID, "entryID", "e", "", "A custom ID for this registration entry (optional). If not set, a new entry ID will be generated")
commoncli.StringVar(f, &c.parentID, "parentID", "p", "", "The SPIFFE ID of this record's parent")
commoncli.StringVar(f, &c.spiffeID, "spiffeID", "s", "", "The SPIFFE ID that this record represents")
commoncli.IntVar(f, &c.x509SVIDTTL, "x509SVIDTTL", "", 0, "The lifetime, in seconds, for x509-SVIDs issued based on this registration entry.")
commoncli.IntVar(f, &c.jwtSVIDTTL, "jwtSVIDTTL", "", 0, "The lifetime, in seconds, for JWT-SVIDs issued based on this registration entry.")
commoncli.StringVar(f, &c.path, "data", "d", "", "Path to a file containing registration JSON (optional). If set to '-', read the JSON from stdin.")
commoncli.Var(f, &c.selectors, "selector", "l", "A colon-delimited type:value selector. Can be used more than once")
commoncli.Var(f, &c.federatesWith, "federatesWith", "f", "SPIFFE ID of a trust domain to federate with. Can be used more than once")
commoncli.BoolVar(f, &c.node, "node", "n", false, "If set, this entry will be applied to matching nodes rather than workloads")
commoncli.BoolVar(f, &c.admin, "admin", "a", false, "If set, the SPIFFE ID in this entry will be granted access to the SPIRE Server's management APIs")
f.BoolVar(&c.storeSVID, "storeSVID", false, "A boolean value that, when set, indicates that the resulting issued SVID from this entry must be stored through an SVIDStore plugin")
f.BoolVar(&c.downstream, "downstream", false, "A boolean value that, when set, indicates that the entry describes a downstream SPIRE server")
f.Int64Var(&c.entryExpiry, "entryExpiry", 0, "An expiry, from epoch in seconds, for the resulting registration entry to be pruned")
Expand Down
4 changes: 2 additions & 2 deletions cmd/spire-server/cli/entry/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ func (*deleteCommand) Synopsis() string {
}

func (c *deleteCommand) AppendFlags(f *flag.FlagSet) {
f.StringVar(&c.entryID, "entryID", "", "The Registration Entry ID of the record to delete.")
f.StringVar(&c.file, "file", "", "Path to a file containing a JSON structure for batch deletion (optional). If set to '-', read from stdin.")
commoncli.StringVar(f, &c.entryID, "entryID", "e", "", "The Registration Entry ID of the record to delete.")
commoncli.StringVar(f, &c.file, "file", "f", "", "Path to a file containing a JSON structure for batch deletion (optional). If set to '-', read from stdin.")
cliprinter.AppendFlagWithCustomPretty(&c.printer, f, c.env, c.prettyPrintDelete)
}

Expand Down
10 changes: 5 additions & 5 deletions cmd/spire-server/cli/entry/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@ func (*showCommand) Synopsis() string {
}

func (c *showCommand) AppendFlags(f *flag.FlagSet) {
f.StringVar(&c.entryID, "entryID", "", "The Entry ID of the records to show")
f.StringVar(&c.parentID, "parentID", "", "The Parent ID of the records to show")
f.StringVar(&c.spiffeID, "spiffeID", "", "The SPIFFE ID of the records to show")
commoncli.StringVar(f, &c.entryID, "entryID", "e", "", "The Entry ID of the records to show")
commoncli.StringVar(f, &c.parentID, "parentID", "p", "", "The Parent ID of the records to show")
commoncli.StringVar(f, &c.spiffeID, "spiffeID", "s", "", "The SPIFFE ID of the records to show")
f.BoolVar(&c.downstream, "downstream", false, "A boolean value that, when set, indicates that the entry describes a downstream SPIRE server")
f.Var(&c.selectors, "selector", "A colon-delimited type:value selector. Can be used more than once")
f.Var(&c.federatesWith, "federatesWith", "SPIFFE ID of a trust domain an entry is federate with. Can be used more than once")
commoncli.Var(f, &c.selectors, "selector", "l", "A colon-delimited type:value selector. Can be used more than once")
commoncli.Var(f, &c.federatesWith, "federatesWith", "f", "SPIFFE ID of a trust domain an entry is federate with. Can be used more than once")
f.StringVar(&c.matchFederatesWithOn, "matchFederatesWithOn", "superset", "The match mode used when filtering by federates with. Options: exact, any, superset and subset")
f.StringVar(&c.matchSelectorsOn, "matchSelectorsOn", "superset", "The match mode used when filtering by selectors. Options: exact, any, superset and subset")
f.StringVar(&c.hint, "hint", "", "The Hint of the records to show (optional)")
Expand Down
Loading