mirror of
https://github.com/containers/skopeo.git
synced 2025-09-28 21:46:48 +00:00
Bump c/common c/image and c/storage to latest
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>
This commit is contained in:
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
|
||||
|
54
vendor/github.com/containers/common/pkg/report/template.go
generated
vendored
54
vendor/github.com/containers/common/pkg/report/template.go
generated
vendored
@@ -1,6 +1,8 @@
|
||||
package report
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"reflect"
|
||||
"strings"
|
||||
"text/template"
|
||||
@@ -21,16 +23,32 @@ type FuncMap template.FuncMap
|
||||
var tableReplacer = strings.NewReplacer(
|
||||
"table ", "",
|
||||
`\t`, "\t",
|
||||
`\n`, "\n",
|
||||
" ", "\t",
|
||||
)
|
||||
|
||||
// escapedReplacer will clean up escaped characters from CLI
|
||||
var escapedReplacer = strings.NewReplacer(
|
||||
`\t`, "\t",
|
||||
`\n`, "\n",
|
||||
)
|
||||
|
||||
var DefaultFuncs = FuncMap{
|
||||
"join": strings.Join,
|
||||
"json": func(v interface{}) string {
|
||||
buf := &bytes.Buffer{}
|
||||
enc := json.NewEncoder(buf)
|
||||
enc.SetEscapeHTML(false)
|
||||
enc.Encode(v)
|
||||
// Remove the trailing new line added by the encoder
|
||||
return strings.TrimSpace(buf.String())
|
||||
},
|
||||
"lower": strings.ToLower,
|
||||
"pad": padWithSpace,
|
||||
"split": strings.Split,
|
||||
"title": strings.Title,
|
||||
"truncate": truncateWithLength,
|
||||
"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
|
||||
@@ -47,6 +65,22 @@ func NormalizeFormat(format string) string {
|
||||
return f
|
||||
}
|
||||
|
||||
// padWithSpace adds spaces*prefix and spaces*suffix to the input when it is non-empty
|
||||
func padWithSpace(source string, prefix, suffix int) string {
|
||||
if source == "" {
|
||||
return source
|
||||
}
|
||||
return strings.Repeat(" ", prefix) + source + strings.Repeat(" ", suffix)
|
||||
}
|
||||
|
||||
// truncateWithLength truncates the source string up to the length provided by the input
|
||||
func truncateWithLength(source string, length int) string {
|
||||
if len(source) < length {
|
||||
return source
|
||||
}
|
||||
return source[:length]
|
||||
}
|
||||
|
||||
// Headers queries the interface for field names.
|
||||
// Array of map is returned to support range templates
|
||||
// Note: unexported fields can be supported by adding field to overrides
|
||||
@@ -88,7 +122,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 +134,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"
|
||||
|
6
vendor/github.com/containers/common/pkg/retry/retry.go
generated
vendored
6
vendor/github.com/containers/common/pkg/retry/retry.go
generated
vendored
@@ -69,7 +69,7 @@ func isRetryable(err error) bool {
|
||||
}
|
||||
return isRetryable(e.Err)
|
||||
case syscall.Errno:
|
||||
return shouldRestart(e)
|
||||
return isErrnoRetryable(e)
|
||||
case errcode.Errors:
|
||||
// if this error is a group of errors, process them all in turn
|
||||
for i := range e {
|
||||
@@ -94,10 +94,10 @@ func isRetryable(err error) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func shouldRestart(e error) bool {
|
||||
func isErrnoRetryable(e error) bool {
|
||||
switch e {
|
||||
case syscall.ECONNREFUSED, syscall.EINTR, syscall.EAGAIN, syscall.EBUSY, syscall.ENETDOWN, syscall.ENETUNREACH, syscall.ENETRESET, syscall.ECONNABORTED, syscall.ECONNRESET, syscall.ETIMEDOUT, syscall.EHOSTDOWN, syscall.EHOSTUNREACH:
|
||||
return true
|
||||
}
|
||||
return shouldRestartPlatform(e)
|
||||
return isErrnoERESTART(e)
|
||||
}
|
||||
|
2
vendor/github.com/containers/common/pkg/retry/retry_linux.go
generated
vendored
2
vendor/github.com/containers/common/pkg/retry/retry_linux.go
generated
vendored
@@ -4,6 +4,6 @@ import (
|
||||
"syscall"
|
||||
)
|
||||
|
||||
func shouldRestartPlatform(e error) bool {
|
||||
func isErrnoERESTART(e error) bool {
|
||||
return e == syscall.ERESTART
|
||||
}
|
||||
|
2
vendor/github.com/containers/common/pkg/retry/retry_unsupported.go
generated
vendored
2
vendor/github.com/containers/common/pkg/retry/retry_unsupported.go
generated
vendored
@@ -2,6 +2,6 @@
|
||||
|
||||
package retry
|
||||
|
||||
func shouldRestartPlatform(e error) bool {
|
||||
func isErrnoERESTART(e error) bool {
|
||||
return false
|
||||
}
|
||||
|
Reference in New Issue
Block a user