Skip to content

Commit 224622a

Browse files
committed
fix(quickon): disable devops reset password
disable devops reset password Signed-off-by: ysicing <[email protected]>
1 parent 2b9e3b2 commit 224622a

File tree

4 files changed

+14
-7
lines changed

4 files changed

+14
-7
lines changed

cmd/manage/resetpassword.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ func NewResetPassword(f factory.Factory) *cobra.Command {
4646
Aliases: []string{"rp", "re-pass"},
4747
Run: func(cmd *cobra.Command, args []string) {
4848
cfg, _ := config.LoadConfig()
49+
if cfg.Quickon.DevOps {
50+
logrus.Info("devops mode, skip reset password")
51+
return
52+
}
4953
if cfg.APIToken == "" {
5054
k8sClient, err := k8s.NewSimpleClient()
5155
if err != nil {

internal/pkg/k8s/nodes.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ func (c *Client) GetNodes(resourceName string, selector labels.Selector) (map[st
124124
}
125125

126126
// NodeResources
127-
func (c *Client) GetNodeResources(sortBy string, selector labels.Selector) ([]NodeResources, error) {
127+
func (c *Client) GetNodeResources(sortBy, output string, selector labels.Selector) ([]NodeResources, error) {
128128
var resources []NodeResources
129129
var nodenames []string
130130

@@ -168,19 +168,19 @@ func (c *Client) GetNodeResources(sortBy string, selector labels.Selector) ([]No
168168
resource.CPURequests = noderesource.CPURequests.String()
169169
resource.CPULimits = noderesource.CPULimits.String()
170170
resource.CPUCapacity = noderesource.CPUCapacity.String()
171-
resource.CPURequestsFraction = ExceedsCompare(float64ToString(noderesource.CPURequestsFraction))
171+
resource.CPURequestsFraction = ExceedsCompare(float64ToString(noderesource.CPURequestsFraction), output)
172172
resource.CPULimitsFraction = float64ToString(noderesource.CPULimitsFraction)
173173

174174
resource.MemoryUsages = noderesource.MemoryUsages.String()
175175
resource.MemoryRequests = noderesource.MemoryRequests.String()
176176
resource.MemoryLimits = noderesource.MemoryLimits.String()
177177
resource.MemoryCapacity = noderesource.MemoryCapacity.String()
178-
resource.MemoryRequestsFraction = ExceedsCompare(float64ToString(noderesource.MemoryRequestsFraction))
178+
resource.MemoryRequestsFraction = ExceedsCompare(float64ToString(noderesource.MemoryRequestsFraction), output)
179179
resource.MemoryLimitsFraction = float64ToString(noderesource.MemoryLimitsFraction)
180180

181181
resource.AllocatedPods = noderesource.AllocatedPods
182182
resource.PodCapacity = noderesource.PodCapacity
183-
resource.PodFraction = ExceedsCompare(float64ToString(noderesource.PodFraction))
183+
resource.PodFraction = ExceedsCompare(float64ToString(noderesource.PodFraction), output)
184184
resources = append(resources, resource)
185185
}
186186
return resources, err

internal/pkg/k8s/types.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,11 @@ func FieldString(str string) float64 {
118118
}
119119
}
120120

121-
// Compare
122-
func ExceedsCompare(a string) string {
121+
// ExceedsCompare table color
122+
func ExceedsCompare(a, output string) string {
123+
if strings.ToLower(output) == "json" || strings.ToLower(output) == "yaml" {
124+
return a
125+
}
123126
if FieldString(a) > float64(criticalThreshold) {
124127
return redColor(a)
125128
} else if FieldString(a) > float64(warningThreshold) {

internal/pkg/status/top/node.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func (o *NodeOption) RunResourceNode() error {
4848
if err != nil {
4949
return err
5050
}
51-
data, err := k.GetNodeResources(o.SortBy, selector)
51+
data, err := k.GetNodeResources(o.SortBy, o.Output, selector)
5252
if err != nil {
5353
return err
5454
}

0 commit comments

Comments
 (0)