-
Notifications
You must be signed in to change notification settings - Fork 38
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
Improve envTest for validation webhooks #494
Conversation
@@ -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() { |
There was a problem hiding this comment.
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() { |
There was a problem hiding this comment.
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!)
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]>
There was a problem hiding this 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!
[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 |
/test glance-operator-build-deploy-kuttl |
1 similar comment
/test glance-operator-build-deploy-kuttl |
e5cff17
into
openstack-k8s-operators:main
This patch fixes the
isValidEndpoint
function provided by the validationwebhook
and introducesenvTests
for Validation webhooks that are one of the most important part of the operator.