From 2544a4ba4b04e1d386914411bddff8b85c0a4dc3 Mon Sep 17 00:00:00 2001 From: Sebastian Czech Date: Tue, 26 Mar 2024 15:55:07 +0100 Subject: [PATCH] Add comment for MarshalXML in config template --- templates/sdk/config.tmpl | 47 +++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/templates/sdk/config.tmpl b/templates/sdk/config.tmpl index cf077704..305d9336 100644 --- a/templates/sdk/config.tmpl +++ b/templates/sdk/config.tmpl @@ -144,32 +144,31 @@ } {{- end}} - // MarshalXML customized implementation of XML marshal due to requirement to skip - as root for configuration settings - func (c configXml) MarshalXML(e *xml.Encoder, start xml.StartElement) error { - {{- range $_, $param := $.Spec.Params}} - if c.{{$param.Name.CamelCase}} != nil { - start.Name = xml.Name{Local: "{{xmlName $param}}"} - if err := e.EncodeElement(c.{{$param.Name.CamelCase}}, start); err != nil { - return err - } - } - {{- end}} - {{- range $_, $param := $.Spec.OneOf}} - if c.{{$param.Name.CamelCase}} != nil { - start.Name = xml.Name{Local: "{{xmlName $param}}"} - if err := e.EncodeElement(c.{{$param.Name.CamelCase}}, start); err != nil { - return err - } - } - {{- end}} - - for _, v := range c.Misc { - if err := e.Encode(v); err != nil { + // MarshalXML customized implementation of XML marshal due to requirement to skip 'system' as root for configuration settings + func (c configXml) MarshalXML(e *xml.Encoder, start xml.StartElement) error { + {{- range $_, $param := $.Spec.Params}} + if c.{{$param.Name.CamelCase}} != nil { + start.Name = xml.Name{Local: "{{xmlName $param}}"} + if err := e.EncodeElement(c.{{$param.Name.CamelCase}}, start); err != nil { return err } } - - return nil + {{- end}} + {{- range $_, $param := $.Spec.OneOf}} + if c.{{$param.Name.CamelCase}} != nil { + start.Name = xml.Name{Local: "{{xmlName $param}}"} + if err := e.EncodeElement(c.{{$param.Name.CamelCase}}, start); err != nil { + return err } + } + {{- end}} + + for _, v := range c.Misc { + if err := e.Encode(v); err != nil { + return err + } + } + + return nil + } {{- end}} \ No newline at end of file