Skip to content

Commit

Permalink
Do it all in the phase
Browse files Browse the repository at this point in the history
  • Loading branch information
kke committed Nov 3, 2021
1 parent 10499fb commit f22fc40
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
10 changes: 0 additions & 10 deletions config/cluster/k0s.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,6 @@ func (k *K0s) SetDefaults() {
}

k.Version = strings.TrimPrefix(k.Version, "v")

if len(k.Config) > 0 {
if k.Config.DigString("apiVersion") == "" {
k.Config["apiVersion"] = "k0s.k0sproject.io/v1beta1"
}

if k.Config.DigString("kind") == "" {
k.Config["kind"] = "ClusterConfig"
}
}
}

// GenerateToken runs the k0s token create command
Expand Down
12 changes: 8 additions & 4 deletions phase/configure_k0s.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,6 @@ func addUnlessExist(slice *[]string, s string) {

func (p *ConfigureK0s) configFor(h *cluster.Host) (string, error) {
cfg := p.Config.Spec.K0s.Config.Dup()
err := defaults.Set(cfg)
if err != nil {
return "", err
}

var sans []string

Expand Down Expand Up @@ -182,6 +178,14 @@ func (p *ConfigureK0s) configFor(h *cluster.Host) (string, error) {
cfg.DigMapping("spec", "storage", "etcd")["peerAddress"] = addr
}

if _, ok := cfg["apiVersion"]; !ok { {
cfg["apiVersion"] = "k0s.k0sproject.io/v1beta1"
}

if _, ok := cfg["kind"]; !ok { {
cfg["kind"] = "ClusterConfig"
}

c, err := yaml.Marshal(cfg)
if err != nil {
return "", err
Expand Down

0 comments on commit f22fc40

Please sign in to comment.