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

First pass at enforcing "required" fields in PUT requests #49

Merged
merged 4 commits into from
Apr 10, 2024

Conversation

mbarnes
Copy link
Collaborator

@mbarnes mbarnes commented Apr 9, 2024

What this PR does

Before this PR:

Required fields from the OpenAPI spec for HCP clusters were not enforced in PUT requests.

After this PR:

Introduces a new validation struct tag required_for_put and ensures these fields are "non-zero" in PUT requests, both when creating and updating a cluster. Also updates validation error details in HTTP responses to explain missing required fields.

Jira: partially completes ARO-6347

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.

  • PR: The PR description is expressive enough and will help future contributors
  • Code: Write code that humans can understand and Keep it simple
  • Refactor: You have left the code cleaner than you found it (Boy Scout Rule)
  • Upgrade: Impact of this change on upgrade flows was considered and addressed if required
  • Deployment: The deployment process was considered and addressed if required
  • Testing: New code requires new unit tests.
  • Documentation: Is the documentation updated? Either in the doc located in focus area, in the README or in the code itself.
  • Customers: Is this change affecting customers? Is the release plan considered?

Matthew Barnes added 4 commits April 9, 2024 15:36
In validation error details, check specifically for an "enum_"
prefix on the tag name instead of assuming "anyof" is an enum
alias. Just to be more precise to avoid potential future bugs.
Reorder and add parameter for HTTP method.
An updating PUT request must be a complete resource specification.
The old version of the resource only comes into play when applying
idempotency to read-only or create-only fields in an update request,
but this has not yet been implemented.
@mbarnes mbarnes force-pushed the required-for-put branch from 8644b0b to 4f3d40b Compare April 9, 2024 19:39
@mbarnes mbarnes merged commit 9c6acc0 into Azure:main Apr 10, 2024
4 checks passed
@mbarnes mbarnes deleted the required-for-put branch April 10, 2024 12:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants