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

0.13: [Bug]: variables supplied via --var cli flag has no effect on action level variables #4772

Closed
shumailxyz opened this issue Jul 7, 2023 · 0 comments · Fixed by #4773
Assignees
Labels

Comments

@shumailxyz
Copy link
Contributor

shumailxyz commented Jul 7, 2023

Garden Bonsai (0.13) Bug

Current Behavior

Variables supplied via --var cli flag only apply on the project level and have no effect on the variables defined on action level. So, it's not possible to override action level variables using --var cli flag.

Expected behavior

Variables supplied via --var cli flag should also apply on action variables.

Reproducible example

Consider the following garden config for a backend service.

project.garden.yml

apiVersion: garden.io/v1
kind: Project
name: repro-action-vars
environments:
  - name: local
providers:
  - name: local-kubernetes
    environments: [local]
    namespace: ${project.name}-testing-${var.userId}

garden.yml

kind: Build
name: backend
description: Backend service container image
type: container

---

kind: Deploy
name: backend
description: Backend service container
type: container

build: backend

# You can specify variables here at the action level
variables:
  ingressPath: /hello
  nestedmap:
    foo: bar

spec:
  healthCheck:
    httpGet:
      path: ${var.ingressPath}
      port: http
  ports:
    - name: http
      containerPort: 8080
      # Maps service:80 -> container:8080
      servicePort: 80
  ingresses:
    - path: ${var.ingressPath}
      port: http
  env:
    USER: ${var.nestedmap.foo}
    INGRESS_PATH: ${var.ingressPath}

---

and backend is simply a go file.

// main.go
package main

import (
	"fmt"
	"net/http"
	"os"
)

func handler(w http.ResponseWriter, r *http.Request) {
	fmt.Fprint(w, "Backend says: Hello!", os.Getenv("USER"))
}

func main() {
	http.HandleFunc(os.Getenv("INGRESS_PATH"), handler)
	fmt.Println("Server running...")

	err := http.ListenAndServe(":8080", nil)
	if err != nil {
		panic(err)
	}
}

Deploy this using this command:

garden deploy --force --force-build  --var ingressPath="/welcome"

Note the ingress url. The url will be

http://repro-action-vars.local.demo.garden/hello

whereas it should in fact be

http://repro-action-vars.local.demo.garden/hello

as we override the ingressPath variable and set it to /welcome via --var cli flag.

Your environment

  • OS:
  • How I'm running Kubernetes:

garden version: 0.13.6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant