Skip to content

Commit e68bbb1

Browse files
lacikaaakeyki
authored andcommitted
CB-3928 Store pillar as json instead of yaml
1 parent be6b7e1 commit e68bbb1

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

saltboot/salt.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -305,8 +305,9 @@ func writePillarImpl(pillar SaltPillar, basePath string) (outStr string, err err
305305
return "Failed to create dir " + dir, err
306306
}
307307

308-
yml, _ := yaml.Marshal(pillar.Json)
309-
err = ioutil.WriteFile(file, yml, 0644)
308+
jsonDef := []byte("#!json\n")
309+
jsn, _ := json.MarshalIndent(pillar.Json, "", "\t")
310+
err = ioutil.WriteFile(file, append(jsonDef,jsn...), 0644)
310311
if err != nil {
311312
return "Failed to write to " + file, err
312313
}

saltboot/salt_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ func TestWritePillar(t *testing.T) {
217217
t.Errorf("error occurred during write %s", err)
218218
}
219219

220-
expected := "key: value\n"
220+
expected := "#!json\n{\n\t\"key\": \"value\"\n}"
221221
content, _ := ioutil.ReadFile(tempDirName + "/srv/pillar" + pillar.Path)
222222
if string(content) != expected {
223223
t.Errorf("yml content not match %s == %s", expected, string(content))

0 commit comments

Comments
 (0)