diff --git a/command/setup_consul.go b/command/setup_consul.go index 087f26337..75b256546 100644 --- a/command/setup_consul.go +++ b/command/setup_consul.go @@ -45,7 +45,7 @@ type SetupConsulCommand struct { jwksURL string consulEnt bool - cleanup bool + destroy bool autoYes bool } @@ -71,7 +71,7 @@ Setup Consul options: URL of Nomad's JWKS endpoint contacted by Consul to verify JWT signatures. Defaults to http://localhost:4646/.well-known/jwks.json. - -cleanup + -destroy Removes all configuration components this command created from the Consul cluster. @@ -87,7 +87,7 @@ func (s *SetupConsulCommand) AutocompleteFlags() complete.Flags { return mergeAutocompleteFlags(s.Meta.AutocompleteFlags(FlagSetClient), complete.Flags{ "-jwks-url": complete.PredictAnything, - "-cleanup": complete.PredictSet("true", "false"), + "-destroy": complete.PredictSet("true", "false"), "-y": complete.PredictSet("true", "false"), }) } @@ -107,7 +107,7 @@ func (s *SetupConsulCommand) Run(args []string) int { flags := s.Meta.FlagSet(s.Name(), FlagSetClient) flags.Usage = func() { s.Ui.Output(s.Help()) } - flags.BoolVar(&s.cleanup, "cleanup", false, "") + flags.BoolVar(&s.destroy, "destroy", false, "") flags.BoolVar(&s.autoYes, "y", false, "") flags.StringVar(&s.jwksURL, "jwks-url", "http://localhost:4646/.well-known/jwks.json", "") if err := flags.Parse(args); err != nil { @@ -126,7 +126,7 @@ func (s *SetupConsulCommand) Run(args []string) int { return 1 } - if !s.cleanup { + if !s.destroy { s.Ui.Output(` This command will walk you through configuring all the components required for Nomad workloads to authenticate themselves against Consul ACL using their @@ -181,7 +181,7 @@ Please set the CONSUL_NAMESPACE environment variable to the Consul namespace to } } - if s.cleanup { + if s.destroy { return s.removeConfiguredComponents() } diff --git a/command/setup_vault.go b/command/setup_vault.go index 815b7cf51..e052f0c7c 100644 --- a/command/setup_vault.go +++ b/command/setup_vault.go @@ -46,7 +46,7 @@ type SetupVaultCommand struct { jwksURL string - cleanup bool + destroy bool autoYes bool } @@ -71,7 +71,7 @@ Setup Vault options: URL of Nomad's JWKS endpoint contacted by Vault to verify JWT signatures. Defaults to http://localhost:4646/.well-known/jwks.json. - -cleanup + -destroy Removes all configuration components this command created from the Vault cluster. @@ -87,7 +87,7 @@ func (s *SetupVaultCommand) AutocompleteFlags() complete.Flags { return mergeAutocompleteFlags(s.Meta.AutocompleteFlags(FlagSetClient), complete.Flags{ "-jwks-url": complete.PredictAnything, - "-cleanup": complete.PredictSet("true", "false"), + "-destroy": complete.PredictSet("true", "false"), "-y": complete.PredictSet("true", "false"), }) } @@ -107,7 +107,7 @@ func (s *SetupVaultCommand) Run(args []string) int { flags := s.Meta.FlagSet(s.Name(), FlagSetClient) flags.Usage = func() { s.Ui.Output(s.Help()) } - flags.BoolVar(&s.cleanup, "cleanup", false, "") + flags.BoolVar(&s.destroy, "destroy", false, "") flags.BoolVar(&s.autoYes, "y", false, "") flags.StringVar(&s.jwksURL, "jwks-url", "http://localhost:4646/.well-known/jwks.json", "") if err := flags.Parse(args); err != nil { @@ -126,7 +126,7 @@ func (s *SetupVaultCommand) Run(args []string) int { return 1 } - if !s.cleanup { + if !s.destroy { s.Ui.Output(` This command will walk you through configuring all the components required for Nomad workloads to authenticate themselves against Vault ACL using their @@ -181,7 +181,7 @@ Please set the VAULT_NAMESPACE environment variable to the Vault namespace to us } } - if s.cleanup { + if s.destroy { return s.removeConfiguredComponents() } @@ -448,15 +448,15 @@ func (s *SetupVaultCommand) createAuthMethod(authConfig map[string]any) error { return nil } -// namespaceExists takes checks if ns exists. if cleanup is true, it will check +// namespaceExists takes checks if ns exists. if destroy is true, it will check // for custom metadata presence to prevent deleting a namespace we didn't // create. -func (s *SetupVaultCommand) namespaceExists(ns string, cleanup bool) bool { +func (s *SetupVaultCommand) namespaceExists(ns string, destroy bool) bool { s.vClient.SetNamespace("") defer s.vClient.SetNamespace(s.ns) existingNamespace, _ := s.vLogical.Read(fmt.Sprintf("/sys/namespaces/%s", ns)) - if cleanup && existingNamespace != nil { + if destroy && existingNamespace != nil { if m, ok := existingNamespace.Data["custom_metadata"]; ok { if mm, ok := m.(map[string]any)["created-by"]; ok { return mm == "nomad-setup" diff --git a/website/content/docs/commands/setup/consul.mdx b/website/content/docs/commands/setup/consul.mdx index 207f29e97..49109f111 100644 --- a/website/content/docs/commands/setup/consul.mdx +++ b/website/content/docs/commands/setup/consul.mdx @@ -32,7 +32,7 @@ nomad setup consul [options] - `-jwks-url`: URL of Nomad's JWKS endpoint contacted by Consul to verify JWT signatures. Defaults to `http://localhost:4646/.well-known/jwks.json`. -- `-cleanup`: Removes all configuration components this command created from the +- `-destroy`: Removes all configuration components this command created from the Consul cluster. - `-y`: Automatically answers `yes` to all the questions, making the setup @@ -42,7 +42,7 @@ nomad setup consul [options] Below is an example of an interactive session with default options, interrupted by answering `no` to one of the questions, demonstrating the capabilities of the -`-cleanup` flag. +`-destroy` flag. ```shell-session $ nomad setup consul diff --git a/website/content/docs/commands/setup/vault.mdx b/website/content/docs/commands/setup/vault.mdx index 214381642..ac5da6fa4 100644 --- a/website/content/docs/commands/setup/vault.mdx +++ b/website/content/docs/commands/setup/vault.mdx @@ -32,7 +32,7 @@ nomad setup vault [options] - `-jwks-url`: URL of Nomad's JWKS endpoint contacted by Consul to verify JWT signatures. Defaults to `http://localhost:4646/.well-known/jwks.json`. -- `-cleanup`: Removes all configuration components this command created from the +- `-destroy`: Removes all configuration components this command created from the Consul cluster. - `-y`: Automatically answers `yes` to all the questions, making the setup @@ -42,7 +42,7 @@ nomad setup vault [options] Below is an example of an interactive session with default options, interrupted by answering `no` to one of the questions, demonstrating the capabilities of the -`-cleanup` flag. +`-destroy` flag. ```shell-session $ nomad setup vault