-
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
Package Root #932
Comments
I suspect this'll have to wait until after we clean up the scaffolding code -- it'd add to the mess to implement this right now. That being said, while I'm not against supporting this, I'd like to note that "pkg" isn't necessarily the "one true way" to do Go projects. Moving away from "pkg" was somewhat intentional -- while it was clear to Kubernetes contributors, the "pkg" and "cmd" bifrucation wasn't always clear to external users, who looked for a main.go file. |
Agreed that it's not the only way, but personally I feel like the That said though, I completely understand how serving everyone is difficult and there is never going to be the perfect solution. Appreciate the willingness to look into supporting this. Once the code is ready for more changes like this, I'm also happy to help implement this! Would enjoy getting more plugged in to the community. |
/priority important-longterm |
/cc |
Can two locations be considered? Root for |
at a certain point, too many configuration settings makes this a bit weird. KB itself is supposed to be a recommendation for how to use things -- it's one of the reasons we try hard to keep generic stuff in controller-tools and controller-runtime, so that more complex and/or project-specific layouts can be used. We'll have to weigh the costs of "how do we prevent this from becoming a free-for-all" with each of the options. |
HI @DirectXMan12, Could/Should we do it now as well or add to v3 project? |
prob v3 (or in a plugin) if we decide to do it at all. |
Issues go stale after 90d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
/lifecycle frozen |
@DirectXMan12 @mengqiy @droot can any of you add this to "scaffolding-v3" milestone, it seems I can't do it |
done |
you need to be a maintainer to use |
This seems like a decent candidate to use as a test for plugins phase 2 -- it's mostly a matter of preference, and should be something that's easily doable under our general deisgn currently. |
Hi @DirectXMan12, I have been thinking about it. Personally, I do not believe that it could be addressed in the plugins phase 2 because who is asking it are the end-users who are looking for to use the Kubebuilder tool to scaffold the projects in this layout. Then, the plugins are useful for who is looking for this project as a lib to create their tools extending it such as SDK. Also, I think that allows changing the path to scaffold the files will increase the complexity of the plugin phase 2 and would make hard address stories such as I'd like to build my project with kubebuilder but use the SDK features to integrate it with OLM. Also, regards the argumentation over it be a matter of preference than shows that many folks have from the community has this preference since this change would make the scaffolded project follow up common practices. See for example; https://github.com/golang-standards/project-layout#pkg |
Plugins phase 2 will most likely involve out-of-tree plugins. That means that we could have an example plugin for "scaffold under pkg".
I'm not following, can you clarify here? Under what we've brainstormed for phase 2, this should be fairly trivial -- receive the world object, rewrite all |
Hi @DirectXMan12, So, your idea is that the user could choose, I mean have an option in the KB commands to choose the plugin option to do scaffold as A or B or C. Am I right? Then, I agree that if other tools extending it also would still able to work with the N available options. |
@camilamacedo86 while I'm not exactly certain what the final shape of plugins part 2 would be, I'd expect you'd end up having the "move everything to |
We have been discussing this issue. And we are thinking about accepting this one and changing the default layout into go/v4-alpha. Also, a suggestion made was to scaffold the controllers under the pkg/internal path. Therefore, we will check it out better and we will raise this again in the next meeting to see if we can agree to a final decision. Please, feel free to attend if you would like to speak about it. More info |
Glad to hear it @camilamacedo86. I'm definitely in favor of the change, particularly to put the controllers under |
…munity in the layout - Add a new golang language base plugin (base.go/v4) - Change the go/v4-alpha plugin to use the new base - Address the layout changes requirements for go/v4. Now, the api and controllers are under the pkg dir. - Change the Makefile to install kustomize with go install - Remove crdVersion and webhook versions that is not supported and should no longer be served. Closes: kubernetes-sigs#932 Closes: kubernetes-sigs#2531 Closes: kubernetes-sigs#2822
…munity in the layout - Add a new golang language base plugin (base.go/v4) - Change the go/v4-alpha plugin to use the new base - Address the layout changes requirements for go/v4. Now, the api and controllers are under the pkg dir. - Change the Makefile to install kustomize with go install - Remove crdVersion and webhook versions that is not supported and should no longer be served. Closes: kubernetes-sigs#932 Closes: kubernetes-sigs#2531 Closes: kubernetes-sigs#2822
…munity in the layout - Add a new golang language base plugin (base.go/v4) - Change the go/v4-alpha plugin to use the new base - Address the layout changes requirements for go/v4. Now, the api and controllers are under the pkg dir. - Change the Makefile to install kustomize with go install - Remove crdVersion and webhook versions that is not supported and should no longer be served. Closes: kubernetes-sigs#932 Closes: kubernetes-sigs#2531 Closes: kubernetes-sigs#2822
…munity in the layout - Add a new golang language base plugin (base.go/v4) - Change the go/v4-alpha plugin to use the new base - Address the layout changes requirements for go/v4. Now, the api and controllers are under the pkg dir. - Change the Makefile to install kustomize with go install - Remove crdVersion and webhook versions that is not supported and should no longer be served. Closes: kubernetes-sigs#932 Closes: kubernetes-sigs#2531 Closes: kubernetes-sigs#2822
…munity in the layout - Add a new golang language base plugin (base.go/v4) - Change the go/v4-alpha plugin to use the new base - Address the layout changes requirements for go/v4. Now, the api and controllers are under the pkg dir. - Change the Makefile to install kustomize with go install - Remove crdVersion and webhook versions that is not supported and should no longer be served. Closes: kubernetes-sigs#932 Closes: kubernetes-sigs#2531 Closes: kubernetes-sigs#2822
…munity in the layout - Add a new golang language base plugin (base.go/v4) - Change the go/v4-alpha plugin to use the new base - Address the layout changes requirements for go/v4. Now, the api and controllers are under the pkg dir. - Change the Makefile to install kustomize with go install - Remove crdVersion and webhook versions that is not supported and should no longer be served. Closes: kubernetes-sigs#932 Closes: kubernetes-sigs#2531 Closes: kubernetes-sigs#2822
…munity in the layout - Add a new golang language base plugin (base.go/v4) - Change the go/v4-alpha plugin to use the new base - Address the layout changes requirements for go/v4. Now, the api and controllers are under the pkg dir. - Change the Makefile to install kustomize with go install - Remove crdVersion and webhook versions that is not supported and should no longer be served. Closes: kubernetes-sigs#932 Closes: kubernetes-sigs#2531 Closes: kubernetes-sigs#2822
…munity in the layout - Add a new golang language base plugin (base.go/v4) - Change the go/v4-alpha plugin to use the new base - Address the layout changes requirements for go/v4. Now, the api and controllers are under the pkg dir. - Change the Makefile to install kustomize with go install - Remove crdVersion and webhook versions that is not supported and should no longer be served. Closes: kubernetes-sigs#932 Closes: kubernetes-sigs#2531 Closes: kubernetes-sigs#2822
…munity in the layout - Add a new golang language base plugin (base.go/v4) - Change the go/v4-alpha plugin to use the new base - Address the layout changes requirements for go/v4. Now, the api and controllers are under the pkg dir. - Change the Makefile to install kustomize with go install - Remove crdVersion and webhook versions that is not supported and should no longer be served. Closes: kubernetes-sigs#932 Closes: kubernetes-sigs#2531 Closes: kubernetes-sigs#2822
Regards adding the controllers under internal:
c/c @shaneutt |
…munity in the layout - Add a new golang language base plugin (base.go/v4) - Change the go/v4-alpha plugin to use the new base - Address the layout changes requirements for go/v4. Now, the api and controllers are under the pkg dir. - Change the Makefile to install kustomize with go install - Remove crdVersion and webhook versions that is not supported and should no longer be served. Closes: kubernetes-sigs#932 Closes: kubernetes-sigs#2531 Closes: kubernetes-sigs#2822
…munity in the layout - Add a new golang language base plugin (base.go/v4) - Change the go/v4-alpha plugin to use the new base - Address the layout changes requirements for go/v4. Now, the api and controllers are under the pkg dir. - Change the Makefile to install kustomize with go install - Remove crdVersion and webhook versions that is not supported and should no longer be served. Closes: kubernetes-sigs#932 Closes: kubernetes-sigs#2531 Closes: kubernetes-sigs#2822
You can. Internal packages are accessible by packages sharing the path of its parent. Anything under Some people may still prefer to have controllers under |
…munity in the layout - Add a new golang language base plugin (base.go/v4) - Change the go/v4-alpha plugin to use the new base - Address the layout changes requirements for go/v4. Now, the api and controllers are under the pkg dir. - Change the Makefile to install kustomize with go install - Remove crdVersion and webhook versions that is not supported and should no longer be served. Closes: kubernetes-sigs#932 Closes: kubernetes-sigs#2822
…munity in the layout - Add a new golang language base plugin (base.go/v4) - Change the go/v4-alpha plugin to use the new base - Address the layout changes requirements for go/v4. Now, the api and controllers are under the pkg dir. - Change the Makefile to install kustomize with go install - Remove crdVersion and webhook versions that is not supported and should no longer be served. Closes: kubernetes-sigs#932 Closes: kubernetes-sigs#2822
Hi @jgillich,
That is not achievable via Makefile or PROJECT one and it is out of scope. Note that users might want to create their own plugins and tools as well. So that they can define other's layouts and use them with kubebuilder CLI (using plugins phase 2 which is implemented already, see: https://github.com/kubernetes-sigs/kubebuilder/blob/master/designs/extensible-cli-and-scaffolding-plugins-phase-2.md) |
One thing I've never been clear on, is why is this type of option so hard to add to |
Hi @shaneutt,
The project is a scaffold. Then, editing the PROJECT file will NOT change what was done already. However, if you see options please, feel free to push a design doc and/or PR (better yet) with any implementation that you have in mind so we are able to have a better idea and discuss the approach. |
To me it just seems like you would set in the project where your directory is, and while that action alone of course wouldn't change what was done already, it should allow the tooling to look there instead of the default place. e.g. the following workflow seems like something we should be able to make work:
@camilamacedo86 I (or one of my colleagues) may be able to put in a PR/KEP for this, but could you provide some assistance by pointing out some of the places in code where the directory structure is determined/handled? This could help provide something of a map to get started on this voyage and I would appreciate it if you could. 🙇 |
HI @shaneutt,
The files are scaffolded in the places where all plugins and the tool will be able to work with and support the operations such as markers and etc. See, for example, the comment: #932 (comment) Add new specs to the PROJECT file, for them to allow/request users to do manual changes, as implement all CLI options, configurations like controller-gen as any plugin to be able to do the next actions accordingly is not maintainable and sustainable. We have no way (IMHO) to support that. We should only support what is possible to get done 100% by the tool. My vote is -1 for this approach. Also, this issue is for us to discuss the default scaffold layout. I am OK with us adding the pkg as requested by the community and as conveyed before in this one. Then, to allow people to do their own customized scaffolds and helpers we added an API where kubebuilder can be used as LIB and allow anyone to create their own plugins that do the scaffolds as please them or that add things on top such as it is done by Operator-SDK. Note that with plugins phase 2 (https://github.com/kubernetes-sigs/kubebuilder/blob/master/designs/extensible-cli-and-scaffolding-plugins-phase-2.md) which is implemented already, anyone can create their own plugin that does the scaffolds as desired. Therefore, users can re-use all Kubebuilder implementations to make them simple and easily maintainable and then, use their external plugin(s) with Kubebuilder. So, we can support the API and the default options. |
A PR was done with the request to add the api/controllers under the pkg directory: #2985 Please, feel free to check it out. The next step is to check the pros/cons and decide if we will not move forward with attending to the request made by the community. |
Based in the community feedback and latest discussions the convey for the layout changes to the new go/v4 plugin (see: #2985 (comment)) is:
... |
Add the ability to set the Go package root. Currently
api
andcontroller
is created in the root of the project. It would be nice to be able to specify putting these packages inpkg
to maintain good Go hygiene./kind feature
The text was updated successfully, but these errors were encountered: