diff --git a/src/go/rpk/pkg/cli/cloud/login.go b/src/go/rpk/pkg/cli/cloud/login.go index bd30f27238b7c..9037434658774 100644 --- a/src/go/rpk/pkg/cli/cloud/login.go +++ b/src/go/rpk/pkg/cli/cloud/login.go @@ -135,7 +135,7 @@ rpk will talk to a localhost:9092 cluster until you swap to a different profile. if noProfile { // The current profile is seemingly pointing to a container cluster. if p.Name == common.ContainerProfileName { - fmt.Printf("You are talking to a localhost 'rpk container' cluster (rpk profile name: %q)", p.Name) + fmt.Printf("You are talking to a localhost 'rpk container' cluster (rpk profile name: %q)\n", p.Name) fmt.Println("To talk to a cloud cluster, use 'rpk cloud cluster select'.") return } diff --git a/src/go/rpk/pkg/cli/connect/client.go b/src/go/rpk/pkg/cli/connect/client.go index e5c9098d77d9f..85dcc2fd6cb5d 100644 --- a/src/go/rpk/pkg/cli/connect/client.go +++ b/src/go/rpk/pkg/cli/connect/client.go @@ -16,9 +16,9 @@ import ( "net/http" "os" "runtime" - "time" "github.com/redpanda-data/redpanda/src/go/rpk/pkg/httpapi" + "github.com/redpanda-data/redpanda/src/go/rpk/pkg/plugin" ) const pluginBaseURL = "https://rpk-plugins.redpanda.com" @@ -75,13 +75,9 @@ type connectRepoClient struct { } func newRepoClient() (*connectRepoClient, error) { - timeout := 240 * time.Second - if t := os.Getenv("RPK_PLUGIN_DOWNLOAD_TIMEOUT"); t != "" { - duration, err := time.ParseDuration(t) - if err != nil { - return nil, fmt.Errorf("unable to parse RPK_PLUGIN_DOWNLOAD_TIMEOUT: %v", err) - } - timeout = duration + timeout, err := plugin.GetPluginDownloadTimeout() + if err != nil { + return nil, err } return &connectRepoClient{ cl: httpapi.NewClient( diff --git a/src/go/rpk/pkg/cli/registry/schema/get.go b/src/go/rpk/pkg/cli/registry/schema/get.go index a881b49d1ccde..5f4c98576ee71 100644 --- a/src/go/rpk/pkg/cli/registry/schema/get.go +++ b/src/go/rpk/pkg/cli/registry/schema/get.go @@ -50,12 +50,10 @@ To print the schema, use the '--print-schema' flag. Args: cobra.MaximumNArgs(1), Run: func(cmd *cobra.Command, args []string) { f := p.Formatter - var helpFormat any - helpFormat = []subjectSchema{} - if printSchema { - helpFormat = "" + if printSchema && f.Kind != "text" { + out.Die("--print-schema cannot be used along with --format %v", f.Kind) } - if h, ok := f.Help(helpFormat); ok { + if h, ok := f.Help([]subjectSchema{}); ok { out.Exit(h) } p, err := p.LoadVirtualProfile(fs) diff --git a/src/go/rpk/pkg/cli/version/version.go b/src/go/rpk/pkg/cli/version/version.go index f2b466e901139..a543dd5231cee 100644 --- a/src/go/rpk/pkg/cli/version/version.go +++ b/src/go/rpk/pkg/cli/version/version.go @@ -60,7 +60,9 @@ This command prints the current rpk version and allows you to list the Redpanda version running on each node in your cluster. To list the Redpanda version of each node in your cluster you may pass the -Admin API hosts via flags, profile, or environment variables.`, +Admin API hosts using flags, profile, or environment variables. + +To get only the rpk version, use 'rpk --version'.`, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, _ []string) { rv := rpkVersion{ @@ -131,7 +133,9 @@ func printClusterVersions(rpv *redpandaVersions) { if len(*rpv) == 0 { fmt.Println(` Unreachable, to debug, use the '-v' flag. To get the broker versions, pass the hosts via flags, profile, or environment variables: - rpk version -X admin.hosts=`) + rpk version -X admin.hosts= + + To get only the rpk version, use 'rpk --version'.`) return } for _, v := range *rpv { diff --git a/src/go/rpk/pkg/plugin/plugin.go b/src/go/rpk/pkg/plugin/plugin.go index e0bc82d9d88c8..883e0fcbc46b7 100644 --- a/src/go/rpk/pkg/plugin/plugin.go +++ b/src/go/rpk/pkg/plugin/plugin.go @@ -337,9 +337,13 @@ func WriteBinary(fs afero.Fs, name, dstDir string, contents []byte, autocomplete // If the url ends in ".gz", this unzips the binary before shasumming. If the // url ends in ".tar.gz", this unzips, then untars ONE file, then shasums. func Download(ctx context.Context, url string, isKnownCompressed bool, expShaPrefix string) ([]byte, error) { + timeout, err := GetPluginDownloadTimeout() + if err != nil { + return nil, err + } cl := httpapi.NewClient( httpapi.HTTPClient(&http.Client{ - Timeout: 100 * time.Second, + Timeout: timeout, }), ) @@ -366,7 +370,6 @@ func Download(ctx context.Context, url string, isKnownCompressed bool, expShaPre plugin = untar } - var err error if raw, err = io.ReadAll(plugin); err != nil { return nil, fmt.Errorf("unable to read plugin: %w", err) } @@ -381,3 +384,15 @@ func Download(ctx context.Context, url string, isKnownCompressed bool, expShaPre return raw, nil } + +func GetPluginDownloadTimeout() (time.Duration, error) { + timeout := 300 * time.Second + if t := os.Getenv("RPK_PLUGIN_DOWNLOAD_TIMEOUT"); t != "" { + duration, err := time.ParseDuration(t) + if err != nil { + return 0, fmt.Errorf("unable to parse RPK_PLUGIN_DOWNLOAD_TIMEOUT: %v", err) + } + timeout = duration + } + return timeout, nil +}