From 3746d3606af7a59bd87690b1f894109c2ac00768 Mon Sep 17 00:00:00 2001 From: r-vasquez Date: Wed, 27 Nov 2024 17:46:06 -0800 Subject: [PATCH 1/2] rpk: clearer doc text on mechanism flag Mechanism flag is required in `user update` and it was not clear. It also adds an autocompletion function for those who use rpk's autocompletion features. --- src/go/rpk/pkg/cli/security/user/update.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/go/rpk/pkg/cli/security/user/update.go b/src/go/rpk/pkg/cli/security/user/update.go index b5735fbf0234..3454d0aa0694 100644 --- a/src/go/rpk/pkg/cli/security/user/update.go +++ b/src/go/rpk/pkg/cli/security/user/update.go @@ -10,6 +10,7 @@ package user import ( + "fmt" "strings" "github.com/redpanda-data/redpanda/src/go/rpk/pkg/adminapi" @@ -22,7 +23,7 @@ import ( func newUpdateCommand(fs afero.Fs, p *config.Params) *cobra.Command { var newPass, mechanism string cmd := &cobra.Command{ - Use: "update [USER] --new-password [PW]", + Use: "update [USER] --new-password [PW] --mechanism [MECHANISM]", Short: "Update SASL user credentials", Args: cobra.ExactArgs(1), Run: func(cmd *cobra.Command, args []string) { @@ -46,9 +47,11 @@ func newUpdateCommand(fs afero.Fs, p *config.Params) *cobra.Command { } cmd.Flags().StringVar(&newPass, "new-password", "", "New user's password.") - cmd.Flags().StringVar(&mechanism, "mechanism", adminapi.ScramSha256, "SASL mechanism to use for the user you are updating (scram-sha-256, scram-sha-512, case insensitive)") + cmd.Flags().StringVar(&mechanism, "mechanism", "", fmt.Sprintf("SASL mechanism to use for the user you are updating (%v, %v, case insensitive)", adminapi.ScramSha256, adminapi.ScramSha512)) cmd.MarkFlagRequired("new-password") cmd.MarkFlagRequired("mechanism") - + cmd.RegisterFlagCompletionFunc("mechanism", func(_ *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective) { + return []string{adminapi.ScramSha256, adminapi.ScramSha512}, cobra.ShellCompDirectiveDefault + }) return cmd } From cef1a3a2fc85bf37104571243e48d43612005f04 Mon Sep 17 00:00:00 2001 From: r-vasquez Date: Thu, 28 Nov 2024 12:56:50 -0800 Subject: [PATCH 2/2] rpk: parse --help for byoc plugin It fixes a bug where --help didn't work along with --redpanda-is. Fixes DEVEX-56 --- src/go/rpk/pkg/cli/cloud/byoc/byoc.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/go/rpk/pkg/cli/cloud/byoc/byoc.go b/src/go/rpk/pkg/cli/cloud/byoc/byoc.go index 94449a8b77cb..0f0351200230 100644 --- a/src/go/rpk/pkg/cli/cloud/byoc/byoc.go +++ b/src/go/rpk/pkg/cli/cloud/byoc/byoc.go @@ -51,7 +51,10 @@ func init() { cmd.Run = func(cmd *cobra.Command, args []string) { cfg, redpandaID, pluginArgs, err := parseBYOCFlags(fs, p, cmd, args) out.MaybeDieErr(err) - + if cmd.Flags().Changed("help") { + cmd.Help() + return + } // --redpanda-id is only required in apply or destroy commands. // For validate commands we don't need the redpanda-id, instead, // we download the latest version always. @@ -168,7 +171,7 @@ and then come back to this command to complete the process. } } - if !isKnown || (redpandaID == "" && !isValidate) { + if !isKnown || (redpandaID == "" && !isValidate) || cmd.Flags().Changed("help") { cmd.Help() return }