You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Updates the sdk.go-specific templates to take advantage of the new
ACK runtime logger that is embedded in all Context structs passed from
the ACK runtime v0.2.3 release and after.
In working these log traces into the various sdkXXX methods, I took this
opportunity to clean up some of the ugly template conditionals in these methods
that checked to see whether an Output shape was being referenced as a
variable after calling the aws-sdk-go API calls and setting the
associated variable name to `_` in order to prevent `unused variable
declared` compilation failures.
The template code for handling this used to look like this:
```
{{ $createCode := GoCodeSetCreateOutput .CRD "resp" "ko" 1 false }}
{{ if not ( Empty $createCode ) }}resp{{ else }}_{{ end }}, respErr := rm.sdkapi.{{ .CRD.Ops.Create.ExportedName }}WithContext(ctx, input)
rm.metrics.RecordAPICall("CREATE", "{{ .CRD.Ops.Create.ExportedName }}", respErr)
if respErr != nil {
return nil, respErr
}
// Merge in the information we read from the API call above to the copy of
// the original Kubernetes object we passed to the function
ko := r.ko.DeepCopy()
{{ $createCode }}
```
but now is simpler and easier to read:
```
var resp {{ .CRD.GetOutputShapeGoType .CRD.Ops.Create }}
resp, err = rm.sdkapi.{{ .CRD.Ops.Create.ExportedName }}WithContext(ctx, input)
rm.metrics.RecordAPICall("CREATE", "{{ .CRD.Ops.Create.ExportedName }}", err)
if err != nil {
return nil, err
}
// Merge in the information we read from the API call above to the copy of
// the original Kubernetes object we passed to the function
ko := desired.ko.DeepCopy()
{{ GoCodeSetCreateOutput .CRD "resp" "ko" 1 false }}
```
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
0 commit comments