-
Notifications
You must be signed in to change notification settings - Fork 58
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
Add static validation to middleware #106
Conversation
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 overall, just some minor requests to reduce code duplication and unnecessary imports.
|
||
if resourceName != "" { | ||
if !rxResourceGroupName.MatchString(resourceName) { | ||
arm.WriteError(w, http.StatusBadRequest, arm.CloudErrorCodeResourceNotFound, "", "The Resource '%s/%s/%s' under resource group '%s' was not found.", resourceProviderNamespace, resourceType, resourceName, resourceGroupName) |
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 doesn't actually check if the resourceName exists within a resourceGroup. If we are trying to validate the resourceName, we should have an error message tailored to the check. Do the resourceGroup and resourceName have the same requirements?
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.
Each resource has their own requirements. The resource group one is a good upper limit. I can also narrow it down to this from the api spec:
"name": "hcpOpenShiftClusterName",
"in": "path",
"description": "Name of HCP cluster",
"required": true,
"type": "string",
"minLength": 3,
"maxLength": 24,
"pattern": "^[a-zA-Z0-9-]{3,24}$"
}
Please rebase pull request. |
Please rebase pull request. |
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.
Hi @katherinelc321 thank you for doing the extra validation. I agree it is important to do it right from the start. Overall the PR is on a good path with some minor tweaks needed. Would you please look at the comments ?
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.
Some more changes are needed, see comments below.
tl;dr The path segment constants you're adding are not being used in the route patterns, so those path values will not be set. I make a case for why they may not be necessary anyway.
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.
LGTM now, thanks!
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.
Thank you for making those changes, lgtm!
What this PR does
Before this PR:
Not enough static validation on the frontend
After this PR:
Added validation for subscription ID, resource name, resource group name
Jira: ARO-5736
Link to demo recording:
Special notes for your reviewer
Checklist
This checklist is not enforcing, but it's a reminder of items that could be relevant to every PR.
Approvers are expected to review this list.