Add dynamic provider that accepts GVKs instead of types#81
Add dynamic provider that accepts GVKs instead of types#81ntnn wants to merge 2 commits intokcp-dev:mainfrom
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
42722d8 to
9241864
Compare
|
|
||
| type logger struct{} | ||
|
|
||
| func (logger) OnAdd(obj client.Object) { |
There was a problem hiding this comment.
Dio we want to keep this?
There was a problem hiding this comment.
I like it, but I would make it a separate module.
|
|
||
| type logger struct{} | ||
|
|
||
| func (logger) OnAdd(obj client.Object) { |
There was a problem hiding this comment.
I like it, but I would make it a separate module.
Signed-off-by: Nelo-T. Wallus <red.brush9525@fastmail.com> Signed-off-by: Nelo-T. Wallus <n.wallus@sap.com>
Signed-off-by: Nelo-T. Wallus <red.brush9525@fastmail.com> Signed-off-by: Nelo-T. Wallus <n.wallus@sap.com>
d15db4e to
1972b3b
Compare
| func (logger) OnAdd(obj client.Object) { | ||
| log.Printf("add %q in namespace %q", obj.GetName(), obj.GetNamespace()) | ||
| if *fDumpObjects { | ||
| spew.Dump(obj) |
There was a problem hiding this comment.
What made you choose spew over something, dare I say, more common/re-usable like YAML? Personally I find spew super helpful, but also extremely hard to read.
This cmd feels like a multi-cluster stalk 😁 if I may drop some self-advertisement.
There was a problem hiding this comment.
I mostly wanted to have it printed in some way :D I don't care about the specifics.
It's very close yeah, this is tailored to watch resources in control planes linked from the *EndpointSlice resources; we could move this into a "flavoured" version of stalk?
There was a problem hiding this comment.
- I don't wnt to block your progress here and sneak it another one of my shitty little tools into "official workflows" 😁
- I'm not yet sure how much kcp integration a random external Kube tool should have for this. Technically if you provide stalk (or any other tool) with a kubeconfig that already points to the wildcard endpoint / apiexport VW, it should already be able to just watch EndpointSlices. I guess the object key logic would need to be extended to include cluster (i.e. (cluster,namespace,name)), but beyond that, how much should be built into third-party tools? What would we like?
There was a problem hiding this comment.
Well @mjudeikis had PR'd kcp support to the kube mcp server, I'd see that in a similar fashion :D
But we can also try and use stalk as a library and have kcp-apiexport-watcher use it to display changes; I don't mind either way. I just would like a tool that I can point at a *EndpointSlice and follow the changes^^
There was a problem hiding this comment.
And I think we can scrap the dynamic for now and just update the apiexport provider to also expose the cached object - this was just the quickest way to enable something supporting any kind of *EndpointSlice
There was a problem hiding this comment.
Let's forget about stalk, I never mentioned it. But can we replace spew with yaml.NewEncoder ?
There was a problem hiding this comment.
right, lets not start pulling 3rd party libs (even if they are our own), when we can just copy 100LOC and have no dependency.
Is this logger even used? Or is it supposed to be debugLogger/developmentLogger? If so, can we rename it so it's easier to reason why it's dumping full objects into stdot (including potentially secrets).
Summary
Used spew for the utility, though that moved the dep in the go.mod; we could make the utility its own go.mod [and we should check what exactly has spew in its dependencies, that feels like an error].
Overall idea for the provider is if this can be useful to help with either generic APIs and/or polymorphism, the utility is just a handy thing on top e.g. for the FilteredAPIExportWS
What Type of PR Is This?
/kind feature
Related Issue(s)
Fixes #
Release Notes