From 857a58022d90f676cdfd108ca65abcf59dc1f55e Mon Sep 17 00:00:00 2001 From: r-vasquez Date: Wed, 27 Nov 2024 17:46:06 -0800 Subject: [PATCH 1/3] 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. (cherry picked from commit 3746d3606af7a59bd87690b1f894109c2ac00768) --- 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 b5735fbf02345..3454d0aa0694c 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 2212e05a1366edc615b38924ade0c39590fcb95e Mon Sep 17 00:00:00 2001 From: r-vasquez Date: Thu, 28 Nov 2024 12:56:50 -0800 Subject: [PATCH 2/3] rpk: parse --help for byoc plugin It fixes a bug where --help didn't work along with --redpanda-is. Fixes DEVEX-56 (cherry picked from commit cef1a3a2fc85bf37104571243e48d43612005f04) --- 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 828553004ecba..8dbccd8d372a8 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. @@ -170,7 +173,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 } From 5d5932788840fa44a7d6e490a189fec9d9661492 Mon Sep 17 00:00:00 2001 From: r-vasquez Date: Tue, 3 Dec 2024 12:21:34 -0800 Subject: [PATCH 3/3] rpk: remove unused nolint comment --- src/go/rpk/pkg/adminapi/api_broker.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/go/rpk/pkg/adminapi/api_broker.go b/src/go/rpk/pkg/adminapi/api_broker.go index e5e54aa1234d2..f1340eb422357 100644 --- a/src/go/rpk/pkg/adminapi/api_broker.go +++ b/src/go/rpk/pkg/adminapi/api_broker.go @@ -87,7 +87,7 @@ type DecommissionStatusResponse struct { func (a *AdminAPI) Brokers(ctx context.Context) ([]Broker, error) { var bs []Broker defer func() { - sort.Slice(bs, func(i, j int) bool { return bs[i].NodeID < bs[j].NodeID }) //nolint:revive // return inside this deferred function is for the sort's less function + sort.Slice(bs, func(i, j int) bool { return bs[i].NodeID < bs[j].NodeID }) }() return bs, a.sendAny(ctx, http.MethodGet, brokersEndpoint, nil, &bs) }