-
Notifications
You must be signed in to change notification settings - Fork 3
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
Use JSON import for environment variables #64
Use JSON import for environment variables #64
Conversation
e6653b2
to
4af70a5
Compare
The env can be provided as a JSON list `[{"name": "PORT", "value": "8080"}]`. The `dict2items` filter provided by ansible is _almost_ what we want, but it keeps the value original types (a boolean is kept as a boolean in the JSON value). Since environment variables are strings and `clever-tools` does not want to make the implicit coercion for us, we need to do it ourselves.
4af70a5
to
244339e
Compare
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
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.
I'd rather have the variable manipulation done outside the template. Its usually better to understand the variable manipulation next to the ansible tasks.
I am sorry but I don't understand this warning. Where do we “escape and transform line breaks into literal |
The escaping was done by the The unescaping is performed by |
Hm, but that's by nature of JSON values. And we were already transforming any values to be a JSON value. So I still don't understand the difference before and after the PR on the values we provide to clever |
1239ed2
to
07df8ca
Compare
The difference is that before this PR, we provide a file With this, PR, |
Using |
07df8ca
to
f4ba8ed
Compare
🤯 indeed very well noted 👌 thanks for the explanation. |
f4ba8ed
to
107eecc
Compare
107eecc
to
d5b5cb1
Compare
Alright! After yesterday i was a bit scared to modify things further, but now it works well, so 🚀 |
This is a fix to an unfortunate bug introduced by #64 because we had a default value set to `None` on the `clever_haskell_entry_point`. Ansible considers `None` as a defined value so the `is defined` condition doesn't match our need
This is a fix to an unfortunate bug introduced by #64 because we had a default value set to `None` on the `clever_haskell_entry_point`. Ansible considers `None` as a defined value so the `is defined` condition doesn't match our need
This is a fix to an unfortunate bug introduced by #64 because we had a default value set to `None` on the `clever_haskell_entry_point`. Ansible considers `None` as a defined value so the `is defined` condition doesn't match our need
This is a fix to an unfortunate bug introduced by #64 because we had a default value set to `None` on the `clever_haskell_entry_point`. Ansible considers `None` as a defined value so the `is defined` condition doesn't match our need
This is a fix to an unfortunate bug introduced by #64 because we had a default value set to `None` on the `clever_haskell_entry_point`. Ansible considers `None` as a defined value so the `is defined` condition doesn't match our need
clever env import
now supports reading a JSON value, a list of{"name": "MY_VAR", "value": "yolo" }
objects.Using JSON instead of an ad-hoc format makes things more robust, especially wrt quotes and newlines. I have tested it on lane-explorer: https://gitlab.in.fretlink.com/fretlink/lane-explorer/-/jobs/156189
The tricky part is that the values need to be provided as strings (as are environment variables, after all). This was done a bit implicitly previously, now this is done explicitly (this also explains why i was not able to use the
dict2items
filter directly.Warning
Before this PR, when we provide an env var containing line breaks, they are escaped and transformed into literal
\n
, that need to be unescaped later. As far as I know, it's only done for the SSH key in ci-commons. With this PR, this step is not useful anymore and can be removed.