diff --git a/phase/download_binaries.go b/phase/download_binaries.go index 99d734a2..f0500dbc 100644 --- a/phase/download_binaries.go +++ b/phase/download_binaries.go @@ -5,6 +5,7 @@ import ( "io" "net/http" "os" + "strings" "github.com/k0sproject/k0sctl/cache" "github.com/k0sproject/k0sctl/pkg/apis/k0sctl.k0sproject.io/v1beta1" @@ -107,11 +108,11 @@ func (b binary) ext() string { } func (b binary) url() string { - return fmt.Sprintf("https://github.com/k0sproject/k0s/releases/download/v%s/k0s-v%s-%s%s", b.version, b.version, b.arch, b.ext()) + return fmt.Sprintf("https://github.com/k0sproject/k0s/releases/download/v%s/k0s-v%s-%s%s", strings.TrimPrefix(b.version, "v"), strings.TrimPrefix(b.version, "v"), b.arch, b.ext()) } func (b binary) downloadTo(path string) error { - log.Infof("downloading k0s version %s binary for %s-%s", b.version, b.os, b.arch) + log.Infof("downloading k0s version %s binary for %s-%s from %s", b.version, b.os, b.arch, b.url()) var err error diff --git a/pkg/apis/k0sctl.k0sproject.io/v1beta1/cluster/k0s.go b/pkg/apis/k0sctl.k0sproject.io/v1beta1/cluster/k0s.go index 6e12b3d8..1aad4693 100644 --- a/pkg/apis/k0sctl.k0sproject.io/v1beta1/cluster/k0s.go +++ b/pkg/apis/k0sctl.k0sproject.io/v1beta1/cluster/k0s.go @@ -105,6 +105,10 @@ func (k *K0s) validateMinDynamic() func(interface{}) error { // SetDefaults (implements defaults Setter interface) defaults the version to latest k0s version func (k *K0s) SetDefaults() { + if k.Version != "" { + return + } + latest, err := version.LatestReleaseByPrerelease(k0sctl.IsPre() || k0sctl.Version == "0.0.0") if err == nil { k.Version = latest.String()