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

[FEAT] Support setting/overriding config variables with docker environment variables #52

Closed
shamoon opened this issue Sep 29, 2020 · 7 comments
Labels
enhancement New feature or request

Comments

@shamoon
Copy link
Contributor

shamoon commented Sep 29, 2020

Is your feature request related to a problem? Please describe.
A nice feature implemented by other docker-friendly projects is to allow setting config values via docker environment variables. While certainly not mission-critical this can help keep things neater with all config in e.g. a docker-compose file

Describe the solution you'd like
E.g.

    environment:
      - SCRUTINY_NOTIFY_PUSHOVER=pushover://shoutrrr:apiToken@userKey/?devices=device1

Additional context
E.g. https://wiki.cajun.pro/books/varken/page/breakdown#bkmrk-environment-variable
Thanks for this awesome tool.

@shamoon shamoon changed the title Support setting/overriding config variables with docker environment variables [FEAT] Support setting/overriding config variables with docker environment variables Sep 29, 2020
@AnalogJ
Copy link
Owner

AnalogJ commented Sep 29, 2020

Yeah, this is a good idea. I'm using Viper for config parsing, and it supports loading config from the environment as well. I just need to enable it.

@faucherc
Copy link

faucherc commented Mar 27, 2022

Do you have enabled it? How can we use it? It's a very nice feature to pass notification password to the container and don't commit the password in a config repo.

@AnalogJ
Copy link
Owner

AnalogJ commented Apr 28, 2022

Yes, this should already work, though I haven't tested it myself.
As I mentioned, scrutiny uses Viper under the hood for config/env parsing.

You should be able to do this (please comment again if this doesnt work):


# note, "lines" are space delimited in the environmental variable. 
export SCRUTINY_NOTIFY_URLS="discord://token@channel telegram://token@telegram?channels=channel-1" 
scrutiny-collector

# the environmental variable above should be equivalent to the following config stanza
# notify:
#  urls:
#    - "discord://token@channel"
#    - "telegram://token@telegram?channels=channel-1"


@faucherc
Copy link

I have tried it this morning. And unfortunatly I didn't find any way get it working.

I have dig some part of the code. And I think you need to activate the feature with the Viper method "AutomaticEnv" and optionally the method "SetEnvPrefix". I don't have find any referece to this in your code.

https://github.com/spf13/viper#working-with-environment-variables

@AnalogJ
Copy link
Owner

AnalogJ commented Apr 30, 2022

apologies, yeah I noticed that yesterday. It's fixed in the Influxdb branch: https://github.com/AnalogJ/scrutiny/blob/influxdb/webapp/backend/pkg/config/config.go#L68-L71

Once that code is merged to master, we can close this issue.

@faucherc
Copy link

faucherc commented May 1, 2022

No problem. I will follow and wait the influxdb branch. Thanks

@AnalogJ AnalogJ added enhancement New feature or request help wanted Extra attention is needed and removed help wanted Extra attention is needed labels May 2, 2022
@AnalogJ
Copy link
Owner

AnalogJ commented May 12, 2022

Almost all Scrutiny configuration can now be set via environmental variables. (v0.4.1+)

Scrutiny web options are prefixed with SCRUTINY_ and Collector options are prefixed with COLLECTOR_

eg. web.listen.port becomes SCRUTINY_WEB_LISTEN_PORT=8080 and host.id becomes COLLECTOR_HOST_ID.

Closing this for now, feel free to reopen if there are more questions.

@AnalogJ AnalogJ closed this as completed May 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants