Skip to content

Commit 79d76aa

Browse files
authored
Use k0s config create/validate instead of the deprecated subcommands (#294)
1 parent 610682e commit 79d76aa

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,4 +445,4 @@ The version of k0s to deploy. When left out, k0sctl will default to using the la
445445

446446
Embedded k0s cluster configuration. See [k0s configuration documentation](https://docs.k0sproject.io/main/configuration/) for details.
447447

448-
When left out, the output of `k0s default-config` will be used.
448+
When left out, the output of `k0s config create` will be used.

phase/configure_k0s.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,13 @@ func (p *ConfigureK0s) Run() error {
2929
p.SetProp("default-config", true)
3030
leader := p.Config.Spec.K0sLeader()
3131
log.Warnf("%s: generating default configuration", leader)
32-
cfg, err := leader.ExecOutput(leader.Configurer.K0sCmdf("default-config"), exec.Sudo(leader))
32+
33+
var cmd string
34+
if leader.Exec(leader.Configurer.K0sCmdf("config create --help"), exec.Sudo(leader)) == nil {
35+
cmd = leader.Configurer.K0sCmdf("config create")
36+
}
37+
38+
cfg, err := leader.ExecOutput(cmd, exec.Sudo(leader))
3339
if err != nil {
3440
return err
3541
}
@@ -47,7 +53,14 @@ func (p *ConfigureK0s) Run() error {
4753

4854
func (p *ConfigureK0s) validateConfig(h *cluster.Host) error {
4955
log.Infof("%s: validating configuration", h)
50-
output, err := h.ExecOutput(h.Configurer.K0sCmdf(`validate config --config "%s"`, h.K0sConfigPath()), exec.Sudo(h))
56+
var cmd string
57+
if h.Exec(h.Configurer.K0sCmdf("config validate --help"), exec.Sudo(h)) == nil {
58+
cmd = h.Configurer.K0sCmdf(`config validate --config "%s"`, h.K0sConfigPath())
59+
} else {
60+
cmd = h.Configurer.K0sCmdf(`validate config --config "%s"`, h.K0sConfigPath())
61+
}
62+
63+
output, err := h.ExecOutput(cmd, exec.Sudo(h))
5164
if err != nil {
5265
return fmt.Errorf("spec.k0s.config fails validation:\n%s", output)
5366
}

0 commit comments

Comments
 (0)