`LAGOON_CONTEXT` sets the config directory instead of the Lagoon context
Nobody has claimed this yet.
Assessment
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Newbie friendliness
- 88/100
Research direction
Start at getLagoonContext in cmd/root.go (around lines 391-394), where the LAGOON_CONTEXT lookup assigns to configFilePath. Compare it with the neighbouring LAGOONCONTEXT handling and with where lagoonContext is later used, then change the assignment target to lagoonContext. Reproduce with the YAML file from the issue and LAGOON_CONTEXT=second lagoon config current, which should print second; go test ./cmd/... guards against regressions.
Written by the indexing model from the issue text.
Description
Description
The LAGOON_CONTEXT environment variable is meant to select the Lagoon context (like --lagoon / LAGOONCONTEXT), but in getLagoonContext its value is assigned to the global configFilePath instead of lagoonContext:
// prefer LAGOON_CONTEXT
if lagoonContextEnvar, ok := os.LookupEnv("LAGOON_CONTEXT"); ok {
configFilePath = lagoonContextEnvar
}
As a result, LAGOON_CONTEXT is ignored: commands silently run against the default context instead. That can send a command to a different Lagoon than intended (for example production instead of a local one). When the CLI needs to refresh its token, it also tries to write the config file into a directory named after the LAGOON_CONTEXT value, and fails.
Steps to reproduce
cat > /tmp/ctx-test.yml <<'EOF'
current: first
default: first
lagoons:
first:
graphql: http://first.invalid/graphql
hostname: first.invalid
port: "2223"
second:
graphql: http://second.invalid/graphql
hostname: second.invalid
port: "2223"
EOF
export LAGOON_CONFIG_FILE=/tmp/ctx-test.yml
lagoon -l second config current # second
LAGOONCONTEXT=second lagoon config current # second
LAGOON_CONTEXT=second lagoon config current # first <- ignored
LAGOON_CONTEXT=second lagoon whoami # dial tcp: lookup first.invalid: no such host
Expected
LAGOON_CONTEXT=second selects the second context, like -l second and LAGOONCONTEXT=second.
Actual
The default context first is used.
When that default context needs a token refresh, the command fails instead, because the CLI tries to save the config file into a directory named after the LAGOON_CONTEXT value:
Error: couldn't refresh token: couldn't write config: open second/ctx-test.yml: no such file or directory
Suggested fix
if lagoonContextEnvar, ok := os.LookupEnv("LAGOON_CONTEXT"); ok {
lagoonContext = lagoonContextEnvar
}
Version
lagoon-cli v0.33.0 (macOS arm64). Still present on main at 38a7b36.
- Dominant language
- Go
- Stars
- 28
- Forks
- 14
- PR merge metrics
- No merged PRs in 30d
Getting set up
- Ships a Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from uselagoon/lagoon-cli
-
Nix flakeOpen
Difficulty 3/5 1-2 days Newbie friendliness 68/100
uselagoon/lagoon-cli#495 · 1 comment ·
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
uselagoon/lagoon-cli#480 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
uselagoon/lagoon-cli#455 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 45/100
uselagoon/lagoon-cli#454 · 3 comments ·
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
uselagoon/lagoon-cli#453 · 4 comments ·
All issues in uselagoon/lagoon-cli
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
-
Difficulty 1/5 Under an hour Newbie friendliness 62/100
slavakurilyak/awesome-ai-agents#1026 ·
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
Tarektouati/made#197 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
GetBatchResponseById panics for items without a body (204/302) and for unknown idsPossibly taken @0z5a claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100