Skip to content
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

Configuration templating using environment variables #281

Open
jfroy opened this issue Dec 16, 2024 · 3 comments
Open

Configuration templating using environment variables #281

jfroy opened this issue Dec 16, 2024 · 3 comments
Labels
work completed Work for this has been completed but it may not yet be merged / released
Milestone

Comments

@jfroy
Copy link

jfroy commented Dec 16, 2024

I'm deploying glance to my homelab kubernetes cluster, which I manage with fluxcd and a public GitHub repo. Some of my RSS feeds are private URLs from subscriptions, which means I cannot add them verbatim to the config file, and I'd rather not encrypt the entire config file.

What many other projects with complex config files do is process them through some sort of template engine and import environment variables as template/context variables. Kubernetes secrets can be used as a source of environment variables for pods/containers.

text/template would be more than enough.

@svilenmarkov
Copy link
Member

Hey, thanks for bringing this up. Glance already does have the ability to insert environment variables into the config, though the implementation is on a per-field basis and I haven't added it for the RSS feed URLs yet. It does not rely on text/template but you would be able to do this:

- type: rss
  feeds:
    - url: ${MY_FEED_URL}
    - url: ${MY_OTHER_FEED_URL}

Would that suffice?

@jfroy
Copy link
Author

jfroy commented Dec 16, 2024

Hey, thanks for bringing this up. Glance already does have the ability to insert environment variables into the config, though the implementation is on a per-field basis and I haven't added it for the RSS feed URLs yet. It does not rely on text/template but you would be able to do this:

- type: rss
  feeds:
    - url: ${MY_FEED_URL}
    - url: ${MY_OTHER_FEED_URL}

Would that suffice?

It would suffice for my immediate need, but I wonder if people are going to continue coming up with other fields. A practical answer of course is to just keep adding support as demand is expressed, but it feels adding a quick Go template render to the config code would solve it once and for all.

@svilenmarkov
Copy link
Member

svilenmarkov commented Dec 16, 2024

Edit: Ignore the below, I've changed it so you can insert them anywhere in the config with the ${} syntax, no need for me to implement them on individual fields anymore. Thanks for idea.

it feels adding a quick Go template render to the config code would solve it once and for all.

I entirely agree that it would be a more future-proof approach, though I plan on using html/template for a new custom API widget where the user can provide the template in their glance.yml, so a simple pre-parse of the entire config would clash with it.

Admittedly, I underestimated the number of places people would like to be able to use environment variables in, which is why I was adding that ability sparingly. For the time being I'll be more mindful about this and try to add it to more fields, though if it does become a pain point in the future I'll think of something to make it globally available by default.

PS: note to self: I guess I could just change the default template delimiters to something other than {{ }}.

@svilenmarkov svilenmarkov added this to the v0.7.0 milestone Dec 16, 2024
@svilenmarkov svilenmarkov added the work completed Work for this has been completed but it may not yet be merged / released label Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
work completed Work for this has been completed but it may not yet be merged / released
Projects
None yet
Development

No branches or pull requests

2 participants