From 529c8fc1a801efb3c3a8845529251e2510b9e5e8 Mon Sep 17 00:00:00 2001 From: yxxhero Date: Tue, 11 Jun 2024 12:53:13 +0800 Subject: [PATCH 1/2] add KUBECM_DISABLE_K8S_MORE_INFO env to disable output moreinfo Signed-off-by: yxxhero --- cmd/list.go | 3 +-- cmd/utils.go | 3 +++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/cmd/list.go b/cmd/list.go index 0da12226..44342ec2 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.)") } } 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}) From f1d2bc2117382a45d0596ff8f6bc434259a527c4 Mon Sep 17 00:00:00 2001 From: yxxhero Date: Tue, 11 Jun 2024 14:54:39 +0800 Subject: [PATCH 2/2] add docs for KUBECM_DISABLE_K8S_MORE_INFO Signed-off-by: yxxhero --- cmd/list.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cmd/list.go b/cmd/list.go index 44342ec2..a4982d5e 100644 --- a/cmd/list.go +++ b/cmd/list.go @@ -96,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 ` }