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
7af52384
Unverified
Commit
7af52384
authored
Dec 04, 2018
by
Kubernetes Prow Robot
Committed by
GitHub
Dec 04, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #71467 from rosti/nuke-config-print-defaults
kubeadm: remove kubeadm config print-defaults
parents
3b53ea5e
ffb670b8
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
104 deletions
+11
-104
config.go
cmd/kubeadm/app/cmd/config.go
+11
-100
.generated_docs
docs/.generated_docs
+0
-1
kubeadm-config-print-default.1
docs/man/man1/kubeadm-config-print-default.1
+0
-3
No files found.
cmd/kubeadm/app/cmd/config.go
View file @
7af52384
...
...
@@ -85,7 +85,6 @@ func NewCmdConfig(out io.Writer) *cobra.Command {
kubeConfigFile
=
cmdutil
.
FindExistingKubeConfig
(
kubeConfigFile
)
cmd
.
AddCommand
(
NewCmdConfigPrint
(
out
))
cmd
.
AddCommand
(
NewCmdConfigPrintDefault
(
out
))
cmd
.
AddCommand
(
NewCmdConfigMigrate
(
out
))
cmd
.
AddCommand
(
NewCmdConfigUpload
(
out
,
&
kubeConfigFile
))
cmd
.
AddCommand
(
NewCmdConfigView
(
out
,
&
kubeConfigFile
))
...
...
@@ -142,7 +141,7 @@ func runConfigPrintActionDefaults(out io.Writer, componentConfigs []string, conf
allBytes
:=
[][]
byte
{
initialConfig
}
for
_
,
componentConfig
:=
range
componentConfigs
{
cfgBytes
,
err
:=
getDefaultComponentConfig
APIObject
Bytes
(
componentConfig
)
cfgBytes
,
err
:=
getDefaultComponentConfigBytes
(
componentConfig
)
kubeadmutil
.
CheckErr
(
err
)
allBytes
=
append
(
allBytes
,
cfgBytes
)
}
...
...
@@ -150,68 +149,23 @@ func runConfigPrintActionDefaults(out io.Writer, componentConfigs []string, conf
fmt
.
Fprint
(
out
,
string
(
bytes
.
Join
(
allBytes
,
[]
byte
(
constants
.
YAMLDocumentSeparator
))))
}
// NewCmdConfigPrintDefault returns cobra.Command for "kubeadm config print-default" command
func
NewCmdConfigPrintDefault
(
out
io
.
Writer
)
*
cobra
.
Command
{
apiObjects
:=
[]
string
{}
cmd
:=
&
cobra
.
Command
{
Use
:
"print-default"
,
Aliases
:
[]
string
{
"print-defaults"
},
Short
:
"Print the default values for a kubeadm configuration object."
,
Long
:
fmt
.
Sprintf
(
dedent
.
Dedent
(
`
This command prints objects such as the default InitConfiguration that is used for 'kubeadm init' and 'kubeadm upgrade',
and the default JoinConfiguration object that is used for 'kubeadm join'.
For documentation visit: https://godoc.org/k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1alpha3
Note that sensitive values like the Bootstrap Token fields are replaced with placeholder values like %q in order to pass validation but
not perform the real computation for creating a token.
`
),
placeholderToken
),
Deprecated
:
"Please, use `kubeadm config print` instead."
,
Run
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
if
len
(
apiObjects
)
==
0
{
apiObjects
=
getSupportedAPIObjects
()
}
allBytes
:=
[][]
byte
{}
for
_
,
apiObject
:=
range
apiObjects
{
cfgBytes
,
err
:=
getDefaultAPIObjectBytes
(
apiObject
)
kubeadmutil
.
CheckErr
(
err
)
allBytes
=
append
(
allBytes
,
cfgBytes
)
}
fmt
.
Fprint
(
out
,
string
(
bytes
.
Join
(
allBytes
,
[]
byte
(
constants
.
YAMLDocumentSeparator
))))
},
}
cmd
.
Flags
()
.
StringSliceVar
(
&
apiObjects
,
"api-objects"
,
apiObjects
,
fmt
.
Sprintf
(
"A comma-separated list for API objects to print the default values for. Available values: %v. This flag unset means 'print all known objects'"
,
getAllAPIObjectNames
()))
return
cmd
}
func
getDefaultComponentConfigAPIObjectBytes
(
apiObject
string
)
([]
byte
,
error
)
{
func
getDefaultComponentConfigBytes
(
apiObject
string
)
([]
byte
,
error
)
{
registration
,
ok
:=
componentconfigs
.
Known
[
componentconfigs
.
RegistrationKind
(
apiObject
)]
if
!
ok
{
return
[]
byte
{},
errors
.
Errorf
(
"--component-configs needs to contain some of %v"
,
getSupportedComponentConfigAPIObjects
())
}
return
getDefaultComponentConfigBytes
(
registration
)
}
func
getDefaultAPIObjectBytes
(
apiObject
string
)
([]
byte
,
error
)
{
switch
apiObject
{
case
constants
.
InitConfigurationKind
:
return
getDefaultInitConfigBytesByKind
(
constants
.
InitConfigurationKind
)
case
constants
.
ClusterConfigurationKind
:
return
getDefaultInitConfigBytesByKind
(
constants
.
ClusterConfigurationKind
)
case
constants
.
JoinConfigurationKind
:
return
getDefaultNodeConfigBytes
()
defaultedInitConfig
,
err
:=
getDefaultedInitConfig
()
if
err
!=
nil
{
return
[]
byte
{},
err
}
default
:
// Is this a component config?
registration
,
ok
:=
componentconfigs
.
Known
[
componentconfigs
.
RegistrationKind
(
apiObject
)]
if
!
ok
{
return
[]
byte
{},
errors
.
Errorf
(
"--api-object needs to be one of %v"
,
getAllAPIObjectNames
())
}
return
getDefaultComponentConfigBytes
(
registration
)
realObj
,
ok
:=
registration
.
GetFromInternalConfig
(
&
defaultedInitConfig
.
ClusterConfiguration
)
if
!
ok
{
return
[]
byte
{},
errors
.
New
(
"GetFromInternalConfig failed"
)
}
return
registration
.
Marshal
(
realObj
)
}
// getSupportedComponentConfigAPIObjects returns all currently supported component config API object names
...
...
@@ -223,23 +177,6 @@ func getSupportedComponentConfigAPIObjects() []string {
return
objects
}
// getSupportedAPIObjects returns all currently supported API object names
func
getSupportedAPIObjects
()
[]
string
{
baseObjects
:=
[]
string
{
constants
.
InitConfigurationKind
,
constants
.
ClusterConfigurationKind
,
constants
.
JoinConfigurationKind
}
objects
:=
getSupportedComponentConfigAPIObjects
()
objects
=
append
(
objects
,
baseObjects
...
)
return
objects
}
// getAllAPIObjectNames returns currently supported API object names and their historical aliases
// NB. currently there is no historical supported API objects, but we keep this function for future changes
func
getAllAPIObjectNames
()
[]
string
{
historicAPIObjectAliases
:=
[]
string
{}
objects
:=
getSupportedAPIObjects
()
objects
=
append
(
objects
,
historicAPIObjectAliases
...
)
return
objects
}
func
getDefaultedInitConfig
()
(
*
kubeadmapi
.
InitConfiguration
,
error
)
{
return
configutil
.
ConfigFileAndDefaultsToInternalConfig
(
""
,
&
kubeadmapiv1beta1
.
InitConfiguration
{
// TODO: Probably move to getDefaultedClusterConfig?
...
...
@@ -260,18 +197,6 @@ func getDefaultInitConfigBytes() ([]byte, error) {
return
configutil
.
MarshalKubeadmConfigObject
(
internalcfg
)
}
func
getDefaultInitConfigBytesByKind
(
kind
string
)
([]
byte
,
error
)
{
b
,
err
:=
getDefaultInitConfigBytes
()
if
err
!=
nil
{
return
[]
byte
{},
err
}
gvkmap
,
err
:=
kubeadmutil
.
SplitYAMLDocuments
(
b
)
if
err
!=
nil
{
return
[]
byte
{},
err
}
return
gvkmap
[
kubeadmapiv1beta1
.
SchemeGroupVersion
.
WithKind
(
kind
)],
nil
}
func
getDefaultNodeConfigBytes
()
([]
byte
,
error
)
{
internalcfg
,
err
:=
configutil
.
JoinConfigFileAndDefaultsToInternalConfig
(
""
,
&
kubeadmapiv1beta1
.
JoinConfiguration
{
Discovery
:
kubeadmapiv1beta1
.
Discovery
{
...
...
@@ -289,20 +214,6 @@ func getDefaultNodeConfigBytes() ([]byte, error) {
return
configutil
.
MarshalKubeadmConfigObject
(
internalcfg
)
}
func
getDefaultComponentConfigBytes
(
registration
componentconfigs
.
Registration
)
([]
byte
,
error
)
{
defaultedInitConfig
,
err
:=
getDefaultedInitConfig
()
if
err
!=
nil
{
return
[]
byte
{},
err
}
realobj
,
ok
:=
registration
.
GetFromInternalConfig
(
&
defaultedInitConfig
.
ClusterConfiguration
)
if
!
ok
{
return
[]
byte
{},
errors
.
New
(
"GetFromInternalConfig failed"
)
}
return
registration
.
Marshal
(
realobj
)
}
// NewCmdConfigMigrate returns cobra.Command for "kubeadm config migrate" command
func
NewCmdConfigMigrate
(
out
io
.
Writer
)
*
cobra
.
Command
{
var
oldCfgPath
,
newCfgPath
string
...
...
docs/.generated_docs
View file @
7af52384
...
...
@@ -127,7 +127,6 @@ docs/man/man1/kubeadm-config-images-list.1
docs/man/man1/kubeadm-config-images-pull.1
docs/man/man1/kubeadm-config-images.1
docs/man/man1/kubeadm-config-migrate.1
docs/man/man1/kubeadm-config-print-default.1
docs/man/man1/kubeadm-config-print-init-defaults.1
docs/man/man1/kubeadm-config-print-join-defaults.1
docs/man/man1/kubeadm-config-print.1
...
...
docs/man/man1/kubeadm-config-print-default.1
deleted
100644 → 0
View file @
3b53ea5e
This file is autogenerated, but we've stopped checking such files into the
repository to reduce the need for rebases. Please run hack/generate-docs.sh to
populate this file.
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