Skip to content

Commit

Permalink
refactor: better name variables in pkg/webhook/utils
Browse files Browse the repository at this point in the history
  • Loading branch information
ludusrusso authored and prometherion committed May 4, 2021
1 parent 36c90d4 commit c2cede6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions pkg/webhook/utils/in_capsule_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ type handler struct {

// If the user performing action is not a Capsule user, can be skipped
func (h handler) isCapsuleUser(req admission.Request) bool {
g := utils.NewUserGroupList(req.UserInfo.Groups)
groupList := utils.NewUserGroupList(req.UserInfo.Groups)
// if the user is a ServiceAccount belonging to the kube-system namespace, definitely, it's not a Capsule user
// and we can skip the check in case of Capsule user group assigned to system:authenticated
// (ref: https://github.com/clastix/capsule/issues/234)
if g.Find("system:serviceaccounts:kube-system") {
if groupList.Find("system:serviceaccounts:kube-system") {
return false
}
return g.Find(h.capsuleGroup)
return groupList.Find(h.capsuleGroup)
}

func (h *handler) OnCreate(client client.Client, decoder *admission.Decoder) webhook.Func {
Expand Down
8 changes: 4 additions & 4 deletions pkg/webhook/utils/kubernetes_version.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ func GetK8sVersion() (major, minor int, ver string, err error) {
return 0, 0, "", err
}

v, err := client.Discovery().ServerVersion()
version, err := client.Discovery().ServerVersion()
if err != nil {
return 0, 0, "", err
}
major, _ = strconv.Atoi(v.Major)
minor, _ = strconv.Atoi(v.Minor)
ver = v.String()
major, _ = strconv.Atoi(version.Major)
minor, _ = strconv.Atoi(version.Minor)
ver = version.String()
return
}

0 comments on commit c2cede6

Please sign in to comment.