Change nodejs codegen to use coalescing operator when when default values are present (#6496)
This commit is contained in:
parent
c48ba37fcf
commit
1f16423ede
|
@ -62,10 +62,10 @@ export class RubberTree extends pulumi.CustomResource {
|
|||
throw new Error("Missing required property 'type'");
|
||||
}
|
||||
inputs["container"] = args ? args.container : undefined;
|
||||
inputs["diameter"] = (args ? args.diameter : undefined) || 6;
|
||||
inputs["farm"] = (args ? args.farm : undefined) || "(unknown)";
|
||||
inputs["size"] = (args ? args.size : undefined) || "medium";
|
||||
inputs["type"] = (args ? args.type : undefined) || "Burgundy";
|
||||
inputs["diameter"] = (args ? args.diameter : undefined) ?? 6;
|
||||
inputs["farm"] = (args ? args.farm : undefined) ?? "(unknown)";
|
||||
inputs["size"] = (args ? args.size : undefined) ?? "medium";
|
||||
inputs["type"] = (args ? args.type : undefined) ?? "Burgundy";
|
||||
}
|
||||
if (!opts.version) {
|
||||
opts = pulumi.mergeOptions(opts, { version: utilities.getVersion()});
|
||||
|
|
|
@ -583,13 +583,8 @@ func (mod *modContext) genResource(w io.Writer, r *schema.Resource) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// Note: this logic isn't quite correct, but already exists in all of the TF-based providers.
|
||||
// Specifically, this doesn't work right if the first value is set to false but the default value
|
||||
// is true. The Kubernetes provider didn't include this logic, so use the correct ?? operator there.
|
||||
arg = fmt.Sprintf("(%s) || %s", arg, dv)
|
||||
if mod.compatibility == kubernetes20 {
|
||||
arg = fmt.Sprintf("(%s) ?? %s", arg, dv)
|
||||
}
|
||||
|
||||
arg = fmt.Sprintf("(%s) ?? %s", arg, dv)
|
||||
}
|
||||
|
||||
// provider properties must be marshaled as JSON strings.
|
||||
|
|
Loading…
Reference in a new issue