microbean / microbean-kubernetes-controller

A toolset for writing Kubernetes controllers, or operators, in Java.
https://microbean.github.io/microbean-kubernetes-controller/
Apache License 2.0
20 stars 7 forks source link

Event resource delta #12

Closed xguerin closed 6 years ago

xguerin commented 6 years ago

Hey there,

What is the best way to get the resource delta on a modification event? I seem to recall something about delta queues in your blog but I am not entirely convinced this is related.

Thanks,

ljnelson commented 6 years ago

If I'm understanding you right, the prior state of the object a given event concerns is available within the event itself.

xguerin commented 6 years ago

Correct. But both states are complete. I am looking for a mean to basically make a diff of both states to only get what has changed between prior and current.

ljnelson commented 6 years ago

Oh, I see. You are asking a general question, then: given two Kubernetes resources represented as HasMetadata objects, how can you diff them? That's a kubernetes-client question, and it seems they use this: https://github.com/fabric8io/kubernetes-client/blob/59e5b9d0f318f4f78f417efaec34050ed8122b8f/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/dsl/base/OperationSupport.java#L39

xguerin commented 6 years ago

thanks for the pointer 👍