What will a property that is present in `ignoreCha...
# typescript
b
What will a property that is present in
ignoreChanges
do when another property on the resource is updated? Context: We have short-lived K8s creds, and a dynamic resource provider that is doing some basic checks against our cluster that aren't supported by
@pulumi/kubernetes
directly. If I pass in a
kubeconfig
, then more or less every time we run
pulumi up
it sees a change on the resource, because the
kubeconfig
has changed. But if I ignore changes to
kubeconfig
and it only ever uses the initial value from create, then within a few hours the embedded TLS certs will have expired. What I need is for
kubeconfig
changes on their own to not trigger an update, but if any other property changes it should use the latest value of
kubeconfig
that was provided alongside the other updated property to make the request. Is that possible?
e
If this is a custom dynamic provider you should be able to get that logic by just changing the "diff" function, no need for ignoreChanges. Just set diff to only return that there are changes if something other than kubeconfig has changed.
b
Oh amazing, I'd totally not noticed that
diff
was one of the functions you could provide. Thanks!
Hmm, that it not working as I expected. My additional parameter is always showing as a diff and my resource is showing as needing to be replaced, even though it's not paid attention to at all in my custom
diff
function...
e
What's your diff function look like?
b
Copy code
async diff(
        _id: string,
        olds: WaitForCrdsProviderOutputs,
        news: WaitForCrdsProviderInputs,
      ): Promise<dynamic.DiffResult> {
        const changes =
          olds.crds.length !== news.crds.length || olds.crds.sort() !== news.crds.sort();

        return {
          changes,
          replaces: changes ? ['crds'] : undefined,
        };
      },
crds
is just an array of strings
Oh, hmm
Adding some debug, and that
changes
is
true
. So I'm clearly doing something very silly...
I should have checked that first, but it seemed so simple I wasn't expecting there to be an error there 😉
e
I think that compare of the results of sort might be a reference comparison
b
🤦
e
probably have to sort then loop over to check each item
b
Yup, that works. Sorry, that was a really stupid question and I should have checked first
Just gotten so used to Clojure, where nearly everything is compare by value
e
no worries 👍