geofffranks / spruce

A BOSH template merge tool
MIT License
426 stars 77 forks source link

How to Join string and file contents together #338

Closed omieee closed 2 years ago

omieee commented 3 years ago

Hi, I want to join the string and contents of a file together and tried the following.

source: data:text//plain;base64,(( file "path-of-already-converted-base64-file" ))

The above doesn't work whereas if I just remove the static string part it works

source: (( file "path-of-already-converted-base64-file" ))

How can I get the result in following format:

source: data:text/plain;base64,BASE_64_ENCODED_FILE_DATA_HERE

I am using spruce merge abc.yaml which contains the above code

geofffranks commented 3 years ago

Something like this should work:

data: (( file "path-to-file" ))
source: (( concat "data:text/plain;base64," data ))
geofffranks commented 3 years ago

You should be able to use concat for that as well, just losing both files int separate references first. If needed you can separate them with a literal “\n” in the concat call

Sent from my iPhone

On May 21, 2021, at 4:13 AM, omieee-work @.***> wrote:

 Thank you, it worked. There is one more query i am trying to load two files in one file ex.

pre-deployment.yaml contents

apiVersion: v1 kind: List metadata: name: name-here annotations: version: (( grab $TRAVIS_COMMIT || "dev" )) items: (( file "file-path.yaml" )) (( file "file-path2.yaml" )) After this I run spruce merge pre-deployment.yaml > output.yaml

And i get following error

1 error(s) detected: $.items: file operator requires exactly one string or reference argument — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

geofffranks commented 2 years ago

closing as stale