use yaml unmarshaller instead of json for cloud config

This commit is contained in:
Sebastian Florek 2025-02-07 15:24:13 +01:00
parent bcea090a11
commit f07cf1d24f
No known key found for this signature in database
GPG Key ID: DBC7C083B0200A0F
2 changed files with 8 additions and 8 deletions

View File

@ -1,8 +1,8 @@
package v1alpha2
type CloudConfig struct {
Users Users `json:"users,omitempty"`
Plural Plural `json:"plural,omitempty"`
Users Users `json:"users,omitempty" yaml:"users,omitempty"`
Plural Plural `json:"plural,omitempty" yaml:"plural,omitempty"`
}
type Users []User
@ -16,8 +16,8 @@ func (in Users) FirstUser() *User {
}
type User struct {
Name string `json:"name"`
Passwd string `json:"passwd"`
Name string `json:"name" yaml:"name"`
Passwd string `json:"passwd" yaml:"passwd"`
}
func (in *User) GetName() *string {
@ -37,6 +37,6 @@ func (in *User) GetPasswd() *string {
}
type Plural struct {
Token string `json:"token"`
URL string `json:"url"`
Token string `json:"token" yaml:"token"`
URL string `json:"url" yaml:"url"`
}

View File

@ -18,7 +18,6 @@ package controllers
import (
"context"
"encoding/json"
"fmt"
"time"
@ -40,6 +39,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/predicate"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
"sigs.k8s.io/yaml"
osbuilder "github.com/kairos-io/osbuilder/api/v1alpha2"
consoleclient "github.com/kairos-io/osbuilder/pkg/client"
@ -552,7 +552,7 @@ func (r *OSArtifactReconciler) getCloudConfig(ctx context.Context, artifact *osb
return config, fmt.Errorf("could not find key %s in secret %s", artifact.Spec.CloudConfigRef.Key, artifact.Spec.CloudConfigRef.Name)
}
if err := json.Unmarshal(configBytes, config); err != nil {
if err := yaml.Unmarshal(configBytes, config); err != nil {
return config, err
}