mirror of
https://github.com/containers/skopeo.git
synced 2025-09-03 15:46:42 +00:00
Bump github.com/containers/common from 0.33.1 to 0.34.0
Bumps [github.com/containers/common](https://github.com/containers/common) from 0.33.1 to 0.34.0. - [Release notes](https://github.com/containers/common/releases) - [Commits](https://github.com/containers/common/compare/v0.33.1...v0.34.0) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
committed by
Daniel J Walsh
parent
3375a905cc
commit
4ab7faa800
12
vendor/github.com/containers/common/pkg/report/doc.go
generated
vendored
12
vendor/github.com/containers/common/pkg/report/doc.go
generated
vendored
@@ -38,7 +38,17 @@ Helpers:
|
||||
... process JSON and output
|
||||
}
|
||||
|
||||
and
|
||||
Template Functions:
|
||||
|
||||
The following template functions are added to the template when parsed:
|
||||
- join strings.Join, {{join .Field separator}}
|
||||
- lower strings.ToLower {{ .Field | lower }}
|
||||
- split strings.Split {{ .Field | split }}
|
||||
- title strings.Title {{ .Field | title }}
|
||||
- upper strings.ToUpper {{ .Field | upper }}
|
||||
|
||||
report.Funcs() may be used to add additional template functions.
|
||||
Adding an existing function will replace that function for the life of that template.
|
||||
|
||||
|
||||
Note: Your code should not ignore errors
|
||||
|
24
vendor/github.com/containers/common/pkg/report/template.go
generated
vendored
24
vendor/github.com/containers/common/pkg/report/template.go
generated
vendored
@@ -31,6 +31,14 @@ var escapedReplacer = strings.NewReplacer(
|
||||
`\n`, "\n",
|
||||
)
|
||||
|
||||
var defaultFuncs = FuncMap{
|
||||
"join": strings.Join,
|
||||
"lower": strings.ToLower,
|
||||
"split": strings.Split,
|
||||
"title": strings.Title,
|
||||
"upper": strings.ToUpper,
|
||||
}
|
||||
|
||||
// NormalizeFormat reads given go template format provided by CLI and munges it into what we need
|
||||
func NormalizeFormat(format string) string {
|
||||
var f string
|
||||
@@ -88,7 +96,7 @@ func Headers(object interface{}, overrides map[string]string) []map[string]strin
|
||||
|
||||
// NewTemplate creates a new template object
|
||||
func NewTemplate(name string) *Template {
|
||||
return &Template{template.New(name), false}
|
||||
return &Template{Template: template.New(name).Funcs(template.FuncMap(defaultFuncs))}
|
||||
}
|
||||
|
||||
// Parse parses text as a template body for t
|
||||
@@ -100,13 +108,21 @@ func (t *Template) Parse(text string) (*Template, error) {
|
||||
text = NormalizeFormat(text)
|
||||
}
|
||||
|
||||
tt, err := t.Template.Parse(text)
|
||||
tt, err := t.Template.Funcs(template.FuncMap(defaultFuncs)).Parse(text)
|
||||
return &Template{tt, t.isTable}, err
|
||||
}
|
||||
|
||||
// Funcs adds the elements of the argument map to the template's function map
|
||||
// Funcs adds the elements of the argument map to the template's function map.
|
||||
// A default template function will be replace if there is a key collision.
|
||||
func (t *Template) Funcs(funcMap FuncMap) *Template {
|
||||
return &Template{t.Template.Funcs(template.FuncMap(funcMap)), t.isTable}
|
||||
m := make(FuncMap)
|
||||
for k, v := range defaultFuncs {
|
||||
m[k] = v
|
||||
}
|
||||
for k, v := range funcMap {
|
||||
m[k] = v
|
||||
}
|
||||
return &Template{Template: t.Template.Funcs(template.FuncMap(m)), isTable: t.isTable}
|
||||
}
|
||||
|
||||
// IsTable returns true if format string defines a "table"
|
||||
|
Reference in New Issue
Block a user