Skip to content
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

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

Merged
merged 2 commits into from
Jan 5, 2024
Merged

Conversation

displague
Copy link
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 <mjohansson@equinix.com>
Signed-off-by: Marques Johansson <mjohansson@equinix.com>
@ctreatma ctreatma merged commit 4557cff into main Jan 5, 2024
7 of 8 checks passed
@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 <mjohansson@equinix.com>
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