diff --git a/pkg/generate/ack/hook.go b/pkg/generate/ack/hook.go index 575c2a38..2ce49887 100644 --- a/pkg/generate/ack/hook.go +++ b/pkg/generate/ack/hook.go @@ -34,6 +34,12 @@ code paths: * sdk_create_pre_build_request * sdk_update_pre_build_request * sdk_delete_pre_build_request +* sdk_read_one_post_build_request +* sdk_read_many_post_build_request +* sdk_get_attributes_post_build_request +* sdk_create_post_build_request +* sdk_update_post_build_request +* sdk_delete_post_build_request * sdk_read_one_post_request * sdk_read_many_post_request * sdk_get_attributes_post_request @@ -55,6 +61,9 @@ The "pre_build_request" hooks are called BEFORE the call to construct the Input shape that is used in the API operation and therefore BEFORE any call to validate that Input shape. +The "post_build_request" hooks are called AFTER the call to construct +the Input shape but BEFORE the API operation. + The "post_request" hooks are called IMMEDIATELY AFTER the API operation aws-sdk-go client call. These hooks will have access to a Go variable named `resp` that refers to the aws-sdk-go client response and a Go diff --git a/templates/pkg/resource/sdk.go.tpl b/templates/pkg/resource/sdk.go.tpl index 97266f04..4872672e 100644 --- a/templates/pkg/resource/sdk.go.tpl +++ b/templates/pkg/resource/sdk.go.tpl @@ -59,6 +59,9 @@ func (rm *resourceManager) sdkCreate( if err != nil { return nil, err } +{{- if $hookCode := Hook .CRD "sdk_create_post_build_request" }} +{{ $hookCode }} +{{- end }} {{ $createCode := GoCodeSetCreateOutput .CRD "resp" "ko" 1 false }} {{ if not ( Empty $createCode ) }}resp{{ else }}_{{ end }}, respErr := rm.sdkapi.{{ .CRD.Ops.Create.Name }}WithContext(ctx, input) {{- if $hookCode := Hook .CRD "sdk_create_post_request" }} diff --git a/templates/pkg/resource/sdk_find_get_attributes.go.tpl b/templates/pkg/resource/sdk_find_get_attributes.go.tpl index 89ee5700..1c6d9374 100644 --- a/templates/pkg/resource/sdk_find_get_attributes.go.tpl +++ b/templates/pkg/resource/sdk_find_get_attributes.go.tpl @@ -17,6 +17,9 @@ func (rm *resourceManager) sdkFind( if err != nil { return nil, err } +{{- if $hookCode := Hook .CRD "sdk_get_attributes_post_build_request" }} +{{ $hookCode }} +{{- end }} {{ $setCode := GoCodeGetAttributesSetOutput .CRD "resp" "ko" 1 }} {{ if not ( Empty $setCode ) }}resp{{ else }}_{{ end }}, respErr := rm.sdkapi.{{ .CRD.Ops.GetAttributes.Name }}WithContext(ctx, input) {{- if $hookCode := Hook .CRD "sdk_get_attributes_post_request" }} diff --git a/templates/pkg/resource/sdk_find_read_many.go.tpl b/templates/pkg/resource/sdk_find_read_many.go.tpl index 4346d944..4be394ac 100644 --- a/templates/pkg/resource/sdk_find_read_many.go.tpl +++ b/templates/pkg/resource/sdk_find_read_many.go.tpl @@ -10,6 +10,9 @@ func (rm *resourceManager) sdkFind( if err != nil { return nil, err } +{{- if $hookCode := Hook .CRD "sdk_read_many_post_build_request" }} +{{ $hookCode }} +{{- end }} {{ $setCode := GoCodeSetReadManyOutput .CRD "resp" "ko" 1 true }} {{ if not ( Empty $setCode ) }}resp{{ else }}_{{ end }}, respErr := rm.sdkapi.{{ .CRD.Ops.ReadMany.Name }}WithContext(ctx, input) {{- if $hookCode := Hook .CRD "sdk_read_many_post_request" }} diff --git a/templates/pkg/resource/sdk_find_read_one.go.tpl b/templates/pkg/resource/sdk_find_read_one.go.tpl index 985125d4..236f04a0 100644 --- a/templates/pkg/resource/sdk_find_read_one.go.tpl +++ b/templates/pkg/resource/sdk_find_read_one.go.tpl @@ -17,6 +17,9 @@ func (rm *resourceManager) sdkFind( if err != nil { return nil, err } +{{- if $hookCode := Hook .CRD "sdk_read_one_post_build_request" }} +{{ $hookCode }} +{{- end }} {{ $setCode := GoCodeSetReadOneOutput .CRD "resp" "ko" 1 true }} {{ if not ( Empty $setCode ) }}resp{{ else }}_{{ end }}, respErr := rm.sdkapi.{{ .CRD.Ops.ReadOne.Name }}WithContext(ctx, input) {{- if $hookCode := Hook .CRD "sdk_read_one_post_request" }} @@ -52,7 +55,7 @@ func (rm *resourceManager) sdkFind( } // requiredFieldsMissingFromReadOneInput returns true if there are any fields -// for the ReadOne Input shape that are required by not present in the +// for the ReadOne Input shape that are required but not present in the // resource's Spec or Status func (rm *resourceManager) requiredFieldsMissingFromReadOneInput( r *resource, diff --git a/templates/pkg/resource/sdk_update.go.tpl b/templates/pkg/resource/sdk_update.go.tpl index 7dd79298..4fc4cf3d 100644 --- a/templates/pkg/resource/sdk_update.go.tpl +++ b/templates/pkg/resource/sdk_update.go.tpl @@ -20,7 +20,9 @@ func (rm *resourceManager) sdkUpdate( if err != nil { return nil, err } - +{{- if $hookCode := Hook .CRD "sdk_update_pre_build_request" }} +{{ $hookCode }} +{{- end }} {{ $setCode := GoCodeSetUpdateOutput .CRD "resp" "ko" 1 false }} {{ if not ( Empty $setCode ) }}resp{{ else }}_{{ end }}, respErr := rm.sdkapi.{{ .CRD.Ops.Update.Name }}WithContext(ctx, input) {{- if $hookCode := Hook .CRD "sdk_update_post_request" }}