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
277dfbbd
Commit
277dfbbd
authored
Feb 13, 2019
by
Yago Nobre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add --kubeconfig-dir to validate mixed arguments whitelist, and refactor ValidateMixedArguments
parent
e69c735b
Show 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 @
277dfbbd
...
...
@@ -402,8 +402,8 @@ func ValidateMixedArguments(flag *pflag.FlagSet) error {
mixedInvalidFlags
:=
[]
string
{}
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"
{
// "--skip-*" flags or other
whitelist
ed flags can be set with --config
if
isAllowedFlag
(
f
.
Name
)
{
// "--skip-*" flags or other
allow
ed flags can be set with --config
return
}
mixedInvalidFlags
=
append
(
mixedInvalidFlags
,
f
.
Name
)
...
...
@@ -415,6 +415,26 @@ func ValidateMixedArguments(flag *pflag.FlagSet) error {
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
func
ValidateFeatureGates
(
featureGates
map
[
string
]
bool
,
fldPath
*
field
.
Path
)
field
.
ErrorList
{
allErrs
:=
field
.
ErrorList
{}
...
...
cmd/kubeadm/app/cmd/init.go
View file @
277dfbbd
...
...
@@ -243,12 +243,12 @@ func AddInitOtherFlags(flagSet *flag.FlagSet, cfgPath *string, skipTokenPrint, d
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."
,
)
// 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
(
skipTokenPrint
,
options
.
SkipTokenPrint
,
*
skipTokenPrint
,
"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
(
dryRun
,
options
.
DryRun
,
*
dryRun
,
"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
// Checks if an external CA is provided by the user.
externalCA
,
_
:=
certsphase
.
UsingExternalCA
(
&
cfg
.
ClusterConfiguration
)
if
externalCA
{
kubeconfigDir
:=
kubeadmconstants
.
Kubernetes
Dir
kubeconfigDir
:=
options
.
kubeconfig
Dir
if
options
.
dryRun
{
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