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:
@@ -1168,7 +1168,8 @@ bar: |-
|
||||
r#"{
|
||||
"foo": "bar",
|
||||
"bar": "baz\nbam"
|
||||
}"#
|
||||
}
|
||||
"#
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user