Allow overwriting fabric credentials from environment variables #45
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem description
Currently, it is only possible to define the connection credentials in the config.yaml file and not over environment variables. Unfortunately, the
UnmarshalKey
method from viper only reads the values from the configuration file althoughviper.AutomaticEnv
method is called at the beginning.Solution
Check if username or password are defined as environment variables. The environment variables are composed by the following pattern:
ACI_EXPORTER_FABRICS_{fabric name}_{USERNAME or PASSWORD}
. The fabric name used in the environment variables must be all upper case and-
symbol will be converted to_
Example
credentials for fabric cisco_sandbox and profile-fabric-01 can be configured as follows: