Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Read mqtt user and password from environment
Environment variables override config variables, if they exist
- Loading branch information
df2c852
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.
@Momeno this looks like a nice addition? Do you mind to create a PR?
df2c852
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.
Hi @hikhvar, sure! I was planning on making a PR, I just hadn't gotten around to it :)
df2c852
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.
@hikhvar Actually, I ran into an issue where I was not able to get a container built from the head of the master branch to read the configuration file on launch, even though it worked with the container image at ghcr.io/hikhvar/mqtt2prometheus:latest.
I'm not familiar enough with Go to debug the issue quickly and I ran out of time, so I'm not sure what the cause could be.
I did these steps:
make container docker run -it -v "$(pwd)/examples/config.yaml:/config.yaml" -p 9641:9641 mqtt2prometheus:latest
And got this error:
This stopped me from testing the environment variable load so I abandoned the fork, at least for now.
df2c852
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.
Hey,
the problem is, that the working directory in the container is set to
/home/nonroot
. Hence to make this work you must either mount the config to/home/nonroot/config.yaml
or set the current working directory to/
.I will change the working directory upstream to
/
. This is more intuitive.df2c852
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.
hikhvar@4418b5a fixed this upstream.
df2c852
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.
Awesome! I see, the working directory was the issue. I'll have the PR ready shortly.
df2c852
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.
I've posted a PR here: hikhvar#70