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

Improve envTest for validation webhooks #494

Merged

Conversation

fmount
Copy link
Contributor

@fmount fmount commented Mar 29, 2024

This patch fixes the isValidEndpoint function provided by the validation webhook and introduces envTests for Validation webhooks that are one of the most important part of the operator.

@fmount fmount requested a review from abays March 29, 2024 11:55
@openshift-ci openshift-ci bot requested review from konan-abhi and lewisdenny March 29, 2024 11:55
@@ -205,6 +198,11 @@ func (r *Glance) ValidateCreate() (admission.Warnings, error) {
return nil, errors.New("Invalid backend configuration detected")
}
}
// At creation time, if the CR has an invalid keystoneEndpoint value (that
// doesn't match with any defined backend), return an error.
if !r.Spec.isValidKeystoneEP() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This function iterates over the API, no need to iterate multiple times, so I put it outside of the for loop.

// At update time, if the CR has an invalid keystoneEndpoint set
// (e.g. an Edge GlanceAPI instance that can't be registered in keystone)
// return an error message
if !r.Spec.isValidKeystoneEP() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

same comment, we already iterate over the API within the function, no need to stay within an external for loop (that represents the same iteration!)

@fmount fmount marked this pull request as draft March 29, 2024 12:00
This patch fixes the isValidEndpoint function provided by the validation
webhook and introduces envTests for Validation webhooks, that are one of
the most important part of the operator.

Signed-off-by: Francesco Pantano <[email protected]>
@fmount fmount marked this pull request as ready for review March 29, 2024 14:48
@openshift-ci openshift-ci bot requested a review from fultonj March 29, 2024 14:48
Copy link
Contributor

@konan-abhi konan-abhi left a comment

Choose a reason for hiding this comment

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

Looks good, thank you!

Copy link
Contributor

openshift-ci bot commented Mar 30, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: fmount, konan-abhi

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

@fmount
Copy link
Contributor Author

fmount commented Apr 1, 2024

/test glance-operator-build-deploy-kuttl

1 similar comment
@fmount
Copy link
Contributor Author

fmount commented Apr 1, 2024

/test glance-operator-build-deploy-kuttl

@openshift-merge-bot openshift-merge-bot bot merged commit e5cff17 into openstack-k8s-operators:main Apr 2, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants