Skip to content

Commit 995dc83

Browse files
authored
Fix OS detection override for missing or incomplete os-release file (#290)
Signed-off-by: Kimmo Lehto <[email protected]>
1 parent 97a1036 commit 995dc83

File tree

4 files changed

+10
-7
lines changed

4 files changed

+10
-7
lines changed

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ require (
1717
github.com/gofrs/uuid v4.0.0+incompatible // indirect
1818
github.com/hashicorp/go-version v1.3.0
1919
github.com/k0sproject/dig v0.2.0
20-
github.com/k0sproject/rig v0.4.6
20+
github.com/k0sproject/rig v0.4.7
2121
github.com/logrusorgru/aurora v2.0.3+incompatible
2222
github.com/masterzen/simplexml v0.0.0-20190410153822-31eea3082786 // indirect
2323
github.com/masterzen/winrm v0.0.0-20210623064412-3b76017826b0 // indirect
@@ -39,13 +39,13 @@ require (
3939
)
4040

4141
require (
42+
github.com/alessio/shellescape v1.4.1
4243
github.com/go-ozzo/ozzo-validation/v4 v4.3.0
4344
github.com/go-playground/validator/v10 v10.9.0
4445
)
4546

4647
require (
4748
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d // indirect
48-
github.com/alessio/shellescape v1.4.1 // indirect
4949
github.com/asaskevich/govalidator v0.0.0-20200108200545-475eaeb16496 // indirect
5050
github.com/cpuguy83/go-md2man/v2 v2.0.1 // indirect
5151
github.com/davecgh/go-spew v1.1.1 // indirect

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,8 @@ github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1
212212
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
213213
github.com/k0sproject/dig v0.2.0 h1:cNxEIl96g9kqSMfPSZLhpnZ0P8bWXKv08nxvsMHop5w=
214214
github.com/k0sproject/dig v0.2.0/go.mod h1:rBcqaQlJpcKdt2x/OE/lPvhGU50u/e95CSm5g/r4s78=
215-
github.com/k0sproject/rig v0.4.6 h1:3qR0gNmhsa+6XZLYim/4zpN7+bZWLABYHdzBOCPS/54=
216-
github.com/k0sproject/rig v0.4.6/go.mod h1:4FKfoqz5HOE8v8pJ0K8BCvWw3ypB2vJINkAY4P+yTpo=
215+
github.com/k0sproject/rig v0.4.7 h1:ijTypz6X8HwZIpV2csrLTYhtZvpOrYpP3evv08jVwMg=
216+
github.com/k0sproject/rig v0.4.7/go.mod h1:4FKfoqz5HOE8v8pJ0K8BCvWw3ypB2vJINkAY4P+yTpo=
217217
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs=
218218
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8=
219219
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=

phase/detect_os.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ func (p *DetectOS) Title() string {
2727
func (p *DetectOS) Run() error {
2828
return p.Config.Spec.Hosts.ParallelEach(func(h *cluster.Host) error {
2929
if h.OSIDOverride != "" {
30-
log.Infof("%s: overriding OS to %s", h, h.OSIDOverride)
31-
h.OSVersion.ID = h.OSIDOverride
30+
log.Infof("%s: OS ID has been manually set to %s", h, h.OSIDOverride)
3231
}
3332
if err := h.ResolveConfigurer(); err != nil {
3433
p.SetProp("missing-support", h.OSVersion.String())

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ type Host struct {
4242
}
4343

4444
func (h *Host) SetDefaults() {
45+
if h.OSIDOverride != "" {
46+
h.OSVersion = &rig.OSVersion{ID: h.OSIDOverride}
47+
}
48+
4549
_ = defaults.Set(h.Connection)
4650

4751
if h.InstallFlags.Get("--single") != "" && h.InstallFlags.GetValue("--single") != "false" && h.Role != "single" {
@@ -165,7 +169,7 @@ func (h *Host) Protocol() string {
165169

166170
// ResolveConfigurer assigns a rig-style configurer to the Host (see configurer/)
167171
func (h *Host) ResolveConfigurer() error {
168-
bf, err := registry.GetOSModuleBuilder(h.OSVersion)
172+
bf, err := registry.GetOSModuleBuilder(*h.OSVersion)
169173
if err != nil {
170174
return err
171175
}

0 commit comments

Comments
 (0)