-
Notifications
You must be signed in to change notification settings - Fork 103
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
Refactoring: Adjust api imports for new api version #1668
Comments
I'm a fan for revving the version to v1beta1. I don't see this proposal doing anything meaningful (unless I'm missing something). what we need to decide is if we will support v1beta1 and v1beta2 concurrently... if not we bump to v1beta2 and move on. if we support both... then we need an internal model and the use of beta1 and beta2 where appropriate will likely require the aliasing of the import and it's usage in code. The only thing I see here with the current proposal is the aliasing... IMO we shouldn't prescribe low level usage of imports... that is on an as need basis while coding... unless we are creating a standard by which we can make code generally easier to read. I also don't think we need to proactively make import alias changes in prep for new versioned apis. Perhaps your suggestion is to have an alias I'm of the opinion lets make import and alias changes in the process of coding. |
I'm not sure what you mean with this sentence?
Depends on the definition of support :) At least the api packages needs both versions for a while for migration purposes, although the rest of KUDO will (should) use only one version at a time - Conversion will be handled completely by the conversion webhook.
There will be an internal model in any case, to comfortably convert between the different versions - this is described here pretty nicely: https://book.kubebuilder.io/multiversion-tutorial/conversion-concepts.html There is an option to only use the internal model for KUDO code, but on the other hand the KUDO CLI and the controller receive specific versions of the resources. Using the internal model would require conversion every time on read and write. Not necessarily a blocker, but something to keep in mind.
Yes - my suggestion is to have an alias For 1.: I don't think there will be a case where we need to use both in non-generated code outside of the For comparison: We currently have 63 files which import the |
hmm... first the description in the kubebuilder book is about APIs (and operators) and seems different. management of API versions across components with externalized (non-encapsulated) interfaces with a need to convert from one version to another and back is completely different than internal versioning IMO. I'm not convinced but I'm not against it. I currently don't see the value. What we need is the ability for 1 version of kudo to support potentially different versions of the API types (which conversion WH doesn't help with)... why? The CLI needs to be able to work with operator packages which are v1beta1 and v1beta2 at the same time. At some point it will need to be able to parse and manage operators from different API versions. In order to manage this, I believe we need to have an internal model (perhaps it is versioned) and the external models (currently defined in the api package). Then we translate external versions (v1beta1 AND v1beta2) to the internal model. Much of the code which you are looking to modify today should be switched to an internal model and NOT to an external model at all... which is another way of solving the problem you are looking at. |
I've created a draft PR for this. These changes would be mixed in with actual code changes when we switch to
There are two things here:
I've mentioned this in my previous comment, and I think using only the internal (hub) model would be a viable solution - it also solves the problem where the "helper" functions should be defined. This PR would still be helping with this switch, as it separates the tedious search-and-replace work that doesn't need much review from actual code changes. |
What would you like to be added:
Replace
with
and usage of
v1beta1.Instance
withkudoapi.Instance
Why is this needed:
Currently the code in KUDO imports the API packages like this:
the types imported are therefore used as
v1beta1.Instance
,v1beta1.OperatorVersion
, etc.When we introduce a new API version
v1beta2
we need to adjust all these usages, which will introduce a lot of changes in unrelated code, making it hard to review.I propose to alias the import of a specific api to a generic "kudoapi" and only use this in the code itself. When we change the used API version, we only need to run a global replace to use the new API and the PR change will be limited to imports and actual code changes that is required because of the new API.
The text was updated successfully, but these errors were encountered: