提交 a9ec145b 编写于 作者: T Thomas Stromberg

Allow --kubernetes-version to be specified without the leading v

上级 ce79abad
......@@ -586,15 +586,17 @@ func validateNetwork(h *host.Host) string {
// validateKubernetesVersions ensures that the requested version is reasonable
func validateKubernetesVersions(old *cfg.Config) (string, bool) {
nv := viper.GetString(kubernetesVersion)
rawVersion := viper.GetString(kubernetesVersion)
isUpgrade := false
if nv == "" {
nv = constants.DefaultKubernetesVersion
if rawVersion == "" {
rawVersion = constants.DefaultKubernetesVersion
}
nvs, err := semver.Make(strings.TrimPrefix(nv, version.VersionPrefix))
nvs, err := semver.Make(strings.TrimPrefix(rawVersion, version.VersionPrefix))
if err != nil {
exit.WithCode(exit.Data, "Unable to parse %q: %v", nv, err)
exit.WithCode(exit.Data, "Unable to parse %q: %v", rawVersion, err)
}
nv := version.VersionPrefix + nvs.String()
if old == nil || old.KubernetesConfig.KubernetesVersion == "" {
return nv, isUpgrade
......
......@@ -82,7 +82,8 @@ func TestVersionUpgrade(t *testing.T) {
releaseRunner.RunCommand("stop", true)
releaseRunner.CheckStatus(state.Stopped.String())
currentRunner.Start(fmt.Sprintf("--kubernetes-version=%s", constants.NewestKubernetesVersion))
// Trim the leading "v" prefix to assert that we handle it properly.
currentRunner.Start(fmt.Sprintf("--kubernetes-version=%s", strings.TrimPrefix(constants.NewestKubernetesVersion, "v"))
currentRunner.CheckStatus(state.Running.String())
currentRunner.RunCommand("delete", true)
currentRunner.CheckStatus(state.None.String())
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册