Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions pkg/generate/ack/hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ code paths:
* sdk_get_attributes_pre_set_output
* sdk_create_pre_set_output
* sdk_update_pre_set_output
* sdk_read_one_post_set_output
* sdk_read_many_post_set_output
* sdk_get_attributes_post_set_output
* sdk_create_post_set_output
* sdk_update_post_set_output

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
Expand All @@ -69,6 +74,11 @@ that is supplied to the main method, like so:
// the original Kubernetes object we passed to the function
ko := r.ko.DeepCopy()
```

The "post_set_output" hooks are called AFTER the the information from the API call
is merged with the copy of the original Kubernetes object. These hooks will
have access to the updated Kubernetes object `ko`, the response of the API call
(and the original Kubernetes CR object if its sdkUpdate)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome. :) thank you!

*/

// ResourceHookCode returns a string with custom callback code for a resource
Expand Down
3 changes: 3 additions & 0 deletions templates/pkg/resource/sdk.go.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ func (rm *resourceManager) sdkCreate(
return nil, err
}
{{ end }}
{{- if $hookCode := Hook .CRD "sdk_create_post_set_output" }}
{{ $hookCode }}
{{- end }}
return &resource{ko}, nil
}

Expand Down
3 changes: 3 additions & 0 deletions templates/pkg/resource/sdk_find_get_attributes.go.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ func (rm *resourceManager) sdkFind(
{{ $hookCode }}
{{- end }}
rm.setStatusDefaults(ko)
{{- if $hookCode := Hook .CRD "sdk_get_attributes_post_set_output" }}
{{ $hookCode }}
{{- end }}
return &resource{ko}, nil
}

Expand Down
3 changes: 3 additions & 0 deletions templates/pkg/resource/sdk_find_read_many.go.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ func (rm *resourceManager) sdkFind(
return nil, err
}
{{ end }}
{{- if $hookCode := Hook .CRD "sdk_read_many_post_set_output" }}
{{ $hookCode }}
{{- end }}
return &resource{ko}, nil
}

Expand Down
3 changes: 3 additions & 0 deletions templates/pkg/resource/sdk_find_read_one.go.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ func (rm *resourceManager) sdkFind(
return nil, err
}
{{ end }}
{{- if $hookCode := Hook .CRD "sdk_read_one_post_set_output" }}
{{ $hookCode }}
{{- end }}
return &resource{ko}, nil
}

Expand Down
3 changes: 3 additions & 0 deletions templates/pkg/resource/sdk_update.go.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ func (rm *resourceManager) sdkUpdate(
return nil, err
}
{{ end }}
{{- if $hookCode := Hook .CRD "sdk_update_post_set_output" }}
{{ $hookCode }}
{{- end }}
return &resource{ko}, nil
}

Expand Down