Skip to content

Commit

Permalink
add KUBECM_DISABLE_K8S_MORE_INFO env to disable output moreinfo (#973)
Browse files Browse the repository at this point in the history
* add KUBECM_DISABLE_K8S_MORE_INFO env to disable output moreinfo

Signed-off-by: yxxhero <[email protected]>

* add docs for KUBECM_DISABLE_K8S_MORE_INFO

Signed-off-by: yxxhero <[email protected]>

---------

Signed-off-by: yxxhero <[email protected]>
  • Loading branch information
yxxhero authored Jun 11, 2024
1 parent 561e01c commit bd19760
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 3 additions & 2 deletions cmd/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.)")
}
}
Expand Down Expand Up @@ -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
`
}
3 changes: 3 additions & 0 deletions cmd/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down

0 comments on commit bd19760

Please sign in to comment.