-
Notifications
You must be signed in to change notification settings - Fork 211
rust/treefile: support templating of treefile variables #5392
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
base: main
Are you sure you want to change the base?
Conversation
|
Skipping CI for Draft Pull Request. |
This will allow us to do something like:
```
variables:
id: "fedora"
releasever: "42"
osversion: "${id}-${releasever}"
```
Which can definitely be useful in certain situations.
Once the previous commit gets approved we can drop these debugging statements.
750434e to
03e478a
Compare
|
opened as draft to gather feedback on the implementation. still learning rust and not confident in everything I'm doing. |
|
Ask seems reasonable, though how about we structure it differently so it's instead keyed into the include mechanism, where vars in included manifests could be templated using vars defined in higher level manifests. So e.g. in your example, That naturally also allows "higher-level templating" where templated vars could themselves use templated vars, which would be pretty hard to do non-hackily I think using the current approach. |
That seems reasonable but I kind of think it's an arbitrary limitation. For example, where I wanted to use this is shown in coreos/fedora-coreos-config@54d81e6 in which case one of the vars would have been specified in a higher level manifest, but the other one was just defined.
ehh. I did think about the "templated vars could themselves use templated vars" use case but decided to cut myself off yesterday before I spent too much time on it. The idea I had there was some form of calling
In fact recursion in mind is part of the reason I convert Should I pursue that? |
Though does that limit you in any way? Especially if you're dealing with conditionals, it's exactly in lower-level shared manifests that you would use them.
I thought about exactly this and didn't like how that would work, hence the "non-hackily" comment. :) Not strongly opposed to be clear, but also it's not clear to me we actually need that logic anyway vs making it include-based. But actually... I think doing it include-based is probably the only sane choice because of how it plays into conditional includes. Those are evaluated at parsing time using the vars found so far, and so you wouldn't be able to use a templated var in your conditional include conditions if they're only processed at the end. |
|
No opposition to this in principle however I am medium-strongly of the opinion that in the And as we go towards container-native builds I think We could namespace this like And we should definitely streamline a conditional (like what exists in fedora rpm macros) to do the common thing like |
Yup, we already do this in the node image: https://github.com/openshift/os/blob/4f1036bd11949b5901f523029abf899fd3b5673d/build-node-image.sh#L38 And it would make sense to do this in FCOS too. |
| // We allow our base variables to also be templated to allow | ||
| // for substitution so let's process any substitutions in those | ||
| // first. | ||
| fn process_base_vars( |
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 draft PR is totally fine but it'd be helpful to have unit tests just to help understand what this looks like.
|
I probably won't be able to get back to this until mid June since I've got some travel coming up and some prep to do for that. |
This will allow us to do something like:
Which can definitely be useful in certain situations.