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
926baf5f
Commit
926baf5f
authored
Nov 23, 2017
by
xiangpengzhao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactoring ValidateUsages for for bootstrap tokens.
parent
980a5e80
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
5 deletions
+8
-5
constants.go
cmd/kubeadm/app/constants/constants.go
+2
-1
helpers.go
pkg/bootstrap/api/helpers.go
+3
-4
types.go
pkg/bootstrap/api/types.go
+3
-0
No files found.
cmd/kubeadm/app/constants/constants.go
View file @
926baf5f
...
...
@@ -25,6 +25,7 @@ import (
"time"
"k8s.io/api/core/v1"
bootstrapapi
"k8s.io/kubernetes/pkg/bootstrap/api"
"k8s.io/kubernetes/pkg/registry/core/service/ipallocator"
"k8s.io/kubernetes/pkg/util/version"
)
...
...
@@ -220,7 +221,7 @@ var (
AuthorizationWebhookConfigPath
=
filepath
.
Join
(
KubernetesDir
,
"webhook_authz.conf"
)
// DefaultTokenUsages specifies the default functions a token will get
DefaultTokenUsages
=
[]
string
{
"signing"
,
"authentication"
}
DefaultTokenUsages
=
bootstrapapi
.
KnownTokenUsages
// MasterComponents defines the master component names
MasterComponents
=
[]
string
{
KubeAPIServer
,
KubeControllerManager
,
KubeScheduler
}
...
...
pkg/bootstrap/api/helpers.go
View file @
926baf5f
...
...
@@ -37,16 +37,15 @@ func ValidateBootstrapGroupName(name string) error {
// ValidateUsages validates that the passed in string are valid usage strings for bootstrap tokens.
func
ValidateUsages
(
usages
[]
string
)
error
{
usageAuthentication
:=
strings
.
TrimPrefix
(
BootstrapTokenUsageAuthentication
,
BootstrapTokenUsagePrefix
)
usageSigning
:=
strings
.
TrimPrefix
(
BootstrapTokenUsageSigningKey
,
BootstrapTokenUsagePrefix
)
validUsages
:=
sets
.
NewString
(
KnownTokenUsages
...
)
invalidUsages
:=
sets
.
NewString
()
for
_
,
usage
:=
range
usages
{
if
usage
!=
usageAuthentication
&&
usage
!=
usageSigning
{
if
!
validUsages
.
Has
(
usage
)
{
invalidUsages
.
Insert
(
usage
)
}
}
if
len
(
invalidUsages
)
>
0
{
return
fmt
.
Errorf
(
"invalide bootstrap token usage string: %s, valid usage option
: %s, %s"
,
strings
.
Join
(
invalidUsages
.
List
(),
","
),
usageAuthentication
,
usageSigning
)
return
fmt
.
Errorf
(
"invalide bootstrap token usage string: %s, valid usage option
s: %s"
,
strings
.
Join
(
invalidUsages
.
List
(),
","
),
strings
.
Join
(
KnownTokenUsages
,
","
)
)
}
return
nil
}
pkg/bootstrap/api/types.go
View file @
926baf5f
...
...
@@ -95,3 +95,6 @@ const (
// tokens (in addition to any groups from BootstrapTokenExtraGroupsKey).
BootstrapDefaultGroup
=
"system:bootstrappers"
)
// KnownTokenUsages specifies the known functions a token will get.
var
KnownTokenUsages
=
[]
string
{
"signing"
,
"authentication"
}
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