From 7be761b9843ef426ae54378010b712b14ad93012 Mon Sep 17 00:00:00 2001 From: Oscar Utbult Date: Thu, 7 Jul 2022 20:13:14 +0200 Subject: [PATCH] Improve clusterctl describe cluster error message --- cmd/clusterctl/cmd/describe_cluster.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cmd/clusterctl/cmd/describe_cluster.go b/cmd/clusterctl/cmd/describe_cluster.go index 85567e92434c..0bd17840650b 100644 --- a/cmd/clusterctl/cmd/describe_cluster.go +++ b/cmd/clusterctl/cmd/describe_cluster.go @@ -26,6 +26,7 @@ import ( "github.com/fatih/color" "github.com/gobuffalo/flect" "github.com/olekukonko/tablewriter" + "github.com/pkg/errors" "github.com/spf13/cobra" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/util/duration" @@ -94,7 +95,12 @@ var describeClusterClusterCmd = &cobra.Command{ # e.g. show the infrastructure machine objects, no matter if the current state is already reported by the machine's Ready condition. clusterctl describe cluster test-1 --disable-no-echo`), - Args: cobra.ExactArgs(1), + Args: func(cmd *cobra.Command, args []string) error { + if len(args) != 1 { + return errors.New("please specify a cluster name") + } + return nil + }, RunE: func(cmd *cobra.Command, args []string) error { return runDescribeCluster(args[0]) },