From 99e54e28d85ba306c9ef457d9f21be300a9039a6 Mon Sep 17 00:00:00 2001 From: shravan Date: Sun, 9 Feb 2020 19:15:39 +0530 Subject: [PATCH] 644 fixing compilation issue --- pkg/engine/utils.go | 9 --------- pkg/userinfo/roleRef.go | 8 ++++---- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/pkg/engine/utils.go b/pkg/engine/utils.go index 2eed09d48c..9750aa5ec2 100644 --- a/pkg/engine/utils.go +++ b/pkg/engine/utils.go @@ -286,15 +286,6 @@ func ParseNamespaceFromObject(bytes []byte) string { return "" } -func findKind(kinds []string, kindGVK string) bool { - for _, kind := range kinds { - if kind == kindGVK { - return true - } - } - return false -} - // validateGeneralRuleInfoVariables validate variable subtition defined in // - MatchResources // - ExcludeResources diff --git a/pkg/userinfo/roleRef.go b/pkg/userinfo/roleRef.go index e0b53b046b..438ac1bd7c 100644 --- a/pkg/userinfo/roleRef.go +++ b/pkg/userinfo/roleRef.go @@ -5,7 +5,6 @@ import ( "strings" "github.com/golang/glog" - "github.com/nirmata/kyverno/pkg/engine/rbac" v1beta1 "k8s.io/api/admission/v1beta1" authenticationv1 "k8s.io/api/authentication/v1" rbacv1 "k8s.io/api/rbac/v1" @@ -16,6 +15,7 @@ import ( const ( clusterrolekind = "ClusterRole" rolekind = "Role" + SaPrefix = "system:serviceaccount:" ) //GetRoleRef gets the list of roles and cluster roles for the incoming api-request @@ -97,7 +97,7 @@ func matchSubjectsMap(subject rbacv1.Subject, userInfo authenticationv1.UserInfo } func isServiceaccountUserInfo(username string) bool { - if strings.Contains(username, rbac.SaPrefix) { + if strings.Contains(username, SaPrefix) { return true } return false @@ -107,8 +107,8 @@ func isServiceaccountUserInfo(username string) bool { // serviceaccount represents as saPrefix:namespace:name in userInfo func matchServiceAccount(subject rbacv1.Subject, userInfo authenticationv1.UserInfo) bool { subjectServiceAccount := subject.Namespace + ":" + subject.Name - if userInfo.Username[len(rbac.SaPrefix):] != subjectServiceAccount { - glog.V(3).Infof("service account not match, expect %s, got %s", subjectServiceAccount, userInfo.Username[len(rbac.SaPrefix):]) + if userInfo.Username[len(SaPrefix):] != subjectServiceAccount { + glog.V(3).Infof("service account not match, expect %s, got %s", subjectServiceAccount, userInfo.Username[len(SaPrefix):]) return false }