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

[Bug]: Namespace name not updated when passing variables via CLI in Garden environment configuration #6528

Open
Daphaz opened this issue Oct 9, 2024 · 1 comment
Labels

Comments

@Daphaz
Copy link

Daphaz commented Oct 9, 2024

Bug

Current behavior

When dynamically defining a namespace name in the project.garden.yml using a variable passed through the CLI, the namespace name reverts to the default value instead of the one passed via the command line. For example, in the following configuration:

variables:
  my-variable: ${git.branch}
environments:
  - name: preview
    defaultNamespace: ns-${var.my-variable}

When running the command garden deploy --env preview --var my-variable=test,
the expected namespace should be ns-test, but it instead uses the default value based on the git branch.

Expected behavior

The namespace name should be dynamically assigned based on the variable passed via the CLI (--var my-variable=test), not reverting to the default.

Reproducible example

  1. Define the following configuration in your project.garden.yml:
variables:
  my-variable: ${git.branch}
environments:
  - name: preview
    defaultNamespace: ns-${var.my-variable}
  1. Run the command:
garden deploy --env preview --var my-variable=test
  1. Observe the namespace generated is not ns-test, but based on the default git branch instead.

Workaround

As a workaround, use environment variables to override the value:

variables:
  source-branch: ${local.env.SOURCE_BRANCH_OVERRIDE || git.branch}
environments:
  - name: preview
    defaultNamespace: ns-${var.source-branch}

And run the command with the following:

SOURCE_BRANCH_OVERRIDE=test garden deploy --env preview

Suggested solution(s)

N/A

Additional context

N/A

Your environment

  • OS: macOS 14.5 (M1)
  • How I'm running Kubernetes: EKS

garden version: 0.13.41

@Daphaz Daphaz added the bug label Oct 9, 2024
@Daphaz Daphaz changed the title [Bug]: The defaultNamespace should use --var flag [Bug]: Namespace name not updated when passing variables via CLI in Garden environment configuration Oct 9, 2024
@eysi09
Copy link
Collaborator

eysi09 commented Oct 10, 2024

This looks like a legit bug but just FYI and to add to the list of workarounds, you can also set the namespace via the --env flag with the format <namespace>.<environment>.

For example:

garden deploy --env my-namespace.my-env

(From this guide: https://docs.garden.io/guides/namespaces)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants