-
Notifications
You must be signed in to change notification settings - Fork 88
Consolidate all K8s API calls in one place #71
Consolidate all K8s API calls in one place #71
Conversation
🤖 zincr found 0 problems , 1 warning
Details on how to resolve are provided below Large CommitsChecks all commits for large additions to a single file. Large commits should be reviewed more carefully for potential copyright and licensing issues This file contains a substantial change, please review to determine if the change comes from an external source and if there are any copyright or licensing issues to be aware of
|
4182d4b
to
64d9197
Compare
64d9197
to
a88c1fe
Compare
e5fff83
to
47f6777
Compare
type=type, | ||
reason=reason, | ||
note=message, | ||
# message=message, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are you leaving these comments intentionally? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
I struggle to identify which fields do what here, as they are duplicating each other (but not all of them): e.g. note
~ message
, regarding
~ related
, event_time
~ deprecated_first_timestamp
; also some are of unclear purpose, and are not shown anywhere, e.g. action
.
I will get back to them later, probably when I will be switching Kopf to pykube-ng — just to see how it is better done with other clients.
This might also be needed for multi-version K8s compatibility, as these fields look like some transitional stage between Kubernetes versions, so it might happen that these lines should be uncommented later. — E.g., most likely, it will be a switch from V1beta1Event
to something like V1Event
class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@samurang87 And immediately related: #81 — with the cleanup of these fields (on another occasion).
This is purely a refactoring: moving all Kubernetes-client-related routines into one place.
And a lot of new tests for these K8s-client call (in addition to the existing ones).
Previously, the API calls were spread all over the codebase. And the official Kubernetes client is quite wordy, so the places were also unnecessary wordy (not to their main point).
Few notes:
The peering objects (cluster-scoped, namespace-scoped, and the legacy one) use exactly the same unified logic now, with no exceptions.
There are no changes in the APIs, DSLs, signatures, behaviour or anything user-facing or k8s-facing. Only the internal code moves. Except for this:
patch_cluster_custom_object()
is used instead ofpatch_namespaced_custom_object(namespace=None)
, which would fail. This would also affect the patching of peering objects (cluster-scoped and legacy), but is fixed in place.Patching of a namespaced resource uses the namespace of the resource itself (even for the cluster-scoped operator).
This PR is also a part of the following chain of changes: