diff --git a/cmd/list.go b/cmd/list.go index 0da12226..a4982d5e 100644 --- a/cmd/list.go +++ b/cmd/list.go @@ -57,8 +57,7 @@ func (lc *ListCommand) runList(command *cobra.Command, args []string) error { printString(os.Stdout, "\nKubernetes version ") printYellow(os.Stdout, clusterMessage.Version.GitVersion) printService(os.Stdout, "\nKubernetes master", clusterMessage.Config.Host) - err = MoreInfo(clusterMessage.ClientSet, os.Stdout) - if err != nil { + if err := MoreInfo(clusterMessage.ClientSet, os.Stdout); err != nil { fmt.Println("(Error reporting can be ignored and does not affect usage.)") } } @@ -97,5 +96,7 @@ kubecm ls kubecm l # Filter out keywords(Multi-keyword support) kubecm ls kind k3s +# Useful environment variables +KUBECM_DISABLE_K8S_MORE_INFO: it will disable the k8s more info in the output ` } diff --git a/cmd/utils.go b/cmd/utils.go index addad10f..959f32a8 100644 --- a/cmd/utils.go +++ b/cmd/utils.go @@ -289,6 +289,9 @@ func ClusterStatus(duration time.Duration) (*ClusterStatusCheck, error) { // MoreInfo output more info func MoreInfo(clientSet kubernetes.Interface, writer io.Writer) error { + if os.Getenv("KUBECM_DISABLE_K8S_MORE_INFO") != "" { + return nil + } timeout := int64(2) ctx := context.TODO() nodesList, err := clientSet.CoreV1().Nodes().List(ctx, metav1.ListOptions{TimeoutSeconds: &timeout})