Skip to content

Commit e0dc6c3

Browse files
authored
add hooks for set identifiers (#459)
1 parent e9b6859 commit e0dc6c3

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

pkg/generate/ack/hook.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ code paths:
6969
* convert_tags_post_to_ack_tags
7070
* convert_tags_pre_from_ack_tags
7171
* convert_tags_post_from_ack_tags
72+
* pre_set_resource_identifiers
73+
* post_set_resource_identifiers
7274
7375
The "pre_build_request" hooks are called BEFORE the call to construct
7476
the Input shape that is used in the API operation and therefore BEFORE
@@ -143,6 +145,12 @@ tags into K8s resource tags
143145
144146
The "convert_tags_post_from_ack_tags" are called after converting the ACK
145147
tags into K8s resource tags
148+
149+
The "pre_set_resource_identifiers" hook is called before the generated code
150+
that sets the resource identifiers to uniquely identify a resource
151+
152+
The "post_set_resource_identifiers" hook is called after the generated code
153+
that sets the resource identifiers to uniquely identify a resource
146154
*/
147155

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

templates/pkg/resource/resource.go.tpl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,13 @@ func (r *resource) SetStatus(desired acktypes.AWSResource) {
7272
// SetIdentifiers sets the Spec or Status field that is referenced as the unique
7373
// resource identifier
7474
func (r *resource) SetIdentifiers(identifier *ackv1alpha1.AWSIdentifiers) error {
75+
{{- if $hookCode := Hook .CRD "pre_set_resource_identifiers" }}
76+
{{ $hookCode }}
77+
{{- end }}
7578
{{- GoCodeSetResourceIdentifiers .CRD "identifier" "r.ko" 1}}
79+
{{- if $hookCode := Hook .CRD "post_set_resource_identifiers" }}
80+
{{ $hookCode }}
81+
{{- end }}
7682
return nil
7783
}
7884

0 commit comments

Comments
 (0)