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
2bfbbc31
Unverified
Commit
2bfbbc31
authored
Feb 13, 2019
by
Kubernetes Prow Robot
Committed by
GitHub
Feb 13, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #73998 from yagonobre/fix-mixed-args
Allow the usage of --kubeconfig-dir and --config flags on kubeadm init
parents
12502373
277dfbbd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
5 deletions
+25
-5
validation.go
cmd/kubeadm/app/apis/kubeadm/validation/validation.go
+22
-2
init.go
cmd/kubeadm/app/cmd/init.go
+3
-3
No files found.
cmd/kubeadm/app/apis/kubeadm/validation/validation.go
View file @
2bfbbc31
...
@@ -402,8 +402,8 @@ func ValidateMixedArguments(flag *pflag.FlagSet) error {
...
@@ -402,8 +402,8 @@ func ValidateMixedArguments(flag *pflag.FlagSet) error {
mixedInvalidFlags
:=
[]
string
{}
mixedInvalidFlags
:=
[]
string
{}
flag
.
Visit
(
func
(
f
*
pflag
.
Flag
)
{
flag
.
Visit
(
func
(
f
*
pflag
.
Flag
)
{
if
f
.
Name
==
"config"
||
f
.
Name
==
"ignore-preflight-errors"
||
strings
.
HasPrefix
(
f
.
Name
,
"skip-"
)
||
f
.
Name
==
"dry-run"
||
f
.
Name
==
"kubeconfig"
||
f
.
Name
==
"v"
||
f
.
Name
==
"rootfs"
||
f
.
Name
==
"print-join-command"
||
f
.
Name
==
"node-name"
||
f
.
Name
==
"cri-socket"
{
if
isAllowedFlag
(
f
.
Name
)
{
// "--skip-*" flags or other
whitelist
ed flags can be set with --config
// "--skip-*" flags or other
allow
ed flags can be set with --config
return
return
}
}
mixedInvalidFlags
=
append
(
mixedInvalidFlags
,
f
.
Name
)
mixedInvalidFlags
=
append
(
mixedInvalidFlags
,
f
.
Name
)
...
@@ -415,6 +415,26 @@ func ValidateMixedArguments(flag *pflag.FlagSet) error {
...
@@ -415,6 +415,26 @@ func ValidateMixedArguments(flag *pflag.FlagSet) error {
return
nil
return
nil
}
}
func
isAllowedFlag
(
flagName
string
)
bool
{
isAllowed
:=
false
switch
flagName
{
case
kubeadmcmdoptions
.
CfgPath
,
kubeadmcmdoptions
.
IgnorePreflightErrors
,
kubeadmcmdoptions
.
DryRun
,
kubeadmcmdoptions
.
KubeconfigPath
,
kubeadmcmdoptions
.
NodeName
,
kubeadmcmdoptions
.
NodeCRISocket
,
kubeadmcmdoptions
.
KubeconfigDir
,
"print-join-command"
,
"rootfs"
,
"v"
:
isAllowed
=
true
default
:
if
strings
.
HasPrefix
(
flagName
,
"skip-"
)
{
isAllowed
=
true
}
}
return
isAllowed
}
// ValidateFeatureGates validates provided feature gates
// ValidateFeatureGates validates provided feature gates
func
ValidateFeatureGates
(
featureGates
map
[
string
]
bool
,
fldPath
*
field
.
Path
)
field
.
ErrorList
{
func
ValidateFeatureGates
(
featureGates
map
[
string
]
bool
,
fldPath
*
field
.
Path
)
field
.
ErrorList
{
allErrs
:=
field
.
ErrorList
{}
allErrs
:=
field
.
ErrorList
{}
...
...
cmd/kubeadm/app/cmd/init.go
View file @
2bfbbc31
...
@@ -243,12 +243,12 @@ func AddInitOtherFlags(flagSet *flag.FlagSet, cfgPath *string, skipTokenPrint, d
...
@@ -243,12 +243,12 @@ func AddInitOtherFlags(flagSet *flag.FlagSet, cfgPath *string, skipTokenPrint, d
ignorePreflightErrors
,
options
.
IgnorePreflightErrors
,
*
ignorePreflightErrors
,
ignorePreflightErrors
,
options
.
IgnorePreflightErrors
,
*
ignorePreflightErrors
,
"A list of checks whose errors will be shown as warnings. Example: 'IsPrivilegedUser,Swap'. Value 'all' ignores errors from all checks."
,
"A list of checks whose errors will be shown as warnings. Example: 'IsPrivilegedUser,Swap'. Value 'all' ignores errors from all checks."
,
)
)
// Note: All flags that are not bound to the cfg object should be
whitelist
ed in cmd/kubeadm/app/apis/kubeadm/validation/validation.go
// Note: All flags that are not bound to the cfg object should be
allow
ed in cmd/kubeadm/app/apis/kubeadm/validation/validation.go
flagSet
.
BoolVar
(
flagSet
.
BoolVar
(
skipTokenPrint
,
options
.
SkipTokenPrint
,
*
skipTokenPrint
,
skipTokenPrint
,
options
.
SkipTokenPrint
,
*
skipTokenPrint
,
"Skip printing of the default bootstrap token generated by 'kubeadm init'."
,
"Skip printing of the default bootstrap token generated by 'kubeadm init'."
,
)
)
// Note: All flags that are not bound to the cfg object should be
whitelist
ed in cmd/kubeadm/app/apis/kubeadm/validation/validation.go
// Note: All flags that are not bound to the cfg object should be
allow
ed in cmd/kubeadm/app/apis/kubeadm/validation/validation.go
flagSet
.
BoolVar
(
flagSet
.
BoolVar
(
dryRun
,
options
.
DryRun
,
*
dryRun
,
dryRun
,
options
.
DryRun
,
*
dryRun
,
"Don't apply any changes; just output what would be done."
,
"Don't apply any changes; just output what would be done."
,
...
@@ -333,7 +333,7 @@ func newInitData(cmd *cobra.Command, args []string, options *initOptions, out io
...
@@ -333,7 +333,7 @@ func newInitData(cmd *cobra.Command, args []string, options *initOptions, out io
// Checks if an external CA is provided by the user.
// Checks if an external CA is provided by the user.
externalCA
,
_
:=
certsphase
.
UsingExternalCA
(
&
cfg
.
ClusterConfiguration
)
externalCA
,
_
:=
certsphase
.
UsingExternalCA
(
&
cfg
.
ClusterConfiguration
)
if
externalCA
{
if
externalCA
{
kubeconfigDir
:=
kubeadmconstants
.
Kubernetes
Dir
kubeconfigDir
:=
options
.
kubeconfig
Dir
if
options
.
dryRun
{
if
options
.
dryRun
{
kubeconfigDir
=
dryRunDir
kubeconfigDir
=
dryRunDir
}
}
...
...
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