shell-operator icon indicating copy to clipboard operation
shell-operator copied to clipboard

✨ feat: Accessing old object on `watchEvent`

Open mhkarimi1383 opened this issue 2 years ago • 8 comments

Overview

By using OldObject input from K8s we will have access to oldObject when modified

What this PR does / why we need it

Closes #515 I need this here: https://github.com/mhkarimi1383/reflector/pull/3

Sometimes we need to have access to older object specially if we are managing our own CRD

Special notes for your reviewer

mhkarimi1383 avatar Jul 24 '23 06:07 mhkarimi1383

I don't know if I have updated docs correctly, Also in Delete event we can fill OldObject instead of Object, Since we can Called removed object 'old'

mhkarimi1383 avatar Jul 24 '23 07:07 mhkarimi1383

@nabokihms Can you review this?

mhkarimi1383 avatar Jul 26 '23 07:07 mhkarimi1383

@mhkarimi1383 yes, sure. I've just put it in the queue.

nabokihms avatar Jul 26 '23 08:07 nabokihms

I will add unit test for that later on, I have not worked with Golang unit tests alot :)

Can you give me a context of how should I test this thing? I mean testing the input and output is good enough or I have to do a more advaced test

mhkarimi1383 avatar Jul 27 '23 17:07 mhkarimi1383

@nabokihms Hi, I have fixed linter and unit test error.!

The only left thing is the feature unit tests :)

mhkarimi1383 avatar Aug 01 '23 09:08 mhkarimi1383

@nabokihms

Any updates on this? My project development blocked 😕

mhkarimi1383 avatar Aug 10 '23 19:08 mhkarimi1383

@nabokihms What is this error?

pkg/kube_events_manager/resource_informer.go:302: File is not `gci`-ed with --skip-generated -s standard,default,prefix(github.com/flant/) (gci)

mhkarimi1383 avatar Aug 14 '23 14:08 mhkarimi1383

I fixed the linter, but PR doesn't work because there are other parts missing.

For example, to finally see an old object in a hook, this file requires changes as well https://github.com/flant/shell-operator/blob/main/pkg/hook/binding_context/binding_context.go

And probably this one https://github.com/flant/shell-operator/blob/1d4c4d9320a89fbe348409750631b372671ae958/pkg/hook/controller/kubernetes_bindings_controller.go#L294-L329

One more thing, without adding tests, we will not be able to merge the PR.

nabokihms avatar Aug 17 '23 21:08 nabokihms