factor out healthchecks API endpoint to an environment variable#3
factor out healthchecks API endpoint to an environment variable#3earthquakesan wants to merge 1 commit intohealthchecks:masterfrom
Conversation
|
Thanks for the PR! CLI already needs to store API key: How about storing the API endpoint there as well? Also I think we should only store the –something like that. What do you think? |
|
Hi @cuu508, I agree with the API endpoint notion, storing only https://server/api/v1/ is indeed better option. https://github.com/earthquakesan/borg-lab/blob/master/playbooks/roles/hchk/tasks/main.yml To have environment variables as a first class citizen in the code, we can define precedence as follows:
And then both configuration options (API endpoint and key) can be defined either with env vars or with the configuration file. If env variable is set, configuration file is simply ignored. Let me know what you think. |
|
Supporting configuration file and environment variables sounds good to me. Environment variables taking precedence also seems like the way to go. A couple quick spot checks: Ansible prefers env vars over configuration file: https://docs.ansible.com/ansible/latest/reference_appendices/general_precedence.html |
I factored out the API endpoint URL into an env variable, this way CLI can be used with custom healthchecks deployment.