Prioritize environment variables over current config
tylerphelan opened this issue · 5 comments
What version of the credhub server you are using?
1.6.5
What version of the credhub cli you are using?
1.6.0
If you were attempting to accomplish a task, what was it you were attempting to do?
I'm hoping that when I switch my credhub environment variables from one credhub server to another server my credhub config will be configured without having to run credhub api
.
Steps to reproduce:
$ export CREDHUB_CLIENT=...
$ export CREDHUB_SECRET=...
$ export CREDHUB_SERVER=server1
$ export CREDHUB_CA_CERT=cert1
$ credhub get -n /some/ref
> id: 1b34c341... (success)
...
$ export CREDHUB_CLIENT=...
$ export CREDHUB_SECRET=...
$ export CREDHUB_SERVER=server2
$ export CREDHUB_CA_CERT=cert2
credhub get -n /some/ref
> Post https://server1:8443/oauth/token: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
Potentially useful line number?:
https://github.com/cloudfoundry-incubator/credhub-cli/blob/be697aff6ba98c2f37dad63887ba1349dbd0d40c/commands/helpers.go#L57
Please confirm where necessary:
- I have included a log output
- My log includes an error message
- I have included steps for reproduction
We have created an issue in Pivotal Tracker to manage this:
https://www.pivotaltracker.com/story/show/155225102
The labels on this github issue will be updated when the story is started.
I agree that the better behavior would be for the CLI to prioritize the env vars over its cached server info. We'll prioritize this change.
I'd be in favor of removing the cached server functionality altogether and just use environment variables and explicit flags for everything. It's too confusing to have two sources of configuration.
Given that removing the cached server functionality would break backwards-compatibility, we'll go ahead and prioritize the env vars if they are set.
This looks like the current behavior!