Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
96e2610a
Commit
96e2610a
authored
Nov 16, 2017
by
Yanqiang Miao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use `sets` instead of `for` statement in "IsValidAuthorizationMode"
parent
d6325933
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
6 deletions
+4
-6
BUILD
pkg/kubeapiserver/authorizer/modes/BUILD
+1
-0
modes.go
pkg/kubeapiserver/authorizer/modes/modes.go
+3
-6
No files found.
pkg/kubeapiserver/authorizer/modes/BUILD
View file @
96e2610a
...
@@ -17,6 +17,7 @@ go_library(
...
@@ -17,6 +17,7 @@ go_library(
name = "go_default_library",
name = "go_default_library",
srcs = ["modes.go"],
srcs = ["modes.go"],
importpath = "k8s.io/kubernetes/pkg/kubeapiserver/authorizer/modes",
importpath = "k8s.io/kubernetes/pkg/kubeapiserver/authorizer/modes",
deps = ["//vendor/k8s.io/apimachinery/pkg/util/sets:go_default_library"],
)
)
filegroup(
filegroup(
...
...
pkg/kubeapiserver/authorizer/modes/modes.go
View file @
96e2610a
...
@@ -16,6 +16,8 @@ limitations under the License.
...
@@ -16,6 +16,8 @@ limitations under the License.
package
modes
package
modes
import
"k8s.io/apimachinery/pkg/util/sets"
const
(
const
(
ModeAlwaysAllow
string
=
"AlwaysAllow"
ModeAlwaysAllow
string
=
"AlwaysAllow"
ModeAlwaysDeny
string
=
"AlwaysDeny"
ModeAlwaysDeny
string
=
"AlwaysDeny"
...
@@ -29,10 +31,5 @@ var AuthorizationModeChoices = []string{ModeAlwaysAllow, ModeAlwaysDeny, ModeABA
...
@@ -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
// IsValidAuthorizationMode returns true if the given authorization mode is a valid one for the apiserver
func
IsValidAuthorizationMode
(
authzMode
string
)
bool
{
func
IsValidAuthorizationMode
(
authzMode
string
)
bool
{
for
_
,
validMode
:=
range
AuthorizationModeChoices
{
return
sets
.
NewString
(
AuthorizationModeChoices
...
)
.
Has
(
authzMode
)
if
authzMode
==
validMode
{
return
true
}
}
return
false
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment