Skip to content

Commit

Permalink
fix(quickon): disable devops reset password
Browse files Browse the repository at this point in the history
disable devops reset password

Signed-off-by: ysicing <[email protected]>
  • Loading branch information
ysicing committed Aug 30, 2023
1 parent 2b9e3b2 commit 224622a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
4 changes: 4 additions & 0 deletions cmd/manage/resetpassword.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 4 additions & 4 deletions internal/pkg/k8s/nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions internal/pkg/k8s/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/status/top/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 224622a

Please sign in to comment.