https://pulumi.com logo
Title
a

adamant-postman-86832

01/16/2020, 10:02 AM
We are using pulumi with typescript and a pulumi yaml config file. We have included “enableIstio”: false using “pulumi config set enableIstio false”. If we use let blabla = config.getBoolean(“enableIstio”) || true it always results in true so I assume we cannot use this example? I know that typescript defines it as such. For let blabla = config.getNumber(“somenumber”) || 20 is working correctly except in the case where your number is a 0 (=false). A bit of a gotcha as a lot of these code examples use || and not ??
b

broad-dog-22463

01/16/2020, 11:57 AM
have you instantiated the config? e.g.
const x = new pulumi.Config();
a

adamant-postman-86832

01/16/2020, 12:41 PM
Hi,Paul. Yes we use
const config = new pulumi.Config(“pulumi”)
b

broad-dog-22463

01/16/2020, 2:09 PM
Drop the Pulumi part and try it - I don’t believe you need that
a

adamant-postman-86832

01/16/2020, 4:44 PM
if Indo a console.log it returns the correct value so it reads the config directly
I think you should use ?? for numbers and bools, not || to provide default values
w

white-balloon-205

01/16/2020, 5:35 PM
Yes - you are right about the gotcha here (if you see any Pulumi example code that has a bug due to this let us know). The
??
operator was just added to TypeScript 2 months ago, and is not widely known syntax yet - which is the primary reason it’s not used in examples yet. It is indeed closer to the desired semantics for this use case.
👍 1