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

[Feature] Consume host/user/pass from env variables or command line #406

Closed
mahnunchik opened this issue Sep 26, 2024 · 1 comment
Closed

Comments

@mahnunchik
Copy link
Contributor

Is your feature request related to a problem? Please describe.

I'd like to bring to mqtt-io ability to be launched in single click as Home Assistant integration. To implement this, it is required to add the ability to read authentication related configuration values from environment variables or from the command line.

Describe the solution you'd like

Option 1: Env vars

export MQTT_IO_HOST="core-mosquitto"
export MQTT_IO_USER="addons"
export MQTT_IO_PASS="12345"
python -m mqtt_io config.yml

Option 2: Command line arguments

python -m mqtt_io config.yml --host="core-mosquitto" --user="addons" --pass="12345"

The questions are:

  1. How is better to implement this feature? Any ideas?
  2. Should env vars or command line arguments has precedence over yaml configuration? According to old spec - yes (https://12factor.net/config)
  3. Should it be validated separately or together with the main config? According to common sense - yes 😉

Describe alternatives you've considered

It is possible to implement the similar behaviour on top of current implementation

python -m mqtt_io --render render.yaml config.yaml
# render.yaml
backends:
  env:
    type: env
    prefix: 'MQTT_IO'
# config.yaml
mqtt:
  host: { { env('HOST') } }
  user: { { env('USER') } }
  password: { { env('PASS') } }
  ha_discovery:
    enabled: true

More info: hassio-addons/addon-mqtt-io#19

But in the maintainer's opinion and in my opinion, this is too complicated and error prone a design for configuration.

Additional context

I'd like to work on this feature in the core https://github.com/flyte/mqtt-io and ha addon https://github.com/hassio-addons/addon-mqtt-io/

Related issues:

  1. Add support for environment variables hassio-addons/addon-mqtt-io#19
  2. [Feature] Server & username & password automatic detection hassio-addons/addon-mqtt-io#134 - I've described how to load necessary auth data from HA core.
  3. config not found - new install via addons in home assistant #399 - I'd like to fix config not found issues too
  4. addon didn't start - config file missing  hassio-addons/addon-mqtt-io#110
  5. Render Env Variables by Default #279
  6. Split configuration #209
@BenjiU
Copy link
Collaborator

BenjiU commented Oct 19, 2024

merged

@BenjiU BenjiU closed this as completed Oct 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants