-
Notifications
You must be signed in to change notification settings - Fork 602
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
Add limayaml param settings to provisioning script environment #2570
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs docs!
Also wondering if probes
should have access too (they currently don't have access to LIMA_CIDATA_*
variables, I think).
b13d8b1
to
22676c1
Compare
I'm not proud of the hack to make the Anyways, I think the PR is ready for review now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change looks like something I considered before implementing #2498 but ultimately abandoned because it seemed too complex for me. I find it impressive and at the same time feel that it was indeed too challenging for me.
I haven't finished reading the probes
hack yet, but I'll share what I understand so far.
81f7fda
to
b8fcab6
Compare
This change just build on top of #2498, which is still needed so we can use
I've moved the hack to a separate function and added rather verbose documentation about it. It feels kind of too long, but maybe it is useful. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The implementation and comments for prefixExportParam()
made it very clear. Thanks to that, I can suggest a simpler command.
Adding tests to test-misc.yaml
is also very clear and good.
They will be prefixed with `PARAM_`, so `param.FOO` becomes `PARAM_FOO`. This is useful because parameter substitution happens when a template is instantiated, so `[ "{{.Param.ROOTFUL}}" = true ]` becomes `[ "true" = true ]` in the cloud-init-output.log. This mechanism also works better when the parameter contains quotes, which would break a simplistic `FOO="{{.Param.FOO}}"`. Signed-off-by: Jan Dubois <jan.dubois@suse.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
🙏 Thanks! All checks have passed, so I will merge now. |
This is awesome improvement, I wanted to ask how to inject values from the instance yaml to the cloud-init scripts. However the names makes this harder to understand. Maybe rename to: env:
MY_KEY: VALUE
provision:
- mode: system
script: |
#!/bin/bash
echo "MY_KEY" No magic prefix, what you put in env added to the provision scripts. This is also similar to docker/podman --env flag. |
The |
Yes being able to limit the scope is nice. Did you consider something like this? env:
KEY: global
bootEnv:
BOOT_KEY: boot
provision:
- mode: system
script: |
echo $KEY # -> gloabl
echo $BOOT_KEY # -> boot
probes:
- mode: system
script: |
echo $KEY # -> gloabl
echo $BOOT_KEY # -> boot Since all provision steps are run by the same global boot.sh script, we can pass the bootEnv to the scripts by exporting the boot env vars from the script. I did not check how probes are run, but since they are scripts there must be some shell running them and we can modify its environment. |
They will be prefixed with
PARAM_
, soparam.FOO
becomesPARAM_FOO
.This is useful because parameter substitution happens when a template is instantiated, so
[ "{{.Param.ROOTFUL}}" = true ]
becomes[ "true" = true ]
in thecloud-init-output.log
.This mechanism also works better when the parameter contains quotes, which would break a simplistic
FOO="{{.Param.FOO}}"
.Test sample:
Output:
Example of real-life usage (from #2515) will be to replace