Skip to content

Commit

Permalink
Merge pull request #45 from surajkota/post_output_hoook
Browse files Browse the repository at this point in the history
hook for post_set_output
  • Loading branch information
jaypipes authored Apr 19, 2021
2 parents 4aed99b + 66128dd commit b6d98fa
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 0 deletions.
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)
*/

// 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

0 comments on commit b6d98fa

Please sign in to comment.