Skip to content

Commit

Permalink
fix: 修复cluster manager节点池更新问题
Browse files Browse the repository at this point in the history
  • Loading branch information
Maclon9573 committed Sep 12, 2024
1 parent e04e654 commit 9c64a0e
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions bcs-services/bcs-cluster-manager/internal/actions/nodegroup/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,33 @@ func (ga *GetAction) Handle(
}

func removeSensitiveInfo(group *cmproto.NodeGroup) *cmproto.NodeGroup {
shield := func(key string) string {
keyBytes := []byte(key)
if len(keyBytes) <= 4 {
return string(keyBytes)
}
size := len(keyBytes)

resultKeys := make([]byte, 0)
for i := range keyBytes {
if i < 2 || i >= (size-2) {
resultKeys = append(resultKeys, keyBytes[i])
continue
}

resultKeys = append(resultKeys, '*')
}

return string(resultKeys)
}

if group != nil && group.LaunchTemplate != nil {
if group.LaunchTemplate.InitLoginPassword != "" {
group.LaunchTemplate.InitLoginPassword = utils.RandomString(8)
group.LaunchTemplate.InitLoginPassword = shield(group.LaunchTemplate.InitLoginPassword)
}
if group.LaunchTemplate.KeyPair != nil {
if group.LaunchTemplate.KeyPair.KeyPublic != "" {
group.LaunchTemplate.KeyPair.KeyPublic = utils.RandomString(8)
group.LaunchTemplate.KeyPair.KeyPublic = shield(group.LaunchTemplate.KeyPair.KeyPublic)
}
group.LaunchTemplate.KeyPair.KeySecret = ""
}
Expand Down

0 comments on commit 9c64a0e

Please sign in to comment.