openconfig / gnmic

gNMIc is a gNMI CLI client and collector
https://gnmic.openconfig.net
Apache License 2.0
166 stars 52 forks source link

Environment expansion does not always work #458

Closed mathieudevos closed 16 hours ago

mathieudevos commented 1 month ago

Hey,

As the title states, if you attempt to use environment variable expansion through ${ENV_VAR} it does not seem to work on top level.

Example of gnmic.yml file:

encoding: json_ietf
log: true
address: ${MY_ADDRESS}
token: ${MY_TOKEN}

subscriptions:
  SWITCH1:
    paths:
      - openconfig:interfaces/interface/config/description
    target: SWITCH1SERIAL
    outputs:
      - influx-output

outputs:
  influx-output:
    type: influxdb
    url: ${INFLUX_ADDRESS}
    token: ${INFLUX_TOKEN}

^ in the above example, INFLUX_ADDRESS and INFLUX_TOKEN will be replaced by their respective env vars, however ${MY_ADDRESS} and ${MY_TOKEN} will not be substituted and be dropped as is.

Figuring this out took me quite a while as I was seeing unauthorized issues with a token that I was quite sure should work.

Hopefully this either gets amended in the information or bugfixed.

karimra commented 1 month ago

I will retest this by end of next week.

karimra commented 3 weeks ago

This should be fixed by #468 . Meanwhile you can use GNMIC_ADDRESS and GNMIC_TOKEN for those global attributes instead of setting them in the config file.

karimra commented 16 hours ago

Added in v0.38.0, the only exceptions are the fields password and token.