Skip to content

Commit f7d14c6

Browse files
committed
return mutated ignition as json
1 parent 28b7ac6 commit f7d14c6

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

internal/controller/helper.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ limitations under the License.
1717
package controller
1818

1919
import (
20+
"encoding/json"
2021
"fmt"
2122

2223
config "github.com/coreos/ignition/v2/config/v3_4"
2324
"github.com/coreos/ignition/v2/config/v3_4/types"
24-
"gopkg.in/yaml.v3"
2525
"sigs.k8s.io/controller-runtime/pkg/client"
2626
)
2727

@@ -38,15 +38,15 @@ func modifyIgnitionConfig(ignitionData []byte, effectiveHostname string) ([]byte
3838
hostnameFound := false
3939
for i, file := range cfg.Storage.Files {
4040
if file.Path == "/etc/hostname" {
41-
source := "data:," + effectiveHostname + "\n"
41+
source := "data:," + effectiveHostname + "%0A"
4242
cfg.Storage.Files[i].Contents.Source = &source
4343
hostnameFound = true
4444
break
4545
}
4646
}
4747

4848
if !hostnameFound {
49-
source := "data:," + effectiveHostname + "\n"
49+
source := "data:," + effectiveHostname + "%0A"
5050
newFile := types.File{
5151
Node: types.Node{
5252
Path: "/etc/hostname",
@@ -64,7 +64,7 @@ func modifyIgnitionConfig(ignitionData []byte, effectiveHostname string) ([]byte
6464
cfg.Storage.Files = append(cfg.Storage.Files, newFile)
6565
}
6666

67-
serialized, err := yaml.Marshal(&cfg)
67+
serialized, err := json.Marshal(&cfg)
6868
if err != nil {
6969
return []byte(""), fmt.Errorf("failed to serialize Ignition config: %v", err)
7070
}

0 commit comments

Comments
 (0)