Typescript question: How can I append an additiona...
# typescript
s
Typescript question: How can I append an additional field & value to an existing variable of type
pulumi.ComponentResourceOptions
? I want to add
dependsOn
to a
kubernetesOptions
variable defined beforehand.
w
You can use `pulumi.mergeOptions`:
Copy code
pulumi.mergeOptions(args.opts, { ignoreChanges: ["tags"] })
Docs here: https://www.pulumi.com/docs/reference/pkg/nodejs/pulumi/pulumi/#mergeOptions One example here: https://www.pulumi.com/docs/intro/concepts/programming-model/#transformations
s
@white-balloon-205 Nice. Thanks ๐Ÿ™‚ I thought there would be a native Typescript way, though. But neat to see that you already created an easy solution for this ๐Ÿ‘
b
if you want native solution and don't need a deep merge you can use
{ ...args.opts, ...{ ignoreChanges: ["tags"] }}
w
Thatโ€™s right - though intelligently deep merging these data structures is the reason
mergeOptions
exists - and can avoid subtle issues in code that just does direct object splatting. Definitely encourage using mergeOptions over hand-rolling this sort of thing.
๐Ÿ‘ 3