Skip to content

feat: add METAL_CONFIG as alternative to --config#420

Merged
ctreatma merged 2 commits intomainfrom
metal_config_env
Jan 5, 2024
Merged

feat: add METAL_CONFIG as alternative to --config#420
ctreatma merged 2 commits intomainfrom
metal_config_env

Conversation

@displague
Copy link
Copy Markdown
Member

@displague displague commented Dec 20, 2023

Nearly all --args can be supplied as METAL_{ARG} because we take advantage of Viper's AutomaticEnv feature.

The code that configures this and runs this happens after the config file option is detected and read in.

In order to support METAL_CONFIG, we have to check for it explicitly.

Fixes #360

How has this been tested

mjohansson@dev-qemu:~/dev/metal-cli$ METAL_CONFIG=/tmp/foo.yaml  go run ./cmd/metal env
METAL_AUTH_TOKEN=foo
METAL_ORGANIZATION_ID=
METAL_PROJECT_ID=
METAL_CONFIG=/tmp/foo.yaml

mjohansson@dev-qemu:~/dev/metal-cli$ go run ./cmd/metal env --config=/tmp/foo.yaml
METAL_AUTH_TOKEN=foo
METAL_ORGANIZATION_ID=
METAL_PROJECT_ID=
METAL_CONFIG=/tmp/foo.yaml

mjohansson@dev-qemu:~/dev/metal-cli$ go run ./cmd/metal env | grep CONFIG
METAL_CONFIG=/home/mjohansson/.config/equinix/metal.yaml

Nearly all --args can be supplied as METAL_{ARG} because we take advantage of Viper's AutomaticEnv feature.

The code that configures this and runs this happens after the config file option is detected and read in.
In order to support METAL_CONFIG, we have to check for it explicitly.

Signed-off-by: Marques Johansson <[email protected]>
@ctreatma ctreatma merged commit 4557cff into main Jan 5, 2024
@ctreatma ctreatma deleted the metal_config_env branch January 5, 2024 19:11
aayushrangwala pushed a commit to aayushrangwala/metal-cli that referenced this pull request Jan 9, 2024
Nearly all --args can be supplied as METAL_{ARG} because we take
advantage of Viper's AutomaticEnv feature.
    
The code that configures this and runs this happens after the config
file option is detected and read in.

In order to support METAL_CONFIG, we have to check for it explicitly.

Fixes equinix#360 

## How has this been tested

```sh
mjohansson@dev-qemu:~/dev/metal-cli$ METAL_CONFIG=/tmp/foo.yaml  go run ./cmd/metal env
METAL_AUTH_TOKEN=foo
METAL_ORGANIZATION_ID=
METAL_PROJECT_ID=
METAL_CONFIG=/tmp/foo.yaml

mjohansson@dev-qemu:~/dev/metal-cli$ go run ./cmd/metal env --config=/tmp/foo.yaml
METAL_AUTH_TOKEN=foo
METAL_ORGANIZATION_ID=
METAL_PROJECT_ID=
METAL_CONFIG=/tmp/foo.yaml

mjohansson@dev-qemu:~/dev/metal-cli$ go run ./cmd/metal env | grep CONFIG
METAL_CONFIG=/home/mjohansson/.config/equinix/metal.yaml
```

---------

Signed-off-by: Marques Johansson <[email protected]>
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.

Accept METAL_CONFIG env var in addition to --config

2 participants