diff --git a/pkg/kubeapiserver/authorizer/modes/BUILD b/pkg/kubeapiserver/authorizer/modes/BUILD index 29176473626bb..97b233aa930f7 100644 --- a/pkg/kubeapiserver/authorizer/modes/BUILD +++ b/pkg/kubeapiserver/authorizer/modes/BUILD @@ -16,6 +16,7 @@ go_library( name = "go_default_library", srcs = ["modes.go"], importpath = "k8s.io/kubernetes/pkg/kubeapiserver/authorizer/modes", + deps = ["//vendor/k8s.io/apimachinery/pkg/util/sets:go_default_library"], ) filegroup( diff --git a/pkg/kubeapiserver/authorizer/modes/modes.go b/pkg/kubeapiserver/authorizer/modes/modes.go index 56a708a6b1d53..54d0a627701d5 100644 --- a/pkg/kubeapiserver/authorizer/modes/modes.go +++ b/pkg/kubeapiserver/authorizer/modes/modes.go @@ -16,6 +16,8 @@ limitations under the License. package modes +import "k8s.io/apimachinery/pkg/util/sets" + const ( ModeAlwaysAllow string = "AlwaysAllow" ModeAlwaysDeny string = "AlwaysDeny" @@ -29,10 +31,5 @@ var AuthorizationModeChoices = []string{ModeAlwaysAllow, ModeAlwaysDeny, ModeABA // IsValidAuthorizationMode returns true if the given authorization mode is a valid one for the apiserver func IsValidAuthorizationMode(authzMode string) bool { - for _, validMode := range AuthorizationModeChoices { - if authzMode == validMode { - return true - } - } - return false + return sets.NewString(AuthorizationModeChoices...).Has(authzMode) }