Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow empty maps for yaml (#907) #908

Merged
merged 3 commits into from Mar 22, 2022

Conversation

ikedam
Copy link
Contributor

@ikedam ikedam commented Jul 24, 2021

Fixes #907

This allows following usage in sops-3.7.x, just like in sops-3.6.x and earlier.

echo '{}' | sops --input-type yaml --output-type yaml -e /dev/stdin | sops --input-type yaml --output-type yaml -d /dev/stdin

assert.Nil(t, err)
assert.Equal(t, "{}\n", string(bytes))
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fails like this:

--- FAIL: TestEmpty3 (0.00s)
    store_test.go:206: 
                Error Trace:    store_test.go:206
                Error:          Expected nil, but got: &errors.errorString{s:"Error marshaling to yaml: yaml: expected SCALAR, SEQUENCE-START, MAPPING-START, or ALIAS, but got document end"}
                Test:           TestEmpty3
    store_test.go:207: 
                Error Trace:    store_test.go:207
                Error:          Not equal: 
                                expected: "{}\n"
                                actual  : ""
                            
                                Diff:
                                --- Expected
                                +++ Actual
                                @@ -1,2 +1 @@
                                -{}
                                 
                Test:           TestEmpty3
FAIL
coverage: 69.5% of statements
FAIL    go.mozilla.org/sops/v3/stores/yaml      0.066s
FAIL

I wanted to demonstrate that in CI, but the test failed fast for #882.

@ikedam ikedam marked this pull request as ready for review July 24, 2021 06:48
@@ -361,11 +361,7 @@ func (store *Store) EmitPlainFile(branches sops.TreeBranches) ([]byte, error) {
mapping.Kind = yaml.MappingNode
// Marshal branch to global mapping node
store.appendTreeBranch(branch, &mapping)
if len(mapping.Content) == 0 {
doc.HeadComment = mapping.HeadComment
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This branch always cause an error as far as I know, and is useless.

@felixfontein
Copy link
Contributor

felixfontein commented Jul 24, 2021

Right now this PR is needed, but once go-yaml/yaml#690 is merged it has to be reverted. (Depends on what we actually want...)

@felixfontein
Copy link
Contributor

(You probably have to close+reopen to re-run CI.)

@felixfontein
Copy link
Contributor

@ajvb could you please re-run CI for this one (probably closing+reopening is required)? I think it's still ready for merging, but it would be good to see a new test run :)

@ajvb ajvb added this to the v3.7.3 milestone Mar 3, 2022
@ikedam
Copy link
Contributor Author

ikedam commented Mar 5, 2022

Merged latest develop.

@ajvb ajvb merged commit e2c0479 into getsops:develop Mar 22, 2022
@felixfontein
Copy link
Contributor

@ikedam thanks for fixing this!
@ajvb thanks for reviewing and merging!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants