-
Notifications
You must be signed in to change notification settings - Fork 331
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
Allow Unstructured callback from Defaulting Webhook #2363
Allow Unstructured callback from Defaulting Webhook #2363
Conversation
Signed-off-by: Pierangelo Di Pilato <[email protected]>
Codecov Report
@@ Coverage Diff @@
## main #2363 +/- ##
==========================================
- Coverage 63.66% 63.35% -0.32%
==========================================
Files 228 226 -2
Lines 9854 9855 +1
==========================================
- Hits 6274 6244 -30
- Misses 3305 3323 +18
- Partials 275 288 +13
Continue to review full report at Codecov.
|
Signed-off-by: Pierangelo Di Pilato <[email protected]>
Signed-off-by: Pierangelo Di Pilato <[email protected]>
Signed-off-by: Pierangelo Di Pilato <[email protected]>
fd777cc
to
b2524a0
Compare
#1672 |
Signed-off-by: Pierangelo Di Pilato <[email protected]>
Flake in GH action #1509 |
Signed-off-by: Pierangelo Di Pilato <[email protected]>
@julz @markusthoemmes can you please review this PR since Dave is on vacation? |
Signed-off-by: Pierangelo Di Pilato <[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.
some minor things
@@ -50,3 +53,28 @@ func setUserInfoAnnotations(ctx context.Context, resource apis.HasSpec, groupNam | |||
} | |||
} | |||
} | |||
|
|||
// setUserInfoAnnotationsUnstructured sets creator and updater annotations on a resource. | |||
func setUserInfoAnnotationsUnstructured(ctx context.Context, after *unstructured.Unstructured, before *unstructured.Unstructured, req *admissionv1.AdmissionRequest) { |
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.
UnstructuredContent()
returns the whole object as a map so the equality.semantic.DeepEqual
call isn't the same as the other helper - which is just comparing the spec
when updating the UpdaterAnnotation
.
I wonder if it's simpler to just wrap unstructured in a special type that returns the spec
to satisfy apis.HasSpec
and use the other helper.
Also unstructured objects conform to metav1.Object
so there are methods for GetAnnotations
, SetAnnotations
etc.
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.
Done in 8cc1192
I didn't want to expose this adapter to API users so it is only used internally.
r.Spec.FieldForCallbackDefaulting = "magic value" | ||
// THIS IS NOT WHO IS CREATING IT, IT LIES! | ||
r.Annotations = map[string]string{ | ||
"pkg.knative.dev/lastModifier": user2, | ||
} |
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.
Should this be set given that the resource is being 'created' and not 'updated'?
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.
if I understand your question, it was set
{
Operation: "replace",
Path: "/spec/fieldDefaultingCallback",
Value: "I'm a default",
}
The problem is that the json tag was called differently from the field name of the struct.
I pushed a new commit to fix it.
Signed-off-by: Pierangelo Di Pilato <[email protected]>
Signed-off-by: Pierangelo Di Pilato <[email protected]>
9b393b9
to
b186600
Compare
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: dprotaso, pierDipi 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 |
Issue #1140
Proposed Changes
Allow Defaulting webhook to register generic Unstructured callbacks so that implementers can create generic defaulting logic outside of the APIs package.
This will later be used in Eventing Kafka Broker.
Changes
Release Note