Can we compute env in shell
kindermax opened this issue · 2 comments
kindermax commented
I am asking about the ability to compute env vars before command run. This is kinda makefile
behavior.
For example, calculate a hash from the file, and expose it as MY_TAG
and use it as a tag for the image.
cat myfile.txt | base64 -
I have
image=myimage:
tags: ['{env.MY_TAG}']
I would like to note that it would be great to do it in dobi
and not outside of it
For example this is not desired:
MY_TAG=$(cat myfile.txt | base64 -) dob myimage:pull
dnephin commented
Yes, this is supported using the :capture()
task of a job resource: http://dnephin.github.io/dobi/tasks.html#job-tasks
There is an example here: https://github.com/dnephin/dobi/blob/master/examples/env-vars/dobi.yaml
I think for your case it would be something like this:
image=bash:
image: bash
tags: [5]
pull: once
job=base64:
use: bash
# probably a `mounts:` here as well to make the file available to this container
command: bash -c 'cat myfile.txt | base64 -'
image=myimage:
tags: ['{env.MY_TAG}']
depends:
- base64:capture(MY_TAG)
kindermax commented
Got the idea, thank you for your quick response!