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

Boolean variables not comparing correctly in string templates #4174

Closed
marklester opened this issue May 5, 2023 · 1 comment
Closed

Boolean variables not comparing correctly in string templates #4174

marklester opened this issue May 5, 2023 · 1 comment

Comments

@marklester
Copy link

marklester commented May 5, 2023

Bug

Current Behavior

Given:

kind: Module
description: run hello world
type: exec
name: var-bug
variables:
  booltest: true
tasks:
  - name: varbug-echo
    command: ["echo", "${var.booltest ? 'true':'false'}"]
garden run task varbug-echo --var booltest=false
Task output:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
true
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Expected behavior

I would expect this to return false

Workaround

The workaround I am currently using is to treat all variables as strings

Your environment

  • OS: VERSION="18.04.6 LTS (Bionic Beaver)"
  • How I'm running Kubernetes: kind version 0.17.0

garden version
0.12.53

@10ko
Copy link
Member

10ko commented Feb 8, 2024

While the yaml allow for boolean values, passing a variable via the cli will convert the value to a string, which will correctly be evaluated to true.
There could be a more fundamental change we could implement to check for types or convert automatically strings to booleans but we don't see us planning this for now.

@10ko 10ko closed this as not planned Won't fix, can't repro, duplicate, stale Feb 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants