8000 Allow overwriting fabric credentials from environment variables by thushjandan · Pull Request #45 · opsdis/aci-exporter · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Allow overwriting fabric credentials from environment variables #45

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

Merged
merged 1 commit into from
Dec 26, 2023

Conversation

thushjandan
Copy link
Contributor

Problem description

Currently, it is only possible to define the connection credentials in the config.yaml file and not over environment variables. Unfortunately, theUnmarshalKey method from viper only reads the values from the configuration file although viper.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

fabrics:
  cisco_sandbox:
    username: foo
    password: bar
    apic:
      - https://sandboxapicdc.cisco.com
  profile-fabric-01:
    username: foo
    password: bar
    apic:
      - https://apic1
      - https://apic2
    aci_name: foobar

credentials for fabric cisco_sandbox and profile-fabric-01 can be configured as follows:

# fabric cisco_sandbox
export ACI_EXPORTER_FABRICS_CISCO_SANDBOX_USERNAME=foo 
export ACI_EXPORTER_FABRICS_CISCO_SANDBOX_PASSWORD=bar
# fabric profile-fabric-01
export ACI_EXPORTER_FABRICS_PROFILE_FABRIC_01_USERNAME=foo 
export ACI_EXPORTER_FABRICS_PROFILE_FABRIC_01_PASSWORD=bar

Copy link
Member
@thenodon thenodon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thushjandan thanks for your PR

@thenodon thenodon merged commit db00361 into opsdis:master Dec 26, 2023
@thenodon
Copy link
Member
thenodon commented Dec 27, 2023

@thushjandan I will add some more functionality to the use of env variables, so it possible to define everything related to the fabric(s) as environment variables. https://github.com/opsdis/aci-exporter/releases/tag/v0.6.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0