Skip to content
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

🐛 kubebuilder edit ignore the errors if the project layout is already on same type #1754

Merged
merged 1 commit into from
Nov 6, 2020

Conversation

prafull01
Copy link
Contributor

Description of the change

Add validation of kb edit command if the scaffolding is already on same side either multigroup: true or multigroup: false. kb edit command fails when it tries to change the Dockerfile that it doesn't find the apis or api directory respectively.

Motivation of the change
Fixes: #1747

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Oct 29, 2020
@k8s-ci-robot

This comment has been minimized.

@k8s-ci-robot k8s-ci-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Oct 29, 2020
Copy link
Member

@camilamacedo86 camilamacedo86 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not think that we should do that because:

  • The plugin/command kb edit can have more than one arg besides it has only the multigroup
  • We can enable/disable the support via kb edit --multigroup=[true or false]

However, we could check if the project has multi-group resources scaffolded already before allow remove the support. WDYT?

@prafull01
Copy link
Contributor Author

I do not think that we should do that because:

* The plugin/command kb edit can have more than one arg besides it has only the multigroup

* We can enable/disable the support via kb edit --multigroup=[true or false]

However, we could check if the project has multi-group resources scaffolded already before allow remove the support. WDYT?

The current implementation also fails if we try to edit a project which is already on the same type. Current, failure happens in the PostScaffolding of the kb edit command.

prafull@EMPID18004:~/go/src/github.com/prafull01/kubebuilder/proj$ ../bin/kubebuilder edit --multigroup=true
prafull@EMPID18004:~/go/src/github.com/prafull01/kubebuilder/proj$ ../bin/kubebuilder edit --multigroup=true
Error: failed to edit project with version "3-alpha": can't find "COPY api/ api/"
Usage:
  kubebuilder edit [flags]

Examples:
# Enable the multigroup layout
        kubebuilder edit --multigroup

        # Disable the multigroup layout
        kubebuilder edit --multigroup=false
	

Flags:
  -h, --help         help for edit
      --multigroup   enable or disable multigroup layout

2020/10/30 00:13:52 failed to edit project with version "3-alpha": can't find "COPY api/ api/"

This change will give more clear message to the user that he is already on the same type of the project layout.
Also, this change will become more important when we add #1640 . When we try to modify the layout of the project, we don't need to do anything is the project is already on the same layout.

@camilamacedo86
Copy link
Member

@prafull01, I catcher the scenario 👍
Great catcher, btw.

However, it is a really bugfix in POV. So, wdyt about update the title with :bug; and to do the same for v2?

@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Oct 29, 2020
@prafull01 prafull01 changed the title ✨ Add the validation for edit command (go/v3-alpha) 🐛 Add the validation for edit command Oct 29, 2020
@prafull01
Copy link
Contributor Author

@prafull01, I catcher the scenario +1
Great catcher, btw.

However, it is a really bugfix in POV. So, wdyt about update the title with :bug; and to do the same for v2?

Done

Copy link
Member

@camilamacedo86 camilamacedo86 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great 👍
/approve

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 29, 2020
@prafull01
Copy link
Contributor Author

@camilamacedo86 Needs /ok-to-test command to run the tests. Thanks :)

@camilamacedo86
Copy link
Member

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Oct 29, 2020
@kubernetes-sigs kubernetes-sigs deleted a comment from k8s-ci-robot Nov 1, 2020
Copy link
Member

@camilamacedo86 camilamacedo86 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/approve cancel

Hi @prafull01,

After tests and think about that more, I believe that it is not the best approach for we avoid this issue.
See that after this pr if we run kubebuilder edit it will return the issue added here instead of the helper. So, WDYT about we add a check in the Dockerfile update here to ignore the issue if the projectfile==multigroup value and the error faced is can't find "COPY?

@prafull01

This comment has been minimized.

@camilamacedo86

This comment has been minimized.

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Nov 2, 2020
@prafull01 prafull01 changed the title 🐛 Add the validation for edit command 🐛 kubebuilder edit ignore the errors if the project layout is already on same type Nov 2, 2020
Copy link
Member

@camilamacedo86 camilamacedo86 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/approve

Great work 👍

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: camilamacedo86, prafull01

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 2, 2020
@camilamacedo86
Copy link
Member

Tested locally and the bug fixed work.
Since it is a very tiny fix I think that is fine we get it merged.

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 6, 2020
@k8s-ci-robot k8s-ci-robot merged commit 8d5e286 into kubernetes-sigs:master Nov 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Validate the kubebuilder edit command for the project layout
3 participants