Skip to content

Commit e6e8d94

Browse files
authored
Fix always overwriting k0s version with latest version (#340)
* Fix k0s version defaulting to latest to not override existing value * Show download url in debug * Why is this necessary?
1 parent 1767917 commit e6e8d94

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

phase/download_binaries.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"io"
66
"net/http"
77
"os"
8+
"strings"
89

910
"github.com/k0sproject/k0sctl/cache"
1011
"github.com/k0sproject/k0sctl/pkg/apis/k0sctl.k0sproject.io/v1beta1"
@@ -107,11 +108,11 @@ func (b binary) ext() string {
107108
}
108109

109110
func (b binary) url() string {
110-
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())
111+
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())
111112
}
112113

113114
func (b binary) downloadTo(path string) error {
114-
log.Infof("downloading k0s version %s binary for %s-%s", b.version, b.os, b.arch)
115+
log.Infof("downloading k0s version %s binary for %s-%s from %s", b.version, b.os, b.arch, b.url())
115116

116117
var err error
117118

pkg/apis/k0sctl.k0sproject.io/v1beta1/cluster/k0s.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ func (k *K0s) validateMinDynamic() func(interface{}) error {
105105

106106
// SetDefaults (implements defaults Setter interface) defaults the version to latest k0s version
107107
func (k *K0s) SetDefaults() {
108+
if k.Version != "" {
109+
return
110+
}
111+
108112
latest, err := version.LatestReleaseByPrerelease(k0sctl.IsPre() || k0sctl.Version == "0.0.0")
109113
if err == nil {
110114
k.Version = latest.String()

0 commit comments

Comments
 (0)