Skip to content

The change outputs: add trailing \n at the end of json files that just landed in 3.10.0 is breaking #1825

@matheuscscp

Description

@matheuscscp

Dependabot just ran in fluxcd/kustomize-controller and bumped SOPS from 3.9.4 to 3.10.0:

fluxcd/kustomize-controller#1410

This test is failing:

https://github.com/fluxcd/kustomize-controller/actions/runs/14162921724/job/39671210850?pr=1410#step:10:1611

=== RUN   TestDecryptor_DecryptResource/SOPS-encrypted_Docker_config_Secret
    decryptor_test.go:707: 
        Expected
            <map[string]string | len:1>: {
                ".dockerconfigjson": "ewoJImF1dGhzIjogewoJCSJteS1yZWdpc3RyeS5leGFtcGxlOjUwMDAiOiB7CgkJCSJ1c2VybmFtZSI6ICJ0aWdlciIsCgkJCSJwYXNzd29yZCI6ICJwYXNzMTIzNCIsCgkJCSJlbWFpbCI6ICJ0aWdlckBhY21lLmV4YW1wbGUiLAoJCQkiYXV0aCI6ICJkR2xuWlhJNmNHRnpjekV5TXpRPSIKCQl9Cgl9Cn0K",
            }
        to have {key: value}
            <map[interface {}]interface {} | len:1>: {
                <string>".dockerconfigjson": <string>"ewoJImF1dGhzIjogewoJCSJteS1yZWdpc3RyeS5leGFtcGxlOjUwMDAiOiB7CgkJCSJ1c2VybmFtZSI6ICJ0aWdlciIsCgkJCSJwYXNzd29yZCI6ICJwYXNzMTIzNCIsCgkJCSJlbWFpbCI6ICJ0aWdlckBhY21lLmV4YW1wbGUiLAoJCQkiYXV0aCI6ICJkR2xuWlhJNmNHRnpjekV5TXpRPSIKCQl9Cgl9Cn0=",
            }

The difference between the two values is that the SOPS output now has a trailing \n, while the expected value does not. I traced this behavior change to this commit in SOPS, which was not present in 3.9.4 and has just landed in 3.10.0:

fa545b1

While I can easily fix this test with the diff below, I wanted to let you know of this breaking change.

diff --git a/internal/decryptor/decryptor_test.go b/internal/decryptor/decryptor_test.go
index 5d0895f..ac1dd42 100644
--- a/internal/decryptor/decryptor_test.go
+++ b/internal/decryptor/decryptor_test.go
@@ -704,7 +704,8 @@ func TestDecryptor_DecryptResource(t *testing.T) {
                got, err := d.DecryptResource(secret)
                g.Expect(err).ToNot(HaveOccurred())
                g.Expect(got).ToNot(BeNil())
-               g.Expect(got.GetDataMap()).To(HaveKeyWithValue(corev1.DockerConfigJsonKey, base64.StdEncoding.EncodeToString(plainData)))
+               plainDataWithTrailingNewline := append(plainData, '\n') // https://github.com/getsops/sops/issues/1825
+               g.Expect(got.GetDataMap()).To(HaveKeyWithValue(corev1.DockerConfigJsonKey, base64.StdEncoding.EncodeToString(plainDataWithTrailingNewline)))
        })
 
        t.Run("nil resource", func(t *testing.T) {

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions