Skip to content

Commit a6ae207

Browse files
authored
Inject missing code hook points in set attributes (#434)
The sdkUpdate method template for attribute-based APIs was missing the custom hook point injections. This patch adds them in. This is necessary for support of tags in SQS controller. Issue aws-controllers-k8s/community#1541 Signed-off-by: Jay Pipes <[email protected]>
1 parent fa24753 commit a6ae207

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

templates/pkg/resource/sdk_update_set_attributes.go.tpl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ func (rm *resourceManager) sdkUpdate(
1212
exit(err)
1313
}()
1414

15+
{{- if $hookCode := Hook .CRD "sdk_update_pre_build_request" }}
16+
{{ $hookCode }}
17+
{{- end }}
1518
// If any required fields in the input shape are missing, AWS resource is
1619
// not created yet. And sdkUpdate should never be called if this is the
1720
// case, and it's an error in the generated code if it is...
@@ -23,12 +26,18 @@ func (rm *resourceManager) sdkUpdate(
2326
if err != nil {
2427
return nil, err
2528
}
29+
{{- if $hookCode := Hook .CRD "sdk_update_post_build_request" }}
30+
{{ $hookCode }}
31+
{{- end }}
2632

2733
// NOTE(jaypipes): SetAttributes calls return a response but they don't
2834
// contain any useful information. Instead, below, we'll be returning a
2935
// DeepCopy of the supplied desired state, which should be fine because
3036
// that desired state has been constructed from a call to GetAttributes...
3137
_, respErr := rm.sdkapi.{{ .CRD.Ops.SetAttributes.ExportedName }}WithContext(ctx, input)
38+
{{- if $hookCode := Hook .CRD "sdk_update_post_request" }}
39+
{{ $hookCode }}
40+
{{- end }}
3241
rm.metrics.RecordAPICall("SET_ATTRIBUTES", "{{ .CRD.Ops.SetAttributes.ExportedName }}", respErr)
3342
if respErr != nil {
3443
if awsErr, ok := ackerr.AWSError(respErr); ok && awsErr.Code() == "{{ ResourceExceptionCode .CRD 404 }}" {{ GoCodeSetExceptionMessageCheck .CRD 404 }}{
@@ -42,7 +51,13 @@ func (rm *resourceManager) sdkUpdate(
4251
// Merge in the information we read from the API call above to the copy of
4352
// the original Kubernetes object we passed to the function
4453
ko := desired.ko.DeepCopy()
54+
{{- if $hookCode := Hook .CRD "sdk_update_pre_set_output" }}
55+
{{ $hookCode }}
56+
{{- end }}
4557
rm.setStatusDefaults(ko)
58+
{{- if $hookCode := Hook .CRD "sdk_update_post_set_output" }}
59+
{{ $hookCode }}
60+
{{- end }}
4661
return &resource{ko}, nil
4762
}
4863

0 commit comments

Comments
 (0)