@@ -21,7 +21,8 @@ import (
2121 k0sversion "github.com/k0sproject/version"
2222 embeddedclusterv1beta1 "github.com/replicatedhq/embedded-cluster-operator/api/v1beta1"
2323 "github.com/sirupsen/logrus"
24- "sigs.k8s.io/yaml"
24+ "gopkg.in/yaml.v2"
25+ k8syaml "sigs.k8s.io/yaml"
2526
2627 "github.com/replicatedhq/embedded-cluster/pkg/addons"
2728 "github.com/replicatedhq/embedded-cluster/pkg/customization"
@@ -43,7 +44,7 @@ func ReadConfigFile(cfgPath string) (*v1beta1.Cluster, error) {
4344 return nil , fmt .Errorf ("unable to read current config: %w" , err )
4445 }
4546 var cfg v1beta1.Cluster
46- if err := yaml .Unmarshal (data , & cfg ); err != nil {
47+ if err := k8syaml .Unmarshal (data , & cfg ); err != nil {
4748 return nil , fmt .Errorf ("unable to unmarshal current config: %w" , err )
4849 }
4950 return & cfg , nil
@@ -280,12 +281,12 @@ func UpdateHelmConfigs(cfg *v1beta1.Cluster, opts ...addons.Option) error {
280281 return fmt .Errorf ("invalid cluster configuration" )
281282 }
282283 currentSpec := cfg .Spec .K0s .Config
283- configString , err := yaml .Marshal (currentSpec )
284+ configString , err := k8syaml .Marshal (currentSpec )
284285 if err != nil {
285286 return fmt .Errorf ("unable to marshal helm config: %w" , err )
286287 }
287288 k0s := k0sconfig.ClusterConfig {}
288- if err := yaml .Unmarshal (configString , & k0s ); err != nil {
289+ if err := k8syaml .Unmarshal (configString , & k0s ); err != nil {
289290 return fmt .Errorf ("unable to unmarshal k0s config: %w" , err )
290291 }
291292 opts = append (opts , addons .WithConfig (k0s ))
@@ -302,12 +303,12 @@ func UpdateHelmConfigs(cfg *v1beta1.Cluster, opts ...addons.Option) error {
302303 }
303304
304305 // marshal and unmarshal to convert key names from struct tags
305- newClusterExtensionsBytes , err := yaml .Marshal (newClusterExtensions )
306+ newClusterExtensionsBytes , err := k8syaml .Marshal (newClusterExtensions )
306307 if err != nil {
307308 return fmt .Errorf ("unable to marshal new cluster extensions: %w" , err )
308309 }
309310 newClusterExtensionsMap := dig.Mapping {}
310- if err := yaml .Unmarshal (newClusterExtensionsBytes , & newClusterExtensionsMap ); err != nil {
311+ if err := k8syaml .Unmarshal (newClusterExtensionsBytes , & newClusterExtensionsMap ); err != nil {
311312 return fmt .Errorf ("unable to unmarshal new cluster extensions: %w" , err )
312313 }
313314
@@ -333,7 +334,7 @@ func ApplyEmbeddedUnsupportedOverrides(config *v1beta1.Cluster, embconfig string
333334 if embconfig == "" {
334335 return nil
335336 }
336- newConfigBytes , err := yaml .Marshal (config .Spec .K0s . Config )
337+ newConfigBytes , err := yaml .Marshal (config .Spec .K0s )
337338 if err != nil {
338339 return fmt .Errorf ("unable to marshal original cluster config: %w" , err )
339340 }
@@ -353,11 +354,11 @@ func ApplyEmbeddedUnsupportedOverrides(config *v1beta1.Cluster, embconfig string
353354 if err != nil {
354355 return fmt .Errorf ("unable to convert patched configuration to json: %w" , err )
355356 }
356- var newK0sConfig dig. Mapping
357- if err := yaml .Unmarshal (newConfigBytes , & newK0sConfig ); err != nil {
357+ var newK0sConfig cluster. K0s
358+ if err := k8syaml .Unmarshal (newConfigBytes , & newK0sConfig ); err != nil {
358359 return fmt .Errorf ("unable to unmarshal patched cluster config: %w" , err )
359360 }
360- config .Spec .K0s . Config = newK0sConfig
361+ config .Spec .K0s = & newK0sConfig
361362 return nil
362363}
363364
0 commit comments