diff --git a/config/cluster/k0s.go b/config/cluster/k0s.go index acdfd8ce..3b690e47 100644 --- a/config/cluster/k0s.go +++ b/config/cluster/k0s.go @@ -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 diff --git a/phase/configure_k0s.go b/phase/configure_k0s.go index d4ab3ce4..44d677cb 100644 --- a/phase/configure_k0s.go +++ b/phase/configure_k0s.go @@ -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 @@ -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