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

Implement logic to add checks for conversion webhooks under tests/e2e using kubebuilder:scaffold:e2e-webhooks-checks #4317

Closed
camilamacedo86 opened this issue Nov 10, 2024 · 1 comment · Fixed by #4407
Assignees
Labels
kind/feature Categorizes issue or PR as related to a new feature.
Milestone

Comments

@camilamacedo86
Copy link
Member

What do you want to happen?

Under the tests/e2e folder have the checks to validate CA injection for conversion webhooks inject via the kubebuilder marker kubebuilder:scaffold: e2e-webhooks-checks, similarly to how we check CA injection for mutating and validating webhooks: https://github.com/kubernetes-sigs/kubebuilder/blob/master/testdata/project-v4/test/e2e/e2e_test.go#L247-L273

See an example of how this check can be done at: https://github.com/kubernetes-sigs/kubebuilder/blob/master/testdata/project-v4/test/e2e/e2e_test.go#L247-L273.

Also, for reference, see the code used to inject the tests using the marker:

func (f *WebhookTestUpdater) GetCodeFragments() machinery.CodeFragmentsMap {
codeFragments := machinery.CodeFragmentsMap{}
if !f.WireWebhook {
return nil
}
codeFragments[machinery.NewMarkerFor(f.GetPath(), webhookChecksMarker)] = append(
codeFragments[machinery.NewMarkerFor(f.GetPath(), webhookChecksMarker)],
webhookChecksFragment,
)
if f.Resource != nil && f.Resource.HasDefaultingWebhook() {
mutatingWebhookCode := fmt.Sprintf(mutatingWebhookChecksFragment, f.ProjectName)
codeFragments[machinery.NewMarkerFor(f.GetPath(), webhookChecksMarker)] = append(
codeFragments[machinery.NewMarkerFor(f.GetPath(), webhookChecksMarker)],
mutatingWebhookCode,
)
}
if f.Resource.HasValidationWebhook() {
validatingWebhookCode := fmt.Sprintf(validatingWebhookChecksFragment, f.ProjectName)
codeFragments[machinery.NewMarkerFor(f.GetPath(), webhookChecksMarker)] = append(
codeFragments[machinery.NewMarkerFor(f.GetPath(), webhookChecksMarker)],
validatingWebhookCode,
)
}
return codeFragments
}

Extra Labels

No response

@camilamacedo86 camilamacedo86 added the kind/feature Categorizes issue or PR as related to a new feature. label Nov 10, 2024
@camilamacedo86 camilamacedo86 added this to the webhook milestone Nov 25, 2024
@mateusoliveira43
Copy link
Contributor

/assign

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Categorizes issue or PR as related to a new feature.
Projects
None yet
2 participants