Skip to content

Commit b6d98fa

Browse files
authored
Merge pull request #45 from surajkota/post_output_hoook
hook for post_set_output
2 parents 4aed99b + 66128dd commit b6d98fa

File tree

6 files changed

+25
-0
lines changed

6 files changed

+25
-0
lines changed

pkg/generate/ack/hook.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ code paths:
4545
* sdk_get_attributes_pre_set_output
4646
* sdk_create_pre_set_output
4747
* sdk_update_pre_set_output
48+
* sdk_read_one_post_set_output
49+
* sdk_read_many_post_set_output
50+
* sdk_get_attributes_post_set_output
51+
* sdk_create_post_set_output
52+
* sdk_update_post_set_output
4853
4954
The "pre_build_request" hooks are called BEFORE the call to construct
5055
the Input shape that is used in the API operation and therefore BEFORE
@@ -69,6 +74,11 @@ that is supplied to the main method, like so:
6974
// the original Kubernetes object we passed to the function
7075
ko := r.ko.DeepCopy()
7176
```
77+
78+
The "post_set_output" hooks are called AFTER the the information from the API call
79+
is merged with the copy of the original Kubernetes object. These hooks will
80+
have access to the updated Kubernetes object `ko`, the response of the API call
81+
(and the original Kubernetes CR object if its sdkUpdate)
7282
*/
7383

7484
// ResourceHookCode returns a string with custom callback code for a resource

templates/pkg/resource/sdk.go.tpl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ func (rm *resourceManager) sdkCreate(
8383
return nil, err
8484
}
8585
{{ end }}
86+
{{- if $hookCode := Hook .CRD "sdk_create_post_set_output" }}
87+
{{ $hookCode }}
88+
{{- end }}
8689
return &resource{ko}, nil
8790
}
8891

templates/pkg/resource/sdk_find_get_attributes.go.tpl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ func (rm *resourceManager) sdkFind(
3838
{{ $hookCode }}
3939
{{- end }}
4040
rm.setStatusDefaults(ko)
41+
{{- if $hookCode := Hook .CRD "sdk_get_attributes_post_set_output" }}
42+
{{ $hookCode }}
43+
{{- end }}
4144
return &resource{ko}, nil
4245
}
4346

templates/pkg/resource/sdk_find_read_many.go.tpl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ func (rm *resourceManager) sdkFind(
3838
return nil, err
3939
}
4040
{{ end }}
41+
{{- if $hookCode := Hook .CRD "sdk_read_many_post_set_output" }}
42+
{{ $hookCode }}
43+
{{- end }}
4144
return &resource{ko}, nil
4245
}
4346

templates/pkg/resource/sdk_find_read_one.go.tpl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ func (rm *resourceManager) sdkFind(
4545
return nil, err
4646
}
4747
{{ end }}
48+
{{- if $hookCode := Hook .CRD "sdk_read_one_post_set_output" }}
49+
{{ $hookCode }}
50+
{{- end }}
4851
return &resource{ko}, nil
4952
}
5053

templates/pkg/resource/sdk_update.go.tpl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ func (rm *resourceManager) sdkUpdate(
4545
return nil, err
4646
}
4747
{{ end }}
48+
{{- if $hookCode := Hook .CRD "sdk_update_post_set_output" }}
49+
{{ $hookCode }}
50+
{{- end }}
4851
return &resource{ko}, nil
4952
}
5053

0 commit comments

Comments
 (0)