From 9951c52bf77e2852683c95005a47153c6dc52cb3 Mon Sep 17 00:00:00 2001 From: Steven Gagniere <108363707+sgagniere@users.noreply.github.com> Date: Fri, 4 Oct 2024 11:14:43 -0700 Subject: [PATCH] Update flags for mTLS (#2899) --- cmd/docs/main.go | 11 ++--------- internal/iam/command_certificate_pool_create.go | 2 ++ internal/iam/command_certificate_pool_delete.go | 1 + internal/iam/command_certificate_pool_describe.go | 3 +++ internal/iam/command_certificate_pool_list.go | 4 ++++ internal/iam/command_certificate_pool_update.go | 2 ++ pkg/cmd/flags.go | 2 +- .../output/iam/certificate-pool/create-help.golden | 4 +++- .../output/iam/certificate-pool/delete-help.golden | 1 + .../output/iam/certificate-pool/describe-help.golden | 2 ++ .../output/iam/certificate-pool/list-help.golden | 2 ++ .../output/iam/certificate-pool/update-help.golden | 4 +++- .../output/iam/group-mapping/create-help.golden | 2 +- .../output/iam/group-mapping/update-help.golden | 2 +- test/fixtures/output/iam/pool/create-help.golden | 2 +- test/fixtures/output/iam/pool/no-op-update.golden | 2 +- test/fixtures/output/iam/pool/update-help.golden | 2 +- 17 files changed, 31 insertions(+), 17 deletions(-) diff --git a/cmd/docs/main.go b/cmd/docs/main.go index cf96cc3a59..e668282931 100644 --- a/cmd/docs/main.go +++ b/cmd/docs/main.go @@ -62,19 +62,12 @@ func main() { panic(err) } - removeUnreleasedDocs() - if err := os.Setenv("HOME", home); err != nil { panic(err) } } -func removeUnreleasedDocs() { - removeUnreleasedCommands("iam certificate-authority") - removeUnreleasedCommands("iam certificate-pool") -} - -func removeUnreleasedCommands(command string) { +func removeUnreleasedCommands(command string) { //nolint:unused subcommands := strings.Split(command, " ") line := fmt.Sprintf(`\s{3}%s/index\n`, subcommands[len(subcommands)-1]) @@ -101,7 +94,7 @@ func removeUnreleasedCommands(command string) { } } -func removeLineFromFile(line, file string) error { +func removeLineFromFile(line, file string) error { //nolint:unused out, err := os.ReadFile(file) if err != nil { return err diff --git a/internal/iam/command_certificate_pool_create.go b/internal/iam/command_certificate_pool_create.go index bd1d3ec080..1167acb967 100644 --- a/internal/iam/command_certificate_pool_create.go +++ b/internal/iam/command_certificate_pool_create.go @@ -28,6 +28,8 @@ func (c *certificatePoolCommand) newCreateCommand() *cobra.Command { cmd.Flags().String("description", "", "Description of the certificate pool.") pcmd.AddFilterFlag(cmd) pcmd.AddExternalIdentifierFlag(cmd) + pcmd.AddContextFlag(cmd, c.CLICommand) + pcmd.AddOutputFlag(cmd) cobra.CheckErr(cmd.MarkFlagRequired("provider")) diff --git a/internal/iam/command_certificate_pool_delete.go b/internal/iam/command_certificate_pool_delete.go index 41d1f19538..0f99a0abd5 100644 --- a/internal/iam/command_certificate_pool_delete.go +++ b/internal/iam/command_certificate_pool_delete.go @@ -26,6 +26,7 @@ func (c *certificatePoolCommand) newDeleteCommand() *cobra.Command { c.AddProviderFlag(cmd) pcmd.AddForceFlag(cmd) + pcmd.AddContextFlag(cmd, c.CLICommand) cobra.CheckErr(cmd.MarkFlagRequired("provider")) diff --git a/internal/iam/command_certificate_pool_describe.go b/internal/iam/command_certificate_pool_describe.go index e3eb149f61..ef107e1c54 100644 --- a/internal/iam/command_certificate_pool_describe.go +++ b/internal/iam/command_certificate_pool_describe.go @@ -23,6 +23,9 @@ func (c *certificatePoolCommand) newDescribeCommand() *cobra.Command { } c.AddProviderFlag(cmd) + pcmd.AddContextFlag(cmd, c.CLICommand) + pcmd.AddOutputFlag(cmd) + cobra.CheckErr(cmd.MarkFlagRequired("provider")) return cmd } diff --git a/internal/iam/command_certificate_pool_list.go b/internal/iam/command_certificate_pool_list.go index e4a59db130..2a755a1ba7 100644 --- a/internal/iam/command_certificate_pool_list.go +++ b/internal/iam/command_certificate_pool_list.go @@ -3,6 +3,7 @@ package iam import ( "github.com/spf13/cobra" + pcmd "github.com/confluentinc/cli/v4/pkg/cmd" "github.com/confluentinc/cli/v4/pkg/output" ) @@ -15,6 +16,9 @@ func (c *certificatePoolCommand) newListCommand() *cobra.Command { } c.AddProviderFlag(cmd) + pcmd.AddContextFlag(cmd, c.CLICommand) + pcmd.AddOutputFlag(cmd) + cobra.CheckErr(cmd.MarkFlagRequired("provider")) return cmd } diff --git a/internal/iam/command_certificate_pool_update.go b/internal/iam/command_certificate_pool_update.go index 2a41b4a1c3..0b0095f29d 100644 --- a/internal/iam/command_certificate_pool_update.go +++ b/internal/iam/command_certificate_pool_update.go @@ -29,6 +29,8 @@ func (c *certificatePoolCommand) newUpdateCommand() *cobra.Command { cmd.Flags().String("name", "", "Name of the certificate pool.") pcmd.AddFilterFlag(cmd) pcmd.AddExternalIdentifierFlag(cmd) + pcmd.AddContextFlag(cmd, c.CLICommand) + pcmd.AddOutputFlag(cmd) cobra.CheckErr(cmd.MarkFlagRequired("provider")) diff --git a/pkg/cmd/flags.go b/pkg/cmd/flags.go index eb3f7ece10..b1a4453cd0 100644 --- a/pkg/cmd/flags.go +++ b/pkg/cmd/flags.go @@ -204,7 +204,7 @@ func AddKsqlClusterFlag(cmd *cobra.Command, c *AuthenticatedCLICommand) { } func AddFilterFlag(cmd *cobra.Command) { - cmd.Flags().String("filter", "true", "A supported Common Expression Language (CEL) filter expression for group mappings.") + cmd.Flags().String("filter", "true", "A supported Common Expression Language (CEL) filter expression.") } func AddExternalIdentifierFlag(cmd *cobra.Command) { diff --git a/test/fixtures/output/iam/certificate-pool/create-help.golden b/test/fixtures/output/iam/certificate-pool/create-help.golden index fa7cf160c0..07b2821a4c 100644 --- a/test/fixtures/output/iam/certificate-pool/create-help.golden +++ b/test/fixtures/output/iam/certificate-pool/create-help.golden @@ -11,8 +11,10 @@ Create a certificate pool named "pool-123". Flags: --provider string REQUIRED: ID of this pool's certificate authority. --description string Description of the certificate pool. - --filter string A supported Common Expression Language (CEL) filter expression for group mappings. (default "true") + --filter string A supported Common Expression Language (CEL) filter expression. (default "true") --external-identifier string External Identifier for this pool. + --context string CLI context name. + -o, --output string Specify the output format as "human", "json", or "yaml". (default "human") Global Flags: -h, --help Show help for this command. diff --git a/test/fixtures/output/iam/certificate-pool/delete-help.golden b/test/fixtures/output/iam/certificate-pool/delete-help.golden index 5b6dacffc2..99b72898f0 100644 --- a/test/fixtures/output/iam/certificate-pool/delete-help.golden +++ b/test/fixtures/output/iam/certificate-pool/delete-help.golden @@ -11,6 +11,7 @@ Delete certificate pool "pool-123": Flags: --provider string REQUIRED: ID of this pool's certificate authority. --force Skip the deletion confirmation prompt. + --context string CLI context name. Global Flags: -h, --help Show help for this command. diff --git a/test/fixtures/output/iam/certificate-pool/describe-help.golden b/test/fixtures/output/iam/certificate-pool/describe-help.golden index 30e8166193..c045430024 100644 --- a/test/fixtures/output/iam/certificate-pool/describe-help.golden +++ b/test/fixtures/output/iam/certificate-pool/describe-help.golden @@ -10,6 +10,8 @@ Describe a certificate pool with ID "pool-123". Flags: --provider string REQUIRED: ID of this pool's certificate authority. + --context string CLI context name. + -o, --output string Specify the output format as "human", "json", or "yaml". (default "human") Global Flags: -h, --help Show help for this command. diff --git a/test/fixtures/output/iam/certificate-pool/list-help.golden b/test/fixtures/output/iam/certificate-pool/list-help.golden index d87d5be599..250d95ca02 100644 --- a/test/fixtures/output/iam/certificate-pool/list-help.golden +++ b/test/fixtures/output/iam/certificate-pool/list-help.golden @@ -5,6 +5,8 @@ Usage: Flags: --provider string REQUIRED: ID of this pool's certificate authority. + --context string CLI context name. + -o, --output string Specify the output format as "human", "json", or "yaml". (default "human") Global Flags: -h, --help Show help for this command. diff --git a/test/fixtures/output/iam/certificate-pool/update-help.golden b/test/fixtures/output/iam/certificate-pool/update-help.golden index 3a14d61cb1..8e819df5bd 100644 --- a/test/fixtures/output/iam/certificate-pool/update-help.golden +++ b/test/fixtures/output/iam/certificate-pool/update-help.golden @@ -12,8 +12,10 @@ Flags: --provider string REQUIRED: ID of this pool's certificate authority. --description string Description of the certificate pool. --name string Name of the certificate pool. - --filter string A supported Common Expression Language (CEL) filter expression for group mappings. (default "true") + --filter string A supported Common Expression Language (CEL) filter expression. (default "true") --external-identifier string External Identifier for this pool. + --context string CLI context name. + -o, --output string Specify the output format as "human", "json", or "yaml". (default "human") Global Flags: -h, --help Show help for this command. diff --git a/test/fixtures/output/iam/group-mapping/create-help.golden b/test/fixtures/output/iam/group-mapping/create-help.golden index 362210eee9..03318b524a 100644 --- a/test/fixtures/output/iam/group-mapping/create-help.golden +++ b/test/fixtures/output/iam/group-mapping/create-help.golden @@ -10,7 +10,7 @@ Create a group mapping named "demo-group-mapping". Flags: --description string Description of the group mapping. - --filter string A supported Common Expression Language (CEL) filter expression for group mappings. (default "true") + --filter string A supported Common Expression Language (CEL) filter expression. (default "true") --context string CLI context name. -o, --output string Specify the output format as "human", "json", or "yaml". (default "human") diff --git a/test/fixtures/output/iam/group-mapping/update-help.golden b/test/fixtures/output/iam/group-mapping/update-help.golden index 3bcbb27d44..48b18dc061 100644 --- a/test/fixtures/output/iam/group-mapping/update-help.golden +++ b/test/fixtures/output/iam/group-mapping/update-help.golden @@ -11,7 +11,7 @@ Update the description of group mapping "group-123456". Flags: --name string Name of the group mapping. --description string Description of the group mapping. - --filter string A supported Common Expression Language (CEL) filter expression for group mappings. (default "true") + --filter string A supported Common Expression Language (CEL) filter expression. (default "true") --context string CLI context name. -o, --output string Specify the output format as "human", "json", or "yaml". (default "human") diff --git a/test/fixtures/output/iam/pool/create-help.golden b/test/fixtures/output/iam/pool/create-help.golden index fac15425ea..46b03ef5e9 100644 --- a/test/fixtures/output/iam/pool/create-help.golden +++ b/test/fixtures/output/iam/pool/create-help.golden @@ -12,7 +12,7 @@ Flags: --provider string REQUIRED: ID of this pool's identity provider. --identity-claim string REQUIRED: Claim specifying the external identity using this identity pool. --description string Description of the identity pool. - --filter string A supported Common Expression Language (CEL) filter expression for group mappings. (default "true") + --filter string A supported Common Expression Language (CEL) filter expression. (default "true") --context string CLI context name. -o, --output string Specify the output format as "human", "json", or "yaml". (default "human") diff --git a/test/fixtures/output/iam/pool/no-op-update.golden b/test/fixtures/output/iam/pool/no-op-update.golden index 6afb6ecfed..488806ac79 100644 --- a/test/fixtures/output/iam/pool/no-op-update.golden +++ b/test/fixtures/output/iam/pool/no-op-update.golden @@ -12,7 +12,7 @@ Flags: --identity-claim string Claim specifying the external identity using this identity pool. --name string Name of the identity pool. --description string Description of the identity pool. - --filter string A supported Common Expression Language (CEL) filter expression for group mappings. (default "true") + --filter string A supported Common Expression Language (CEL) filter expression. (default "true") --context string CLI context name. -o, --output string Specify the output format as "human", "json", or "yaml". (default "human") diff --git a/test/fixtures/output/iam/pool/update-help.golden b/test/fixtures/output/iam/pool/update-help.golden index c1ebba0177..013b73f678 100644 --- a/test/fixtures/output/iam/pool/update-help.golden +++ b/test/fixtures/output/iam/pool/update-help.golden @@ -13,7 +13,7 @@ Flags: --identity-claim string Claim specifying the external identity using this identity pool. --name string Name of the identity pool. --description string Description of the identity pool. - --filter string A supported Common Expression Language (CEL) filter expression for group mappings. (default "true") + --filter string A supported Common Expression Language (CEL) filter expression. (default "true") --context string CLI context name. -o, --output string Specify the output format as "human", "json", or "yaml". (default "human")