Skip to content

Commit 735a36c

Browse files
authored
Add pre/post compare hooks for newResourceDelta function (#72)
Issue aws-controllers-k8s/community#796 Description of changes: - Add pre/post compare hooks for `newResourceDelta` function By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent cf8f94f commit 735a36c

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

pkg/generate/ack/hook.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,15 @@ code paths:
5656
* sdk_get_attributes_post_set_output
5757
* sdk_create_post_set_output
5858
* sdk_update_post_set_output
59+
* delta_pre_compare
60+
* delta_post_compare
5961
6062
The "pre_build_request" hooks are called BEFORE the call to construct
6163
the Input shape that is used in the API operation and therefore BEFORE
6264
any call to validate that Input shape.
6365
64-
The "post_build_request" hooks are called AFTER the call to construct
65-
the Input shape but BEFORE the API operation.
66+
The "post_build_request" hooks are called AFTER the call to construct
67+
the Input shape but BEFORE the API operation.
6668
6769
The "post_request" hooks are called IMMEDIATELY AFTER the API operation
6870
aws-sdk-go client call. These hooks will have access to a Go variable
@@ -88,6 +90,13 @@ The "post_set_output" hooks are called AFTER the the information from the API ca
8890
is merged with the copy of the original Kubernetes object. These hooks will
8991
have access to the updated Kubernetes object `ko`, the response of the API call
9092
(and the original Kubernetes CR object if its sdkUpdate)
93+
94+
The "delta_pre_compare" hooks are called BEFORE the generated code that
95+
compares two resources.
96+
97+
The "delta_post_compare" hooks are called AFTER the generated code that
98+
compares two resources.
99+
91100
*/
92101

93102
// ResourceHookCode returns a string with custom callback code for a resource

templates/pkg/resource/delta.go.tpl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@ func newResourceDelta(
1818
delta.Add("", a, b)
1919
return delta
2020
}
21+
22+
{{- if $hookCode := Hook .CRD "delta_pre_compare" }}
23+
{{ $hookCode }}
24+
{{- end }}
2125
{{ GoCodeCompare .CRD "delta" "a.ko" "b.ko" 1}}
26+
{{- if $hookCode := Hook .CRD "delta_post_compare" }}
27+
{{ $hookCode }}
28+
{{- end }}
2229
return delta
2330
}

0 commit comments

Comments
 (0)