mirror of
https://github.com/projectcapsule/capsule.git
synced 2026-08-25 16:07:24 +00:00
refactor: better name variables in pkg/webhook/utils
This commit is contained in:
committed by
Dario Tranchitella
parent
36c90d485e
commit
c2cede6287
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user