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

ssa: object normalization improvements #658

Merged
merged 4 commits into from
Oct 7, 2023
Merged

ssa: object normalization improvements #658

merged 4 commits into from
Oct 7, 2023

Conversation

hiddeco
Copy link
Member

@hiddeco hiddeco commented Oct 4, 2023

No description provided.

@hiddeco hiddeco force-pushed the ssa-normalize branch 4 times, most recently from d593324 to c7d0acb Compare October 5, 2023 19:11
@hiddeco hiddeco changed the title ssa: normalize improvements ssa: object normalization improvements Oct 5, 2023
@hiddeco hiddeco added enhancement New feature or request area/server-side-apply SSA related issues and pull requests labels Oct 5, 2023
@hiddeco hiddeco force-pushed the ssa-normalize branch 3 times, most recently from 044a995 to 9ad1309 Compare October 5, 2023 21:09
@hiddeco hiddeco marked this pull request as ready for review October 5, 2023 21:10
@hiddeco hiddeco requested a review from stefanprodan as a code owner October 5, 2023 21:10
@hiddeco hiddeco mentioned this pull request Oct 3, 2023
4 tasks
ssa/utils.go Show resolved Hide resolved
@hiddeco hiddeco force-pushed the ssa-normalize branch 2 times, most recently from 98b1888 to 9cb0840 Compare October 6, 2023 15:04
Copy link
Member

@stefanprodan stefanprodan left a comment

Choose a reason for hiding this comment

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

LGTM

Great refactoring, thanks @hiddeco 🥇

This allows for a single Unstructured object to be normalized, as was
already possible for a slice of objects using `SetNativeKindsDefaults`.

In addition, the further logic around normalization has be rewritten
to improve maintainability and address certain edge-case issues. More
specifically:

- Any default Kubernetes resource is normalized by converting it to a
  typed resource, and back to an Unstructured.
- Protocol default fixes have been added for Job and CronJob
  resources, which can hypothetically include port definitions.
- Instead of removing the `creationTimestamp` field, it is written to
  `nil`, to equal the default set for Unstructured objects returned
  by the converter.
- Test coverage has been added.

Signed-off-by: Hidde Beydals <[email protected]>
To facilitate fixing issues to Kubernetes resources as returned by a
server-side dry-run apply.

The behavior of the function itself equals to the previous behavior
of `fixHorizontalPodAutoscaler`. However, this is now exposed to allow
other consumers (e.g. the to be introduced `jsondiff` sub-library) to
make use of the same patches without further code duplication.

Signed-off-by: Hidde Beydals <[email protected]>
In favor of the newly added `NormalizeUnstructuredList`.

Signed-off-by: Hidde Beydals <[email protected]>
This enriches the options a consumer has to debug the error, as it now
provides access to the Unstructured which produced the error. While
also allowing the upcoming `jsondiff` sub-package to reuse and emit
the error.

Signed-off-by: Hidde Beydals <[email protected]>
@hiddeco hiddeco merged commit 18dd8fd into main Oct 7, 2023
13 checks passed
@hiddeco hiddeco deleted the ssa-normalize branch October 7, 2023 08:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/server-side-apply SSA related issues and pull requests enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants