From d02ecbddf17868bff9701836e86b918f55ee11dc Mon Sep 17 00:00:00 2001 From: James Rasell Date: Fri, 29 Oct 2021 09:00:50 +0200 Subject: [PATCH 1/3] cli: add json and template flag opts to acl boostrap command. --- command/acl_bootstrap.go | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/command/acl_bootstrap.go b/command/acl_bootstrap.go index aa3069865c4f..85dbc69bffd5 100644 --- a/command/acl_bootstrap.go +++ b/command/acl_bootstrap.go @@ -22,13 +22,24 @@ General Options: ` + generalOptionsUsage(usageOptsDefault|usageOptsNoNamespace) + ` +Bootstrap Options: + + -json + Output the bootstrap response in JSON format. + + -t + Format and display the bootstrap response using a Go template. + ` return strings.TrimSpace(helpText) } func (c *ACLBootstrapCommand) AutocompleteFlags() complete.Flags { return mergeAutocompleteFlags(c.Meta.AutocompleteFlags(FlagSetClient), - complete.Flags{}) + complete.Flags{ + "-json": complete.PredictNothing, + "-t": complete.PredictAnything, + }) } func (c *ACLBootstrapCommand) AutocompleteArgs() complete.Predictor { @@ -42,8 +53,16 @@ func (c *ACLBootstrapCommand) Synopsis() string { func (c *ACLBootstrapCommand) Name() string { return "acl bootstrap" } func (c *ACLBootstrapCommand) Run(args []string) int { + + var ( + json bool + tmpl string + ) + flags := c.Meta.FlagSet(c.Name(), FlagSetClient) flags.Usage = func() { c.Ui.Output(c.Help()) } + flags.BoolVar(&json, "json", false, "") + flags.StringVar(&tmpl, "t", "", "") if err := flags.Parse(args); err != nil { return 1 } @@ -70,6 +89,17 @@ func (c *ACLBootstrapCommand) Run(args []string) int { return 1 } + if json || len(tmpl) > 0 { + out, err := Format(json, tmpl, token) + if err != nil { + c.Ui.Error(err.Error()) + return 1 + } + + c.Ui.Output(out) + return 0 + } + // Format the output c.Ui.Output(formatKVACLToken(token)) return 0 From 35a6d76d4dfaf17efed03d877b950263306ea140 Mon Sep 17 00:00:00 2001 From: James Rasell Date: Fri, 29 Oct 2021 09:01:58 +0200 Subject: [PATCH 2/3] docs: update acl bootstrap command to show json and template opts. --- website/content/docs/commands/acl/bootstrap.mdx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/website/content/docs/commands/acl/bootstrap.mdx b/website/content/docs/commands/acl/bootstrap.mdx index 5d7121cf3092..cdc04845a50f 100644 --- a/website/content/docs/commands/acl/bootstrap.mdx +++ b/website/content/docs/commands/acl/bootstrap.mdx @@ -21,6 +21,11 @@ The `acl bootstrap` command requires no arguments. @include 'general_options_no_namespace.mdx' +## Bootstrap Options + +- `-json` : Output the bootstrap response in JSON format. +- `-t` : Format and display the deployments using a Go template. + ## Examples Bootstrap the initial token: From 9542b2e12696431d83cc65825a965745942e6d84 Mon Sep 17 00:00:00 2001 From: James Rasell Date: Fri, 29 Oct 2021 09:08:10 +0200 Subject: [PATCH 3/3] changelog: add entry for #11411. --- .changelog/11411.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .changelog/11411.txt diff --git a/.changelog/11411.txt b/.changelog/11411.txt new file mode 100644 index 000000000000..70f25c19ae31 --- /dev/null +++ b/.changelog/11411.txt @@ -0,0 +1,3 @@ +```release-note:improvement +cli: added json and template flag opts to the acl bootstrap command +```