Bump github.com/containers/storage from 1.26.0 to 1.29.0

Bumps [github.com/containers/storage](https://github.com/containers/storage) from 1.26.0 to 1.29.0.
- [Release notes](https://github.com/containers/storage/releases)
- [Changelog](https://github.com/containers/storage/blob/master/docs/containers-storage-changes.md)
- [Commits](https://github.com/containers/storage/compare/v1.26.0...v1.29.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
dependabot-preview[bot]
2021-04-13 08:44:26 +00:00
committed by Daniel J Walsh
parent cfbabac961
commit 5485daff13
678 changed files with 44368 additions and 5994 deletions

View File

@@ -22,9 +22,7 @@ import (
func GetDefaultAuthFile() string {
authfile := os.Getenv("REGISTRY_AUTH_FILE")
if authfile == "" {
if authfile, ok := os.LookupEnv("DOCKER_CONFIG"); ok {
logrus.Infof("Using DOCKER_CONFIG environment variable for authfile path %s", authfile)
}
authfile = os.Getenv("DOCKER_CONFIG")
}
return authfile
}

View File

@@ -7,6 +7,7 @@ package capabilities
import (
"strings"
"sync"
"github.com/pkg/errors"
"github.com/syndtr/gocapability/capability"
@@ -16,6 +17,9 @@ var (
// Used internally and populated during init().
capabilityList []string
// Used internally and populated during init().
capsList []capability.Cap
// ErrUnknownCapability is thrown when an unknown capability is processed.
ErrUnknownCapability = errors.New("unknown capability")
@@ -24,10 +28,14 @@ var (
ContainerImageLabels = []string{"io.containers.capabilities"}
)
// All is a special value used to add/drop all known capababilities.
// All is a special value used to add/drop all known capabilities.
// Useful on the CLI for `--cap-add=all` etc.
const All = "ALL"
func getCapName(c capability.Cap) string {
return "CAP_" + strings.ToUpper(c.String())
}
func init() {
last := capability.CAP_LAST_CAP
// hack for RHEL6 which has no /proc/sys/kernel/cap_last_cap
@@ -38,7 +46,8 @@ func init() {
if cap > last {
continue
}
capabilityList = append(capabilityList, "CAP_"+strings.ToUpper(cap.String()))
capsList = append(capsList, cap)
capabilityList = append(capabilityList, getCapName(cap))
}
}
@@ -52,6 +61,38 @@ func stringInSlice(s string, sl []string) bool {
return false
}
var (
boundingSetOnce sync.Once
boundingSetRet []string
boundingSetErr error
)
// BoundingSet returns the capabilities in the current bounding set
func BoundingSet() ([]string, error) {
boundingSetOnce.Do(func() {
currentCaps, err := capability.NewPid2(0)
if err != nil {
boundingSetErr = err
return
}
err = currentCaps.Load()
if err != nil {
boundingSetErr = err
return
}
var r []string
for _, c := range capsList {
if !currentCaps.Get(capability.BOUNDING, c) {
continue
}
r = append(r, getCapName(c))
}
boundingSetRet = r
boundingSetErr = err
})
return boundingSetRet, boundingSetErr
}
// AllCapabilities returns all known capabilities.
func AllCapabilities() []string {
return capabilityList
@@ -88,7 +129,7 @@ func ValidateCapabilities(caps []string) error {
return nil
}
// MergeCapabilities computes a set of capabilities by adding capapbitilities
// MergeCapabilities computes a set of capabilities by adding capabilities
// to or dropping them from base.
//
// Note that:
@@ -122,7 +163,7 @@ func MergeCapabilities(base, adds, drops []string) ([]string, error) {
if stringInSlice(All, capAdd) {
// "Add" all capabilities;
return capabilityList, nil
return BoundingSet()
}
for _, add := range capAdd {

View File

@@ -139,3 +139,17 @@ func AutocompleteOS(cmd *cobra.Command, args []string, toComplete string) ([]str
completions := []string{"linux", "windows"}
return completions, cobra.ShellCompDirectiveNoFileComp
}
// AutocompleteJSONFormat - Autocomplete format flag option.
// -> "json"
func AutocompleteJSONFormat(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
return []string{"json"}, cobra.ShellCompDirectiveNoFileComp
}
// AutocompleteOneArg - Autocomplete one random arg
func AutocompleteOneArg(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
if len(args) == 1 {
return nil, cobra.ShellCompDirectiveDefault
}
return nil, cobra.ShellCompDirectiveNoFileComp
}

View File

@@ -1,7 +1,10 @@
package report
import (
"bytes"
"encoding/json"
"reflect"
"regexp"
"strings"
"text/template"
@@ -21,22 +24,30 @@ 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,
"lower": strings.ToLower,
"split": strings.Split,
"title": strings.Title,
"upper": strings.ToUpper,
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
@@ -55,6 +66,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
@@ -96,7 +123,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: template.New(name).Funcs(template.FuncMap(defaultFuncs))}
return &Template{Template: template.New(name).Funcs(template.FuncMap(DefaultFuncs))}
}
// Parse parses text as a template body for t
@@ -108,7 +135,7 @@ func (t *Template) Parse(text string) (*Template, error) {
text = NormalizeFormat(text)
}
tt, err := t.Template.Funcs(template.FuncMap(defaultFuncs)).Parse(text)
tt, err := t.Template.Funcs(template.FuncMap(DefaultFuncs)).Parse(text)
return &Template{tt, t.isTable}, err
}
@@ -116,7 +143,7 @@ func (t *Template) Parse(text string) (*Template, error) {
// A default template function will be replace if there is a key collision.
func (t *Template) Funcs(funcMap FuncMap) *Template {
m := make(FuncMap)
for k, v := range defaultFuncs {
for k, v := range DefaultFuncs {
m[k] = v
}
for k, v := range funcMap {
@@ -129,3 +156,18 @@ func (t *Template) Funcs(funcMap FuncMap) *Template {
func (t *Template) IsTable() bool {
return t.isTable
}
var rangeRegex = regexp.MustCompile(`{{\s*range\s*\.\s*}}.*{{\s*end\s*}}`)
// EnforceRange ensures that the format string contains a range
func EnforceRange(format string) string {
if !rangeRegex.MatchString(format) {
return "{{range .}}" + format + "{{end}}"
}
return format
}
// HasTable returns whether the format is a table
func HasTable(format string) bool {
return strings.HasPrefix(format, "table ")
}