8000 feat: add METAL_CONFIG as alternative to --config by displague · Pull Request #420 · equinix/metal-cli · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Sep 4, 2026. It is now read-only.

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

Merged
ctreatma merged 2 commits into
mainfrom
metal_config_env
Jan 5, 2024
Merged

ctreatma merged 2 commits into
mainfrom
metal_config_env

Conversation

@displague
@displague displague commented Dec 20, 2023 •
Copy link
Copy Markdown
Member

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
@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>

This branch was previously deployed

1 inactive deployment
internal — 6c58eb14 Deployed Jan 5, 2024 by ctreatma
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

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

0