kubebuilder icon indicating copy to clipboard operation
kubebuilder copied to clipboard

Skippable test scaffolding on `create (api|webhook)`

Open migueleliasweb opened this issue 10 months ago • 8 comments
trafficstars

What do you want to happen?

Context

Giving the ability to skip test creation would allow users who have diverged from the original test scaffolding without facing the error when creating new APIs.

Currently, it seems like the create api|webhook commands require the test/e2e/e2e_test.go to exist and they will also create a <kind>_test.go in every call.

When creating a new webhok after having moved the test/e2e/e2e_test.go files somewhere else, this error is shown:

FATA failed to create webhook: unable to scaffold with "base.go.kubebuilder.io/v4": open test/e2e/e2e_test.go: no such file or directory 

The current workaround is to create an empty file in that location, just so kubebuilder is happy enough to run the command.

Ps: I know the idea here is to create a plugin for kubebuilder but I don't quite have that need yet. It would be nice if I could just keep using the default scaffolding without having to have empty files laying around.

Proposal

My proposal is to create a --skip-test-scaffolding flag for create (api|webhook) calls.

Extra Labels

No response

migueleliasweb avatar Jan 20 '25 07:01 migueleliasweb

Hi @migueleliasweb

Thank you for raise this one. That is happing because we have markers for the tests now; https://github.com/kubernetes-sigs/kubebuilder/blob/master/testdata/project-v4/test/e2e/e2e_test.go#L316

But I agree 100%. In this case, we should WARNING and say that we are unable to scaffold e2e tests for webhooks since the path was not found.

Would you like to push a PR for this one?

camilamacedo86 avatar Jan 26 '25 11:01 camilamacedo86

This one is similar to: https://github.com/kubernetes-sigs/kubebuilder/pull/4518 But see that in the e2e tests we have markers to add tests

+kubebuilder:scaffold:e2e-webhooks-checks

So, we need to see if we can not fail and warn when the tests are not found.

camilamacedo86 avatar Feb 01 '25 19:02 camilamacedo86

Hi @mateusoliveira43,

I noticed you’ve worked on similar areas, and I just wanted to bring this one to your attention. It might be a good fit for you if you have the bandwidth to help out.

Please don’t feel obligated at all, but if you’d like to pitch in, your help would be greatly appreciated and would mean a lot! 🥇

camilamacedo86 avatar Feb 01 '25 19:02 camilamacedo86

Hi @camilamacedo86 , I don't think I'll be able to work on this for the next week or two. If until then it's not done, I'm happy to give it a go.

migueleliasweb avatar Feb 01 '25 21:02 migueleliasweb

/assign

adarshagrawal38 avatar Feb 24 '25 13:02 adarshagrawal38

Hi @camilamacedo86 , I'm currently occupied with other work and won't be able to take on this issue for now.

adarshagrawal38 avatar Mar 06 '25 05:03 adarshagrawal38

/unassign

adarshagrawal38 avatar Mar 06 '25 05:03 adarshagrawal38

/assign

p-shah256 avatar Apr 01 '25 19:04 p-shah256

@camilamacedo86 Hi, I’d like to start working on this issue. Assigning it to myself.

/assign

pabhi18 avatar Jul 01 '25 06:07 pabhi18