From 9b1682622927ff168c37a6cb91f584b5d42a9383 Mon Sep 17 00:00:00 2001 From: John Beisley Date: Wed, 8 Jun 2022 07:05:49 +0100 Subject: [PATCH] Refactor service template. --- v2alpha/srv/srv.gotemplate | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/v2alpha/srv/srv.gotemplate b/v2alpha/srv/srv.gotemplate index a0ecc96..17f684c 100644 --- a/v2alpha/srv/srv.gotemplate +++ b/v2alpha/srv/srv.gotemplate @@ -1,5 +1,5 @@ {{define "service"}} -{{- $Imps := .Imps}} +{{- $Imps := .Imps -}} package {{.Manifest.Package}} import ( @@ -13,18 +13,19 @@ import ( {{end}} {{define "action"}} -type {{.Action.Name}}Request struct { -{{- template "args" args "Args" .Action.InArgs "Imps" .Imps}} -} +{{- $Imps := .Imps}} +type {{.Action.Name}}Request struct +{{- template "args" args "Args" .Action.InArgs "Imps" $Imps}} -type {{.Action.Name}}Response struct { -{{- template "args" args "Args" .Action.OutArgs "Imps" .Imps}} -} +type {{.Action.Name}}Response struct +{{- template "args" args "Args" .Action.OutArgs "Imps" $Imps}} {{- end}} {{define "args"}} -{{- $Imps := .Imps}} -{{- range .Args}} +{{- $Imps := .Imps -}} +{ {{- with .Args}} +{{- range .}} {{.Name}} {{index $Imps.TypeRefByTypeName .RelatedStateVariable.DataType}} {{- end}} +{{end -}} } {{- end}}