Skip to content

Commit 52bd6b1

Browse files
authored
Use the latest/stable.txt from docs for k0s version discovery (#347)
* Use the latest/stable.txt from docs for k0s version discovery Signed-off-by: Kimmo Lehto <[email protected]>
1 parent 0cd7a7e commit 52bd6b1

File tree

4 files changed

+8
-26
lines changed

4 files changed

+8
-26
lines changed

go.mod

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ require (
4242
github.com/alessio/shellescape v1.4.1
4343
github.com/go-ozzo/ozzo-validation/v4 v4.3.0
4444
github.com/go-playground/validator/v10 v10.9.0
45-
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510
46-
github.com/k0sproject/version v0.1.3
45+
github.com/k0sproject/version v0.3.0
4746
)
4847

4948
require (

go.sum

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,6 @@ github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hf
181181
github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
182182
github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
183183
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
184-
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4=
185-
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ=
186184
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
187185
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
188186
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
@@ -230,8 +228,8 @@ github.com/k0sproject/dig v0.2.0 h1:cNxEIl96g9kqSMfPSZLhpnZ0P8bWXKv08nxvsMHop5w=
230228
github.com/k0sproject/dig v0.2.0/go.mod h1:rBcqaQlJpcKdt2x/OE/lPvhGU50u/e95CSm5g/r4s78=
231229
github.com/k0sproject/rig v0.4.8 h1:y9emsvDVfmG+Y7V6oPikB5nqDkivluEXkcb9VWn7VXc=
232230
github.com/k0sproject/rig v0.4.8/go.mod h1:X6sz7o4jBe3I3rpLL/eihWxTyL39hsxYxcGlpT+tTpA=
233-
github.com/k0sproject/version v0.1.3 h1:md6jfYT28VtUGe7qE8Fd/sxvtaCnlnLR3t0mnRneyIk=
234-
github.com/k0sproject/version v0.1.3/go.mod h1:oEjuz2ItQQtAnGyRgwEV9m5R6/9rjoFC6EiEEzbkFdI=
231+
github.com/k0sproject/version v0.3.0 h1:6HAn8C29+WVksGCzbQvQ9feEJpUZ0iHD8GebIQMiftQ=
232+
github.com/k0sproject/version v0.3.0/go.mod h1:oEjuz2ItQQtAnGyRgwEV9m5R6/9rjoFC6EiEEzbkFdI=
235233
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs=
236234
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8=
237235
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=

integration/github/github.go

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -42,35 +42,20 @@ func (r *Release) IsNewer(b string) bool {
4242

4343
// LatestK0sBinaryURL returns the url for the latest k0s release by arch and os
4444
func LatestK0sBinaryURL(arch, osKind string, preok bool) (string, error) {
45-
r, err := k0sversion.LatestReleaseByPrerelease(preok)
45+
r, err := k0sversion.LatestByPrerelease(preok)
4646
if err != nil {
4747
return "", err
4848
}
49-
50-
for _, a := range r.Assets {
51-
if !strings.Contains(a.Name, "-"+arch) {
52-
continue
53-
}
54-
55-
if strings.HasSuffix(a.Name, ".exe") {
56-
if osKind == "windows" {
57-
return a.URL, nil
58-
}
59-
} else if osKind != "windows" {
60-
return a.URL, nil
61-
}
62-
}
63-
64-
return "", fmt.Errorf("failed to find a k0s release")
49+
return r.DownloadURL(osKind, arch), nil
6550
}
6651

6752
// LatestK0sVersion returns the latest k0s version number (without v prefix)
6853
func LatestK0sVersion(preok bool) (string, error) {
69-
r, err := k0sversion.LatestReleaseByPrerelease(preok)
54+
r, err := k0sversion.LatestByPrerelease(preok)
7055
if err != nil {
7156
return "", err
7257
}
73-
return strings.TrimPrefix(r.TagName, "v"), nil
58+
return strings.TrimPrefix(r.String(), "v"), nil
7459
}
7560

7661
// LatestRelease returns the semantically sorted latest k0sctl version from github

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ func (k *K0s) SetDefaults() {
109109
return
110110
}
111111

112-
latest, err := version.LatestReleaseByPrerelease(k0sctl.IsPre() || k0sctl.Version == "0.0.0")
112+
latest, err := version.LatestByPrerelease(k0sctl.IsPre() || k0sctl.Version == "0.0.0")
113113
if err == nil {
114114
k.Version = latest.String()
115115
k.Metadata.VersionDefaulted = true

0 commit comments

Comments
 (0)