Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v24.1.x] rpk: fix --help in byoc and user update #24398

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/go/rpk/pkg/adminapi/api_broker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
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 @@ -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
}
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
}
Loading