-
-
Notifications
You must be signed in to change notification settings - Fork 72
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
[Suggestion] Flexible Runtime Variable Management for Configurations #466
Comments
I'm having trouble picturing what your proposal would look like. Can you provide an example?
You need to tag them so timoni knows which Cue values it should inject vs. being handled by the normal Cue functionality.
This kind of makes sense. AFAIK you can't use Cue itself to manage the values in the annotations. I don't see how this would work though. You still need to have some identifier to map an outside value to the Cue config value.
This is really the responsibility of Cue which is good. You can always set the runtime variable annotated values via normal Cue unification. This is what I do in the testing phase. I can agree though that testing the actual runtime injection is a little annoying via the environment variables.
What would this enable in Timoni itself? You mean like applying values to the cluster? I don't know if this is something Timoni would actually use.
I like this part! |
@salotz , The proposal would look like this: (Taking the example from the proposal message above) # The key is leveraging the "spf13/viper" library to interpret "values" from various sources
# Environment variables feed values by naming convention (not by users maintaining it manually via CUE tags)
export TIMONI_MYAPP_VALUES_FRONTEND_IMAGE_REPOSITORY="quay.io/salotz/myapp-frontend"
export TIMONI_MYAPP_VALUES_FRONTEND_IMAGE_TAG="latest"
# Also additional values provided via databases (e.g. etcd, consul, vault, etc.)
timoni apply ... \
--values="values.json" \
--values="etcd://company.production.etcd:2379/" \
--values="consul://myapp.consul:8500/"
# Alternatively we could introduce new CLI flags for different configuration source types
timoni apply ... \
--values="values.toml" \
--values-etcd="http://myapp.etcd:2379/" \
--values-consul="http://myapp.consul:8500/" The scope of the proposal is opens up a whole new world of possibilities far beyond environment variable tagging in CUE. For an example of "spf13/viper" environment variable convention, see how it is used by Coder configurations (an adopter of spf13/viper). The overall idea is something like this: graph LR
M[apply.go<br/>build.go] --> V
B[bundle_apply.go<br/>bundle_build.go<br/>bundle_vet.go] --> V
V[spf13/viper] --> |Produces the final values going into manifests|C[Cue]
subgraph timoni
M
B
V
end
E[Environment variables] -.-> V
F["Config files (YAML, JSON, TOML)"] -.-> V
D["Database (etcd, consul, vault, etc.)"] -.-> V
The focus is on the "values" part that is going into CUE. @salotz , Is there a way to make this proposal more concrete? |
The reason I'm following on is I do think there is something interesting here. However, I feel there is some general confusion about the utility of Cue and how Timoni interacts with that. Most of what you presented are features which would be added to the CUE lang tool chain itself and not Timoni. CUE is responsible for integrating configuration data from many different sources. This is similar to viper, but with a different set of supported inputs and with a general lack of network awareness.
The only thing Timoni does on top of CUE is add the runtime injection of config values which would not be used with the Where I think your proposal is interesting is specifically for runtime variable injection. Runtime value injection is something that the So I don't think you are going to replace things like:
In your Timoni CUE. However, what I think could be improved is the interpretation of Currently this annotated value can be set by the environment variable Let me take an aside to demonstrate your point, for testing bundles that take runtime injected values. To test them I use environment variables which I have part of my project scripting. I do this while using a (set -o allexport && source .env && set +o allexport && \
timoni bundle vet -f bundle.cue --runtime-from-env) It would be very nice to be able to just do something this: timoni bundle vet -f bundle.cue --runtime-url .env This is where I think viper comes in since it could be the engine for reading the runtime settings. I hope that made sense! One more thing is that I also do like having the environment variables be implicitly namespaced based on the bundle name and a Timoni prefix. That is for your example:
Having the environment variable mapped to this annotation be |
Problem Being Solved For
Currently, environment variables can only be assigned to values at the bundle level, not the module level. While it is possible to assign Timoni runtime tags to module-level values for setting them via environment variables, this process can be cumbersome and error-prone.
For example:
And corresponding values:
This approach requires developers to explicitly map each value to a unique environment variable, introducing complexity and increasing the risk of naming collisions.
Proposal
To simplify configuration management and expand its flexibility, Timoni should integrate a configuration management library like
spf13/viper
(or an equivalent). This enhancement would enable users to manage both module-level and bundle-level values effortlessly.Key Benefits:
This approach would not only simplify the developer experience but also unlock new possibilities, such as:
By adopting a widely-used library like Viper, Timoni can deliver a powerful and developer-friendly configuration experience while maintaining compatibility with existing setups.
The text was updated successfully, but these errors were encountered: