Skip to content

Commit

Permalink
Merge pull request #114 from kumargauravsharma/delete-api-change
Browse files Browse the repository at this point in the history
Returning the latest resource from the Delete() call
  • Loading branch information
jaypipes authored Jul 12, 2021
2 parents 901c958 + f29b01f commit 1423dc8
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ GO111MODULE=on
AWS_SERVICE=$(shell echo $(SERVICE) | tr '[:upper:]' '[:lower:]')

# Build ldflags
VERSION ?= "v0.4.0"
VERSION ?= "v0.5.0"
GITCOMMIT=$(shell git rev-parse HEAD)
BUILDDATE=$(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
IMPORT_PATH=github.com/aws-controllers-k8s/code-generator
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/aws-controllers-k8s/code-generator
go 1.14

require (
github.com/aws-controllers-k8s/runtime v0.4.0
github.com/aws-controllers-k8s/runtime v0.5.0
github.com/aws/aws-sdk-go v1.37.4
github.com/dlclark/regexp2 v1.4.0
// pin to v0.1.1 due to release problem with v0.1.2
Expand Down
5 changes: 3 additions & 2 deletions templates/pkg/resource/manager.go.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,12 @@ func (rm *resourceManager) Update(
}
// Delete attempts to destroy the supplied AWSResource in the backend AWS
// service API.
// service API, returning an AWSResource representing the
// resource being deleted (if delete is asynchronous and takes time)
func (rm *resourceManager) Delete(
ctx context.Context,
res acktypes.AWSResource,
) error {
) (acktypes.AWSResource, error) {
r := rm.concreteResource(res)
if r.ko == nil {
// Should never happen... if it does, it's buggy code.
Expand Down
13 changes: 7 additions & 6 deletions templates/pkg/resource/sdk.go.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func (rm *resourceManager) newCreateRequestPayload(
func (rm *resourceManager) sdkDelete(
ctx context.Context,
r *resource,
) (err error) {
) (latest *resource, err error) {
rlog := ackrtlog.FromContext(ctx)
exit := rlog.Trace("rm.sdkDelete")
defer exit(err)
Expand All @@ -136,25 +136,26 @@ func (rm *resourceManager) sdkDelete(
{{- end }}
{{- if $customMethod := .CRD.GetCustomImplementation .CRD.Ops.Delete }}
if err = rm.{{ $customMethod }}(ctx, r); err != nil {
return err
return nil, err
}
{{- end }}
input, err := rm.newDeleteRequestPayload(r)
if err != nil {
return err
return nil, err
}
{{- if $hookCode := Hook .CRD "sdk_delete_post_build_request" }}
{{ $hookCode }}
{{- end }}
_, err = rm.sdkapi.{{ .CRD.Ops.Delete.Name }}WithContext(ctx, input)
var resp {{ .CRD.GetOutputShapeGoType .CRD.Ops.Delete }}; _ = resp;
resp, err = rm.sdkapi.{{ .CRD.Ops.Delete.Name }}WithContext(ctx, input)
rm.metrics.RecordAPICall("DELETE", "{{ .CRD.Ops.Delete.Name }}", err)
{{- if $hookCode := Hook .CRD "sdk_delete_post_request" }}
{{ $hookCode }}
{{- end }}
return err
return nil, err
{{- else }}
// TODO(jaypipes): Figure this out...
return nil
return nil, nil
{{ end }}
}

Expand Down

0 comments on commit 1423dc8

Please sign in to comment.