https://pulumi.com logo
#typescript
Title
# typescript
s

stocky-island-3676

11/14/2019, 8:09 PM
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

white-balloon-205

11/14/2019, 8:20 PM
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

stocky-island-3676

11/14/2019, 8:26 PM
@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

bored-jackal-93148

12/08/2019, 11:41 PM
if you want native solution and don't need a deep merge you can use
{ ...args.opts, ...{ ignoreChanges: ["tags"] }}
w

white-balloon-205

12/08/2019, 11:54 PM
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