Skip to content

Commit

Permalink
Fixed issue where invalid yaml was generated when using files togethe…
Browse files Browse the repository at this point in the history
…r with secretFrom (#221)

Co-authored-by: Devin Stein <devstein@seas.upenn.edu>
  • Loading branch information
christoffer-eide and devstein committed Jan 10, 2024
1 parent bc619b6 commit a018a93
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ksops.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ func generate(raw []byte) (string, error) {

output.Write(data)
// KRM treats will try parse (and fail) empty documents if there is a trailing separator
if i < len(manifest.Files)-1 {
if i < (len(manifest.Files)+len(manifest.SecretFrom))-1 {
output.WriteString("\n---\n")
}
}
Expand Down
6 changes: 6 additions & 0 deletions test/legacy/multiple/generate-resources.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,9 @@ files:
- ./secret-A.enc.yaml
- ./secret-B.enc.yaml
- ./secret-C.enc.yaml
secretFrom:
- metadata:
name: mysecret
type: Opaque
binaryFiles:
- ./secret.enc.yaml
28 changes: 28 additions & 0 deletions test/legacy/multiple/secret.enc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
username: ENC[AES256_GCM,data:wm8jYTk=,iv:uODPx9IQmb2gQi2oZ6gpmIGddMN7n2ogKdweMjIZIHw=,tag:xnfYKwnirnOV3tV7CFvlvA==,type:str]
password: ENC[AES256_GCM,data:Lpu0v6Qjt6wLmYZv,iv:P7kfBIuJ7M86Oh43q9FpUDgUCK4REColGTTFGFdhjD0=,tag:wSNv3kOLhdNxBK0r3MNLpw==,type:str]
sops:
kms: []
gcp_kms: []
azure_kv: []
hc_vault: []
age: []
lastmodified: "2022-12-14T18:15:56Z"
mac: ENC[AES256_GCM,data:mJUZQ0L26QeAkip3WnGxE/p3JAfgLbF5F2MXElcQRLvKberT0cF6MiOXXXCXFyc1/G/HMYVFGMevEuqFEMwAzZCp4oa70KclZTnE3r8/7lmtvNsF+YbLvRRy5Ib5pwpVYBSFp3RNeRHXmw+lUjz2q61DBK40tyHbRrbXvq0ITy4=,iv:shT/5S+8sjj3gdVSYTNX1r0y0db3rNiQ3YIjIP/0BUM=,tag:VPXX7gTNpsnQDe2U++hexA==,type:str]
pgp:
- created_at: "2022-12-14T18:15:50Z"
enc: |
-----BEGIN PGP MESSAGE-----
hQEMAyUpShfNkFB/AQf/eWYqsnyMtmf1DpllbYFgViTaxTfZNbS+qF9BJeGoL/Q4
etjpXqqkl61RBzuLxj7KlM00fFpXCwTLnhaUzGIPaAvojHhk3xIT3lBBci3tshlP
qZ8PVzKIhVfBT8zoZ5hhR5mH7iT0SwZaD6RLepe1ygwXcS33WSf7srvuIydeAaTE
nxOcszcw+1/gZ88rcqmNQ8EnD4gZeswOLQiLOCliHAmZBaW3yybwp3GWbbqiJLYl
RsKCOkIfX0gQVI+BXb8wB1FukXl3ZiefO0zDoTZzV/hP8tq2MEhYyMMb/w/5qJo5
O49kCAo0nItiTFzMI1jKH3GdO9HSdAEvm4RZPGQSEdJeAWyJxw8Hy9HaecQchwCh
PU5nil4v656adnP+gAcmnUvjvq3WQESNkSYqGttXsxCN+0REP0mR2OuaK1LQJkY4
zr6Ky43znNJ33mgVYF1NKKJN00Ip8GF4l/Km24FnvQ==
=4non
-----END PGP MESSAGE-----
fp: FBC7B9E2A4F9289AC0C1D4843D16CEE4A27381B4
unencrypted_regex: ^(apiVersion|metadata|kind|type)$
version: 3.7.2
8 changes: 8 additions & 0 deletions test/legacy/multiple/want.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
apiVersion: v1
data:
secret.enc.yaml: dXNlcm5hbWU6IGFkbWluCnBhc3N3b3JkOiAxZjJkMWUyZTY3ZGYK
kind: Secret
metadata:
name: mysecret
type: Opaque
---
apiVersion: v1
data:
password: MWYyZDFlMmU2N2Rm
username: YWRtaW4=
Expand Down

0 comments on commit a018a93

Please sign in to comment.