Skip to content

Commit

Permalink
Merge pull request #24369 from r-vasquez/rpk-bugfix
Browse files Browse the repository at this point in the history
rpk: fix --help in `byoc` and `user update`
  • Loading branch information
r-vasquez authored Dec 2, 2024
2 parents 39874d1 + cef1a3a commit e5fda9c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
7 changes: 5 additions & 2 deletions src/go/rpk/pkg/cli/cloud/byoc/byoc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
}
Expand Down
9 changes: 6 additions & 3 deletions src/go/rpk/pkg/cli/security/user/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
package user

import (
"fmt"
"strings"

"github.com/redpanda-data/redpanda/src/go/rpk/pkg/adminapi"
Expand All @@ -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) {
Expand All @@ -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
}

0 comments on commit e5fda9c

Please sign in to comment.