templates: deprecate NewParse()

It it just a chain of `New("sometag").Parse(...)`, and most of our
uses don't use a tag for the template, so can call Parse.

There's no public users of this function, but deprecating it first
just in case.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn
2025-07-28 08:25:02 +02:00
parent 2f87a11e96
commit 7ab3e7e774
5 changed files with 8 additions and 7 deletions
+1 -1
View File
@@ -82,7 +82,7 @@ func buildContainerListOptions(options *psOptions) (*container.ListOptions, erro
// always validate template when `--format` is used, for consistency
if len(options.format) > 0 {
tmpl, err := templates.NewParse("", options.format)
tmpl, err := templates.Parse(options.format)
if err != nil {
return nil, errors.Wrap(err, "failed to parse template")
}
+1 -1
View File
@@ -162,7 +162,7 @@ func needsServerInfo(template string, info dockerInfo) bool {
}
// A template is provided and has at least one field set.
tmpl, err := templates.NewParse("", template)
tmpl, err := templates.Parse(template)
if err != nil {
// ignore parsing errors here, and let regular code handle them
return true
+1 -2
View File
@@ -209,8 +209,7 @@ func newVersionTemplate(templateFormat string) (*template.Template, error) {
case formatter.JSONFormatKey:
templateFormat = formatter.JSONFormat
}
tmpl := templates.New("version").Funcs(template.FuncMap{"getDetailsOrder": getDetailsOrder})
tmpl, err := tmpl.Parse(templateFormat)
tmpl, err := templates.New("version").Funcs(template.FuncMap{"getDetailsOrder": getDetailsOrder}).Parse(templateFormat)
if err != nil {
return nil, errors.Wrap(err, "template parsing error")
}