diff --git a/cmd/manage/resetpassword.go b/cmd/manage/resetpassword.go index b275155f..48a493f2 100644 --- a/cmd/manage/resetpassword.go +++ b/cmd/manage/resetpassword.go @@ -46,6 +46,10 @@ func NewResetPassword(f factory.Factory) *cobra.Command { Aliases: []string{"rp", "re-pass"}, Run: func(cmd *cobra.Command, args []string) { cfg, _ := config.LoadConfig() + if cfg.Quickon.DevOps { + logrus.Info("devops mode, skip reset password") + return + } if cfg.APIToken == "" { k8sClient, err := k8s.NewSimpleClient() if err != nil { diff --git a/internal/pkg/k8s/nodes.go b/internal/pkg/k8s/nodes.go index 6e8b0f83..9a2ed799 100644 --- a/internal/pkg/k8s/nodes.go +++ b/internal/pkg/k8s/nodes.go @@ -124,7 +124,7 @@ func (c *Client) GetNodes(resourceName string, selector labels.Selector) (map[st } // NodeResources -func (c *Client) GetNodeResources(sortBy string, selector labels.Selector) ([]NodeResources, error) { +func (c *Client) GetNodeResources(sortBy, output string, selector labels.Selector) ([]NodeResources, error) { var resources []NodeResources var nodenames []string @@ -168,19 +168,19 @@ func (c *Client) GetNodeResources(sortBy string, selector labels.Selector) ([]No resource.CPURequests = noderesource.CPURequests.String() resource.CPULimits = noderesource.CPULimits.String() resource.CPUCapacity = noderesource.CPUCapacity.String() - resource.CPURequestsFraction = ExceedsCompare(float64ToString(noderesource.CPURequestsFraction)) + resource.CPURequestsFraction = ExceedsCompare(float64ToString(noderesource.CPURequestsFraction), output) resource.CPULimitsFraction = float64ToString(noderesource.CPULimitsFraction) resource.MemoryUsages = noderesource.MemoryUsages.String() resource.MemoryRequests = noderesource.MemoryRequests.String() resource.MemoryLimits = noderesource.MemoryLimits.String() resource.MemoryCapacity = noderesource.MemoryCapacity.String() - resource.MemoryRequestsFraction = ExceedsCompare(float64ToString(noderesource.MemoryRequestsFraction)) + resource.MemoryRequestsFraction = ExceedsCompare(float64ToString(noderesource.MemoryRequestsFraction), output) resource.MemoryLimitsFraction = float64ToString(noderesource.MemoryLimitsFraction) resource.AllocatedPods = noderesource.AllocatedPods resource.PodCapacity = noderesource.PodCapacity - resource.PodFraction = ExceedsCompare(float64ToString(noderesource.PodFraction)) + resource.PodFraction = ExceedsCompare(float64ToString(noderesource.PodFraction), output) resources = append(resources, resource) } return resources, err diff --git a/internal/pkg/k8s/types.go b/internal/pkg/k8s/types.go index d61993dc..3bcba06a 100644 --- a/internal/pkg/k8s/types.go +++ b/internal/pkg/k8s/types.go @@ -118,8 +118,11 @@ func FieldString(str string) float64 { } } -// Compare -func ExceedsCompare(a string) string { +// ExceedsCompare table color +func ExceedsCompare(a, output string) string { + if strings.ToLower(output) == "json" || strings.ToLower(output) == "yaml" { + return a + } if FieldString(a) > float64(criticalThreshold) { return redColor(a) } else if FieldString(a) > float64(warningThreshold) { diff --git a/internal/pkg/status/top/node.go b/internal/pkg/status/top/node.go index b779a37d..da52826b 100644 --- a/internal/pkg/status/top/node.go +++ b/internal/pkg/status/top/node.go @@ -48,7 +48,7 @@ func (o *NodeOption) RunResourceNode() error { if err != nil { return err } - data, err := k.GetNodeResources(o.SortBy, selector) + data, err := k.GetNodeResources(o.SortBy, o.Output, selector) if err != nil { return err }