Skip to content

Commit

Permalink
Merge pull request #457 from pratikjagrut/kubernetes.version.flag
Browse files Browse the repository at this point in the history
fix: warn if the patch version is passed in kubernetes version flag
  • Loading branch information
FabianKramm authored May 2, 2022
2 parents 51a3baa + 565fc32 commit 8166177
Show file tree
Hide file tree
Showing 7 changed files with 482 additions and 1 deletion.
17 changes: 16 additions & 1 deletion cmd/vclusterctl/cmd/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/loft-sh/vcluster/pkg/helm/values"
"github.com/loft-sh/vcluster/pkg/upgrade"
"github.com/loft-sh/vcluster/pkg/util"
"golang.org/x/mod/semver"

"github.com/loft-sh/vcluster/cmd/vclusterctl/flags"
"github.com/loft-sh/vcluster/cmd/vclusterctl/log"
Expand Down Expand Up @@ -172,7 +173,21 @@ func (cmd *CreateCmd) Run(args []string) error {

var kubernetesVersion *version.Info
if cmd.KubernetesVersion != "" {
kubernetesVersion, err = values.ParseKubernetesVersionInfo(cmd.KubernetesVersion)
if cmd.KubernetesVersion[0] != 'v' {
cmd.KubernetesVersion = "v" + cmd.KubernetesVersion
}

if !semver.IsValid(cmd.KubernetesVersion) {
return fmt.Errorf("please use valid semantic versioning format, e.g. vX.X")
}

majorMinorVer := semver.MajorMinor(cmd.KubernetesVersion)

if splittedVersion := strings.Split(cmd.KubernetesVersion, "."); len(splittedVersion) > 2 {
cmd.log.Warnf("currently we only support major.minor version (%s) and not the patch version (%s)", majorMinorVer, cmd.KubernetesVersion)
}

kubernetesVersion, err = values.ParseKubernetesVersionInfo(majorMinorVer)
if err != nil {
return err
}
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ require (
go.uber.org/multierr v1.6.0 // indirect
go.uber.org/zap v1.19.1 // indirect
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 // indirect
golang.org/x/mod v0.5.1
golang.org/x/net v0.0.0-20211209124913-491a49abca63 // indirect
golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f // indirect
golang.org/x/sys v0.0.0-20211029165221-6e7872819dc8 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,8 @@ golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.5.1 h1:OJxoQ/rynoF0dcCdI7cLPktw/hR2cueqYfjm43oqK38=
golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
Expand Down
27 changes: 27 additions & 0 deletions vendor/golang.org/x/mod/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions vendor/golang.org/x/mod/PATENTS

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 8166177

Please sign in to comment.