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
8362d7f6
Commit
8362d7f6
authored
Sep 28, 2017
by
Feng Min
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow version arg in "kubeadm upgrade apply" optional
It's optional if the config file contain the version information.
parent
820ea04f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
4 deletions
+36
-4
apply.go
cmd/kubeadm/app/cmd/upgrade/apply.go
+19
-4
configuration.go
cmd/kubeadm/app/phases/upgrade/configuration.go
+17
-0
No files found.
cmd/kubeadm/app/cmd/upgrade/apply.go
View file @
8362d7f6
...
@@ -80,11 +80,26 @@ func NewCmdApply(parentFlags *cmdUpgradeFlags) *cobra.Command {
...
@@ -80,11 +80,26 @@ func NewCmdApply(parentFlags *cmdUpgradeFlags) *cobra.Command {
err
=
runPreflightChecks
(
flags
.
parent
.
ignorePreflightErrorsSet
)
err
=
runPreflightChecks
(
flags
.
parent
.
ignorePreflightErrorsSet
)
kubeadmutil
.
CheckErr
(
err
)
kubeadmutil
.
CheckErr
(
err
)
err
=
cmdutil
.
ValidateExactArgNumber
(
args
,
[]
string
{
"version"
})
// If the version is specified in config file, pick up that value.
kubeadmutil
.
CheckErr
(
err
)
if
flags
.
parent
.
cfgPath
!=
""
{
cfg
,
err
:=
upgrade
.
FetchConfigurationFromFile
(
flags
.
parent
.
cfgPath
)
kubeadmutil
.
CheckErr
(
err
)
if
cfg
.
KubernetesVersion
!=
""
{
flags
.
newK8sVersionStr
=
cfg
.
KubernetesVersion
}
}
// It's safe to use args[0] here as the slice has been validated above
// If the new version is already specified in config file, version arg is optional.
flags
.
newK8sVersionStr
=
args
[
0
]
if
flags
.
newK8sVersionStr
==
""
{
err
=
cmdutil
.
ValidateExactArgNumber
(
args
,
[]
string
{
"version"
})
kubeadmutil
.
CheckErr
(
err
)
}
// If option was specified in both args and config file, args will overwrite the config file.
if
len
(
args
)
==
1
{
flags
.
newK8sVersionStr
=
args
[
0
]
}
// Default the flags dynamically, based on each others' value
// Default the flags dynamically, based on each others' value
err
=
SetImplicitFlags
(
flags
)
err
=
SetImplicitFlags
(
flags
)
...
...
cmd/kubeadm/app/phases/upgrade/configuration.go
View file @
8362d7f6
...
@@ -52,6 +52,23 @@ func FetchConfiguration(client clientset.Interface, w io.Writer, cfgPath string)
...
@@ -52,6 +52,23 @@ func FetchConfiguration(client clientset.Interface, w io.Writer, cfgPath string)
return
versionedcfg
,
nil
return
versionedcfg
,
nil
}
}
// FetchConfigurationFromFile fetch configuration from a file
func
FetchConfigurationFromFile
(
cfgPath
string
)
(
*
kubeadmapiext
.
MasterConfiguration
,
error
)
{
// Load the configuration from a file or the cluster
configBytes
,
err
:=
ioutil
.
ReadFile
(
cfgPath
)
if
err
!=
nil
{
return
nil
,
err
}
// Take the versioned configuration populated from the configmap, default it and validate
// Return the internal version of the API object
versionedcfg
,
err
:=
bytesToValidatedMasterConfig
(
configBytes
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"could not decode configuration: %v"
,
err
)
}
return
versionedcfg
,
nil
}
// loadConfigurationBytes loads the configuration byte slice from either a file or the cluster ConfigMap
// loadConfigurationBytes loads the configuration byte slice from either a file or the cluster ConfigMap
func
loadConfigurationBytes
(
client
clientset
.
Interface
,
w
io
.
Writer
,
cfgPath
string
)
([]
byte
,
error
)
{
func
loadConfigurationBytes
(
client
clientset
.
Interface
,
w
io
.
Writer
,
cfgPath
string
)
([]
byte
,
error
)
{
if
cfgPath
!=
""
{
if
cfgPath
!=
""
{
...
...
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