-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
pkg/plugin/v3: use repo instead of directory basename as project name #1596
pkg/plugin/v3: use repo instead of directory basename as project name #1596
Conversation
/test pull-kubebuilder-e2e-k8s-1-17-0 |
Hi @estroz, If we allow for Kubebuilder the repo be just the project name then how this scenario will work for the templates where is expected have the go path? See for example, https://github.com/kubernetes-sigs/kubebuilder/blob/master/pkg/plugin/v3/scaffolds/internal/templates/main.go#L154 and https://github.com/kubernetes-sigs/kubebuilder/blob/master/pkg/plugin/v2/scaffolds/internal/templates/gomod.go#L47 |
@camilamacedo86 this PR isn't actually changing anything material. IMO the |
Hi @estroz, The validation occurs because the dir name is used to create the resources as the namespace. So, if we do not ensure that the project dir which is the project name has a valid DSN name than I believe that issues will be faced after. If I can remember it has an issue raised here in the repo. |
@camilamacedo86 yes and that's a problem because an operator project can be checked out in an arbitrary directory. This PR fixes that problem because it uses the |
Yep, I catcher your change. It shows fine for me. Adding /hold to allow you merge as when you wish. |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: camilamacedo86, estroz The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
The /hold did not work and the prow was not re-trigged as default :-( |
Does this PR need to be reverted for more discussion? |
@camilamacedo86 @estroz Does this assume a 1:1 repo to project model? Is this fixing the problem, or shifting the problem to a different set of users? |
@pwittrock my logic for this change is that the basename of a repo path is often more descriptive of a project than the directory name the project was created in, is consistent across git checkouts, and can be DNS 1123-compliant without requiring the directory name be so. Are there scenarios where that isn't true, and directory should be used? I'm effectively trying to work around the lack of having a "project name" stored somewhere in |
@estroz I am a bit rusty, thanks for helping with the context. Being able to explicitly specify the project name makes sense to me. Optionally decoupling the namespace from the project name also makes sense. How is the base directory name not consistent across git checkouts -- shouldn't it be the same for each clone of the git repo? Is the following understanding of the changes in this PR correct? Before: 2 different projects hosted in the same git repo -- different project names
The project name would be
The project name would be Now: 2 different projects hosted in the same git repo -- same project name
The project name would be
The project name would also be |
@pwittrock the git repo path and Go module path (set in the PROJECT's |
Also:
|
I liked the idea to add the flag |
Asking for the project name makes sense to me. I think either defaulting it to the repo name if unspecified or making it required are fine. |
Hi, @pwittrock and @estroz, So, If I understood the consensus here is:
Am I right? |
That sounds good to me. I don't feel strongly about the dir vs repo naming, except that changing it might break existing user's workflows. If we could be reasonably confident that the repo-name was generally preferred by users and was unlikely to unhappily surprise existing users I'd be fine with the repo as a default name. Since this only impacts the init command, it is not going to break existing projects, and would more likely just surprise users. @estroz WDYT of this -- we provide the flag now, default to the dir, and switch to the default to be the repo for kubebuilder v3? |
@pwittrock that sounds good to me. This should be a v3 plugin thing too, not an addition to the v2 plugin. |
When I create a project, I want to be able to specify my project name. Furthermore I would like to create/work on my project in an arbitrary directory. Instead of adding a flag to support setting project name, use the basename of
--repo
which is more likely to be the desired project name than the directory name./cc @DirectXMan12 @hasbro17 @camilamacedo86