devspace-sh / devspace

DevSpace - The Fastest Developer Tool for Kubernetes ⚡ Automate your deployment workflow with DevSpace and develop software directly inside Kubernetes.
https://devspace.sh
Apache License 2.0
4.37k stars 361 forks source link

Expressions in variable using "$1" do not resolve correctly #2478

Closed Quasarman closed 1 year ago

Quasarman commented 1 year ago

What happened?

I am trying to put the expression $( [ $1 == "dev" ] && echo "true" || echo "false" ) inside a variable to use the result in various places in my config. But it does not seem to correctly resolve the "$1" since the expression always results to false regardless if calling devspace dev or not.

What did you expect to happen instead?

I expect the variable to be resolved correctly.

How can we reproduce the bug? (as minimally and precisely as possible)

  1. Put the following inside your devspace config
vars:
  TEST_VAR_EXPRESSION: $( [ $1 == "print" ] && echo "true" || echo "false" )
  1. Call devspace print
  2. Inspect that the variable is false

You can also change the $1 == "print" to any string really it will always return false.

My devspace.yaml:

version: v2beta1

vars:
  DEV_MODE: $( [ $1 == "dev" ] && echo "true" || echo "false" )

...
deployments:
  my-deployment:
      helm:
        chart:
          name: my/chart
        values:
          debug: ${DEV_MODE}
...

Local Environment:

Anything else we need to know?

Nope.

FabianKramm commented 1 year ago

@Quasarman thanks a lot for the PR! We'll try to reproduce this and create a fix as soon as possible.