1
0
mirror of https://github.com/getsops/sops.git synced 2026-02-05 12:45:21 +01:00

outputs: add trailing \n at the end of json files

Signed-off-by: Sebastien Duthil <duthils@duthils.net>
This commit is contained in:
Sebastien Duthil
2024-03-31 17:18:05 +02:00
parent 422c3974de
commit fa545b142d
3 changed files with 14 additions and 6 deletions

View File

@@ -1168,7 +1168,8 @@ bar: |-
r#"{
"foo": "bar",
"bar": "baz\nbam"
}"#
}
"#
);
}

View File

@@ -326,6 +326,7 @@ func (store *Store) EmitEncryptedFile(in sops.Tree) ([]byte, error) {
if err != nil {
return nil, fmt.Errorf("Error marshaling to json: %s", err)
}
out = append(out, '\n')
return out, nil
}
@@ -336,6 +337,7 @@ func (store *Store) EmitPlainFile(in sops.TreeBranches) ([]byte, error) {
if err != nil {
return nil, fmt.Errorf("Error marshaling to json: %s", err)
}
out = append(out, '\n')
return out, nil
}

View File

@@ -34,7 +34,8 @@ func TestDecodeJSON(t *testing.T) {
}
}
}
}`
}
`
expected := sops.TreeBranch{
sops.TreeItem{
Key: "glossary",
@@ -312,7 +313,8 @@ func TestEncodeJSONArrayOfObjects(t *testing.T) {
},
2
]
}`
}
`
store := Store{
config: config.JSONStoreConfig{
Indent: -1,
@@ -446,7 +448,8 @@ func TestIndentTwoSpaces(t *testing.T) {
},
2
]
}`
}
`
store := Store{
config: config.JSONStoreConfig{
Indent: 2,
@@ -488,7 +491,8 @@ func TestIndentDefault(t *testing.T) {
},
2
]
}`
}
`
store := Store{
config: config.JSONStoreConfig{
Indent: -1,
@@ -530,7 +534,8 @@ func TestNoIndent(t *testing.T) {
},
2
]
}`
}
`
store := Store{
config: config.JSONStoreConfig{
Indent: 0,