refactor: better name variables in pkg/webhook/utils

This commit is contained in:
Ludovico Russo
2021-05-04 17:49:13 +02:00
committed by Dario Tranchitella
parent 36c90d485e
commit c2cede6287
2 changed files with 7 additions and 7 deletions
+3 -3
View File
@@ -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 {
+4 -4
View File
@@ -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
}