Skip to content

Commit

Permalink
Update template to use newer versions of functions
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianczech committed Mar 25, 2024
1 parent 54794c2 commit e6c6700
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 31 deletions.
32 changes: 17 additions & 15 deletions templates/sdk/config.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,10 @@
{{- if ne $version ""}}
{{- if eq $index 1}}
if vn.Gte(version{{createGoSuffixFromVersion $version}}) {
return SpecifyConfig, &configXmlContainer{{createGoSuffixFromVersion $version}}{}, nil
return SpecifyConfig{{createGoSuffixFromVersion $version}}, &configXmlContainer{{createGoSuffixFromVersion $version}}{}, nil
{{- else}}
} else if vn.Gte(version{{createGoSuffixFromVersion $version}}) {
return SpecifyConfig, &configXmlContainer{{createGoSuffixFromVersion $version}}{}, nil
return SpecifyConfig{{createGoSuffixFromVersion $version}}, &configXmlContainer{{createGoSuffixFromVersion $version}}{}, nil
{{- end}}
{{- end}}
{{- end}}
Expand All @@ -118,20 +118,22 @@
{{- end}}
}

func SpecifyConfig(o Config) (any, error) {
config := configXml{}
{{- range $version := .SupportedVersions }}
func SpecifyConfig{{createGoSuffixFromVersion $version}}(o Config) (any, error) {
config := configXml{{createGoSuffixFromVersion $version}}{}

{{- range $_, $param := .Spec.Params}}
{{specifyEntryAssignment "config" $param}}
{{- end}}
{{- range $_, $param := .Spec.OneOf}}
{{specifyEntryAssignment "config" $param}}
{{- end}}
{{- range $_, $param := $.Spec.Params}}
{{specifyEntryAssignment "config" $param $version}}
{{- end}}
{{- range $_, $param := $.Spec.OneOf}}
{{specifyEntryAssignment "config" $param $version}}
{{- end}}

config.Misc = o.Misc["Config"]
config.Misc = o.Misc["Config"]

return config, nil
}
return config, nil
}
{{- end}}

{{- range $version := .SupportedVersions }}
func (c *configXmlContainer{{createGoSuffixFromVersion $version}}) Normalize() ([]Config, error) {
Expand All @@ -141,10 +143,10 @@
Misc: make(map[string][]generic.Xml),
}
{{- range $_, $param := $.Spec.Params}}
{{normalizeAssignment "config" $param}}
{{normalizeAssignment "config" $param $version}}
{{- end}}
{{- range $_, $param := $.Spec.OneOf}}
{{normalizeAssignment "config" $param}}
{{normalizeAssignment "config" $param $version}}
{{- end}}

config.Misc["Config"] = o.Misc
Expand Down
34 changes: 18 additions & 16 deletions templates/sdk/entry.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,10 @@
{{- if ne $version ""}}
{{- if eq $index 1}}
if vn.Gte(version{{createGoSuffixFromVersion $version}}) {
return SpecifyEntry, &entryXmlContainer{{createGoSuffixFromVersion $version}}{}, nil
return SpecifyEntry{{createGoSuffixFromVersion $version}}, &entryXmlContainer{{createGoSuffixFromVersion $version}}{}, nil
{{- else}}
} else if vn.Gte(version{{createGoSuffixFromVersion $version}}) {
return SpecifyEntry, &entryXmlContainer{{createGoSuffixFromVersion $version}}{}, nil
return SpecifyEntry{{createGoSuffixFromVersion $version}}, &entryXmlContainer{{createGoSuffixFromVersion $version}}{}, nil
{{- end}}
{{- end}}
{{- end}}
Expand All @@ -157,21 +157,23 @@
{{- end}}
}

func SpecifyEntry(o Entry) (any, error) {
entry := entryXml{}
{{- range $version := .SupportedVersions }}
func SpecifyEntry{{createGoSuffixFromVersion $version}}(o Entry) (any, error) {
entry := entryXml{{createGoSuffixFromVersion $version}}{}

entry.Name = o.Name
{{- range $_, $param := .Spec.Params}}
{{specifyEntryAssignment "entry" $param}}
{{- end}}
{{- range $_, $param := .Spec.OneOf}}
{{specifyEntryAssignment "entry" $param}}
{{- end}}
entry.Name = o.Name
{{- range $_, $param := $.Spec.Params}}
{{specifyEntryAssignment "entry" $param $version}}
{{- end}}
{{- range $_, $param := $.Spec.OneOf}}
{{specifyEntryAssignment "entry" $param $version}}
{{- end}}

entry.Misc = o.Misc["Entry"]
entry.Misc = o.Misc["Entry"]

return entry, nil
}
return entry, nil
}
{{- end}}

{{- range $version := .SupportedVersions }}
func (c *entryXmlContainer{{createGoSuffixFromVersion $version}}) Normalize() ([]Entry, error) {
Expand All @@ -182,10 +184,10 @@
}
entry.Name = o.Name
{{- range $_, $param := $.Spec.Params}}
{{normalizeAssignment "entry" $param}}
{{normalizeAssignment "entry" $param $version}}
{{- end}}
{{- range $_, $param := $.Spec.OneOf}}
{{normalizeAssignment "entry" $param}}
{{normalizeAssignment "entry" $param $version}}
{{- end}}

entry.Misc["Entry"] = o.Misc
Expand Down

0 comments on commit e6c6700

Please sign in to comment.