-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(kubernetes): Reduce API surface of KubernetesKindProperties #4029
Conversation
Only the statically-defined kinds are allowed to set isDynamic to false, or hasClusterRelationship to true. In order to make this statically true, make the full constructor private and expose a factory method that doesn't allow those properties to be set for use outside the class. (Some of the usages of the constructor in tests *did* set isDynamic and hasClusterRelationship, but these were just testing the API that was available; now that these are not exposed outside the class the tests can just use the factory method.)
The only time we ever use the getRegisteredKinds method in KubernetesKindRegistry, what we actually want is a list of the global kinds (so we can set up the core caching agent). We do this by getting all the kinds and filtering on the isDynamic property; it would be simpler to just return the global kinds in the first place. A kind is global if and only if it is not dynamic.
The prior commit removed the last usage of isDynamic in the KubernetesKindProperties class. Remove the member variable from the class.
In preparation for a fix to reduce live CRD lookups, move the defaulting of unknown kinds from the GlobalKubernetesKindRegistry to the account KubernetesKindRegistry. This doesn't change the result of calling getRegisteredKind on the account registry, but moves where the defaulting happens.
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.
🚗 🚌 🔨 🌋
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.
⬇️ 🌎 🏦
To make sure my mental model is correct: global kinds are equivalent to registered kinds, and global kinds and dynamic kinds are a disjoint set?
@maggieneterval : Good question, here are the definitions of the relevant terms: I've found these terms pretty confusing and so am slowly trying to get rid of them; this PR finally gets rid of the concept of a dynamic kind. |
@ezimanyi thank you! 🙏 |
refactor(kubernetes): Reduce API surface of KubernetesKindProperties
Only the statically-defined kinds are allowed to set isDynamic to false, or hasClusterRelationship to true. In order to make this statically true, make the full constructor private and expose a factory method that doesn't allow those properties to be set for use outside the class.
(Some of the usages of the constructor in tests did set isDynamic and hasClusterRelationship, but these were just testing the API that was available; now that these are not exposed outside the class the tests can just use the factory method.)
refactor(kubernetes): Simplify getRegisteredKinds
The only time we ever use the getRegisteredKinds method in KubernetesKindRegistry, what we actually want is a list of the global kinds (so we can set up the core caching agent).
We do this by getting all the kinds and filtering on the isDynamic property; it would be simpler to just return the global kinds in the first place. A kind is global if and only if it is not dynamic.
refactor(kubernetes): Remove isDynamic property from kind properties
The prior commit removed the last usage of isDynamic in the KubernetesKindProperties class. Remove the member variable from the class.
refactor(kubernetes): Move defaulting logic to account registry
In preparation for a fix to reduce live CRD lookups, move the defaulting of unknown kinds from the GlobalKubernetesKindRegistry to the account KubernetesKindRegistry.
This doesn't change the result of calling getRegisteredKind on the account registry, but moves where the defaulting happens.