-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
RFE: Generate api sub-package, with (almost) no external dependencies. #2627
Comments
I'm happy to take a look at this -- changing the scaffolding for new projects is simple enough, but I'm not sure what should happen for existing projects. |
We could also solve point 3 by publishing |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as outdated.
This comment was marked as outdated.
I also owe this issue an update but haven’t had time to write it up yet, sorry.
… On May 2, 2022, at 18:48, Nikhil Sharma ***@***.***> wrote:
@camilamacedo86
Do we need to work on this?
And if yes, is the approach described in the issue description reasonable for tackling it?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.
|
@squeed |
Hey guys, really looking forward to this, are you still working on this @squeed ? If not, would you mind if I take a look at this? |
Feel free to look at that @jakobmoellersap. |
/assign @jakobmoellersap |
One of the first things I want to mention is that its probably a breaking change and thus could be added to the list of the necessary changes in the v4-alpha scaffolding in #2547 (comment) |
Hi @jakobmoellersap, For this one, I guess that we need to change controller-tools. Have you checked it out already? WDYT about creating a comment here explaining what needs to be changed. I think would be easier to discuss if is or is not a broken change after we figure out what needs to be changed and have a proposal for that. WDYT? PS.: Note that currently go/v4-alpha is a composition of kustomize/v2-alpha and the same base language used to generate go/v3. We can generate the base language for go/v4 too (just adds a little more burn to keep maintained but at some point, we will need to do). |
Hey there, I just did a first look and I think we have a few things that we need to solve:
I will come up with a simple draft in kubebuilder next (if I can achieve it) or write here again if I find more issues. Nevertheless I think currently the only realistic way is to create a new folder with EDIT: Since the additional effort with replace statements, I decided to use I decided to try and implement this as a backwards-compatible opt-in feature into v3 since it already supports go1.18 through a CLI flag as it was the easiest to integrate. Ideally we do this already in the init step though I think (and store that information in the |
c/c @varshaprasad96 |
Learnings out of various PRs:
|
Hi @jakobmoellersap, Just to share, what ihmo would help a lot of address requirements as this one would properly handle external apis. See: #1999 |
Updated the labels accordingly since we convey that it would be better addressed via the docs. c/c @jakobmoellersap, |
Just to get this right, you basically want to have a documentation on how to import external APIs from another repository via create API through a guide @camilamacedo86 ? |
Hi @jakobmoellersap, I think we could doc that, ideally to not hurt concepts like single responsibility if a project would like to use an API that is defined/owned by another project then, the recommendation would be to work with these Kinds/APis like external types similar we could create a reconciliation for a core type. Also, we can link:
Then, we could also describe that for some specific case scenarios such as where the user would like to have an enterprise and community version of the same solution (such as the motivation of this issue) so authors have been looking for ways to import one project to another so that is not required to re-implement the same API. For this scenario, would be possible to use the go workspaces and we could describe the steps/manual changes to work with sub-modules as you did in the PR: #2901 (comment). We can provide code examples and etc. We could also add a note to warn that these changes will make it harder to keep the project updated with the latest versions and changes provided in the Kubebuilder scaffold since the process to re-scaffold the project with the lastest version and ensure that you add the code implementation on top would not be easily achievable. See: https://book.kubebuilder.io/migration/v2vsv3.html#project-customizations I think it could be a new doc under the "Reference" section such as "Sub-Module Layout" On top of that, would be great we have a new section under Reference with the content of : https://github.com/kubernetes-sigs/kubebuilder/blob/master/docs/using_an_external_type.md (if possible updated and with a note linking the issue for we officially support that) WDYT? |
That sounds great! I'll get to it and link the PR here. |
The Kubernetes project currently lacks enough contributors to adequately respond to all PRs. This bot triages PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
/remove-lifecycle stale |
We can let it be closed and have one issue with finishing the doc: #3055, since that was the solution agreed/conveyed so far. |
What do you want to happen?
When generating api types with
kubebuilder create api
, it generates the corresponding Go types in./api/v1
.However, it is unergonomic for external projects to import these types. Mostly because they need to resolve all the project's dependencies. This is especially awkward for projects that don't use
controller-runtime
, but it can also be annoying for projects that do, but have different versions.The fix for this is relatively simple:
go.mod
in./api
, thus making it, as far as Go is concerned, a separate packagereplace
directive in the rootgo.mod
sigs.k8s.io/controller-runtime/pkg/scheme
in the generated api types, which is a very thin convenience package.We can also consider using go 1.18's workspace mode, but it's not actually necessary in this case.
What did you do?
kubebuilder create api
What did you expect to see?
A standalone importable package. Something like
Furthermore, I would like to see that
api/go.mod
has almost no external dependencies (i.e.controller-runtime
).What did you see instead? Under which circumstances?
No additional go.mod, etc
Extra Labels
No response
The text was updated successfully, but these errors were encountered: