pulumi/pkg
joeduffy ee1acd365c Add a defaultIfComputed intrinsic
Until we support output-conditional code (pulumi/lumi#170), we
run into cases where we want to make a decision based on a computed
property if it is available, but can't possible know the value.  In
such cases, we get an error ("Unexpected computed value").

In fact, our generated code currently includes client side validation
of properties, since it leads to a(n admittedly only slightly) better
developer experience.  But that triggers the error for required
properties that are computed, basically hosing our ability to plan.

This change introduces a defaultIfComputed intrinsic to the lumirt
library that can be used to work around this.  It takes two arguments,
obj and def, and returns the actual property value obj if it is NOT
computed; if it is computed, def will be substituted in its stead.

The generated code changes to use this.  It's possible it will miss
validation, of course, if a computed property turns out not to match
the precondition.  But this is strictly better than the alternative
of not trying to validate any of them to begin with.
2017-07-16 15:16:48 -07:00
..
compiler Make assets and archives 1st class 2017-07-14 12:28:43 -07:00
diag Add a --debug option to plan, deploy, and destroy 2017-07-13 17:13:19 -07:00
encoding Support try/catch in Lumi and async/await in Node.js 2017-07-07 12:47:27 -07:00
eval Add a defaultIfComputed intrinsic 2017-07-16 15:16:48 -07:00
graph Clarify aspects of using the DCO 2017-06-26 14:46:34 -07:00
integrationtesting Fix golint errors in previous commit 2017-07-13 12:40:10 -07:00
pack Clarify aspects of using the DCO 2017-06-26 14:46:34 -07:00
resource Permit -1 for randlen and maxlen 2017-07-15 09:59:44 -07:00
tokens Addres PR feedback on #288 2017-07-13 23:03:28 -07:00
tools Add a defaultIfComputed intrinsic 2017-07-16 15:16:48 -07:00
util Add a --debug option to plan, deploy, and destroy 2017-07-13 17:13:19 -07:00
workspace Clarify aspects of using the DCO 2017-06-26 14:46:34 -07:00