Skip to content

Commit 18843e6

Browse files
Add Dereference template function (#230)
Description of changes: This PR adds a Go template function for de-referencing strings. Go templates do not, out of the box, support string de-referencing when doing string comparison. When comparing a string pointer to a pointer it gives a fatal type mismatch error. By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent af5f01e commit 18843e6

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

pkg/generate/ack/controller.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ var (
5353
controllerCopyPaths = []string{}
5454
controllerFuncMap = ttpl.FuncMap{
5555
"ToLower": strings.ToLower,
56+
"Dereference": func(s *string) string {
57+
return *s
58+
},
5659
"ResourceExceptionCode": func(r *ackmodel.CRD, httpStatusCode int) string {
5760
return r.ExceptionCode(httpStatusCode)
5861
},

0 commit comments

Comments
 (0)