mirror of
https://github.com/containers/skopeo.git
synced 2025-09-03 23:55:21 +00:00
Update module github.com/containers/common to v0.51.0
Signed-off-by: Renovate Bot <bot@renovateapp.com>
This commit is contained in:
committed by
Miloslav Trmač
parent
fe15a36ed9
commit
afbdaf8ecb
48
vendor/github.com/containers/common/pkg/report/camelcase/camelcase.go
generated
vendored
48
vendor/github.com/containers/common/pkg/report/camelcase/camelcase.go
generated
vendored
@@ -13,37 +13,37 @@ import (
|
||||
//
|
||||
// Examples
|
||||
//
|
||||
// "" => [""]
|
||||
// "lowercase" => ["lowercase"]
|
||||
// "Class" => ["Class"]
|
||||
// "MyClass" => ["My", "Class"]
|
||||
// "MyC" => ["My", "C"]
|
||||
// "HTML" => ["HTML"]
|
||||
// "PDFLoader" => ["PDF", "Loader"]
|
||||
// "AString" => ["A", "String"]
|
||||
// "SimpleXMLParser" => ["Simple", "XML", "Parser"]
|
||||
// "vimRPCPlugin" => ["vim", "RPC", "Plugin"]
|
||||
// "GL11Version" => ["GL", "11", "Version"]
|
||||
// "99Bottles" => ["99", "Bottles"]
|
||||
// "May5" => ["May", "5"]
|
||||
// "BFG9000" => ["BFG", "9000"]
|
||||
// "BöseÜberraschung" => ["Böse", "Überraschung"]
|
||||
// "Two spaces" => ["Two", " ", "spaces"]
|
||||
// "BadUTF8\xe2\xe2\xa1" => ["BadUTF8\xe2\xe2\xa1"]
|
||||
// "" => [""]
|
||||
// "lowercase" => ["lowercase"]
|
||||
// "Class" => ["Class"]
|
||||
// "MyClass" => ["My", "Class"]
|
||||
// "MyC" => ["My", "C"]
|
||||
// "HTML" => ["HTML"]
|
||||
// "PDFLoader" => ["PDF", "Loader"]
|
||||
// "AString" => ["A", "String"]
|
||||
// "SimpleXMLParser" => ["Simple", "XML", "Parser"]
|
||||
// "vimRPCPlugin" => ["vim", "RPC", "Plugin"]
|
||||
// "GL11Version" => ["GL", "11", "Version"]
|
||||
// "99Bottles" => ["99", "Bottles"]
|
||||
// "May5" => ["May", "5"]
|
||||
// "BFG9000" => ["BFG", "9000"]
|
||||
// "BöseÜberraschung" => ["Böse", "Überraschung"]
|
||||
// "Two spaces" => ["Two", " ", "spaces"]
|
||||
// "BadUTF8\xe2\xe2\xa1" => ["BadUTF8\xe2\xe2\xa1"]
|
||||
//
|
||||
// Splitting rules
|
||||
//
|
||||
// 1) If string is not valid UTF-8, return it without splitting as
|
||||
// 1. If string is not valid UTF-8, return it without splitting as
|
||||
// single item array.
|
||||
// 2) Assign all unicode characters into one of 4 sets: lower case
|
||||
// 2. Assign all unicode characters into one of 4 sets: lower case
|
||||
// letters, upper case letters, numbers, and all other characters.
|
||||
// 3) Iterate through characters of string, introducing splits
|
||||
// 3. Iterate through characters of string, introducing splits
|
||||
// between adjacent characters that belong to different sets.
|
||||
// 4) Iterate through array of split strings, and if a given string
|
||||
// 4. Iterate through array of split strings, and if a given string
|
||||
// is upper case:
|
||||
// if subsequent string is lower case:
|
||||
// move last character of upper case string to beginning of
|
||||
// lower case string
|
||||
// if subsequent string is lower case:
|
||||
// move last character of upper case string to beginning of
|
||||
// lower case string
|
||||
func Split(src string) (entries []string) {
|
||||
// don't split invalid utf8
|
||||
if !utf8.ValidString(src) {
|
||||
|
23
vendor/github.com/containers/common/pkg/report/doc.go
generated
vendored
23
vendor/github.com/containers/common/pkg/report/doc.go
generated
vendored
@@ -1,9 +1,12 @@
|
||||
/*
|
||||
Package report provides helper structs/methods/funcs for formatting output
|
||||
|
||||
# Examples
|
||||
|
||||
To format output for an array of structs:
|
||||
|
||||
ExamplePodman:
|
||||
|
||||
headers := report.Headers(struct {
|
||||
ID string
|
||||
}{}, nil)
|
||||
@@ -24,6 +27,7 @@ ExamplePodman:
|
||||
// fa85da03b40141899f3af3de6d27852b
|
||||
|
||||
ExampleUser:
|
||||
|
||||
headers := report.Headers(struct {
|
||||
CID string
|
||||
}{}, map[string]string{"CID":"ID"})
|
||||
@@ -52,22 +56,21 @@ Helpers:
|
||||
... "table" keyword prefix in format text
|
||||
}
|
||||
|
||||
Template Functions:
|
||||
# Template Functions
|
||||
|
||||
The following template functions are added to the template when parsed:
|
||||
- join strings.Join, {{join .Field separator}}
|
||||
- json encode field as JSON {{ json .Field }}
|
||||
- lower strings.ToLower {{ .Field | lower }}
|
||||
- pad add spaces as prefix and suffix {{ pad . 2 2 }}
|
||||
- split strings.Split {{ .Field | split }}
|
||||
- title strings.Title {{ .Field | title }}
|
||||
- truncate limit field length {{ truncate . 10 }}
|
||||
- upper strings.ToUpper {{ .Field | upper }}
|
||||
- join strings.Join, {{join .Field separator}}
|
||||
- json encode field as JSON {{ json .Field }}
|
||||
- lower strings.ToLower {{ .Field | lower }}
|
||||
- pad add spaces as prefix and suffix {{ pad . 2 2 }}
|
||||
- split strings.Split {{ .Field | split }}
|
||||
- title strings.Title {{ .Field | title }}
|
||||
- truncate limit field length {{ truncate . 10 }}
|
||||
- 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
|
||||
*/
|
||||
package report
|
||||
|
8
vendor/github.com/containers/common/pkg/report/formatter.go
generated
vendored
8
vendor/github.com/containers/common/pkg/report/formatter.go
generated
vendored
@@ -51,11 +51,11 @@ type Formatter struct {
|
||||
|
||||
// Parse parses golang template returning a formatter
|
||||
//
|
||||
// - OriginPodman implies text is a template from podman code. Output will
|
||||
// be filtered through a tabwriter.
|
||||
// - OriginPodman implies text is a template from podman code. Output will
|
||||
// be filtered through a tabwriter.
|
||||
//
|
||||
// - OriginUser implies text is a template from a user. If template includes
|
||||
// keyword "table" output will be filtered through a tabwriter.
|
||||
// - OriginUser implies text is a template from a user. If template includes
|
||||
// keyword "table" output will be filtered through a tabwriter.
|
||||
func (f *Formatter) Parse(origin Origin, text string) (*Formatter, error) {
|
||||
f.Origin = origin
|
||||
|
||||
|
13
vendor/github.com/containers/common/pkg/report/template.go
generated
vendored
13
vendor/github.com/containers/common/pkg/report/template.go
generated
vendored
@@ -4,11 +4,11 @@ import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"strings"
|
||||
"text/template"
|
||||
|
||||
"github.com/containers/common/pkg/report/camelcase"
|
||||
"github.com/containers/storage/pkg/regexp"
|
||||
)
|
||||
|
||||
// Template embeds template.Template to add functionality to methods
|
||||
@@ -88,10 +88,11 @@ func truncateWithLength(source string, length int) string {
|
||||
// Array of map is returned to support range templates
|
||||
// Note: unexported fields can be supported by adding field to overrides
|
||||
// Note: It is left to the developer to write out said headers
|
||||
// Podman commands use the general rules of:
|
||||
// 1) unchanged --format includes headers
|
||||
// 2) --format '{{.ID}" # no headers
|
||||
// 3) --format 'table {{.ID}}' # includes headers
|
||||
//
|
||||
// Podman commands use the general rules of:
|
||||
// 1) unchanged --format includes headers
|
||||
// 2) --format '{{.ID}" # no headers
|
||||
// 3) --format 'table {{.ID}}' # includes headers
|
||||
func Headers(object interface{}, overrides map[string]string) []map[string]string {
|
||||
value := reflect.ValueOf(object)
|
||||
if value.Kind() == reflect.Ptr {
|
||||
@@ -159,7 +160,7 @@ func (t *Template) IsTable() bool {
|
||||
return t.isTable
|
||||
}
|
||||
|
||||
var rangeRegex = regexp.MustCompile(`(?s){{\s*range\s*\.\s*}}.*{{\s*end\s*-?\s*}}`)
|
||||
var rangeRegex = regexp.Delayed(`(?s){{\s*range\s*\.\s*}}.*{{\s*end\s*-?\s*}}`)
|
||||
|
||||
// EnforceRange ensures that the format string contains a range
|
||||
func EnforceRange(format string) string {
|
||||
|
15
vendor/github.com/containers/common/pkg/report/validate.go
generated
vendored
15
vendor/github.com/containers/common/pkg/report/validate.go
generated
vendored
@@ -1,13 +1,18 @@
|
||||
package report
|
||||
|
||||
import "regexp"
|
||||
import (
|
||||
"github.com/containers/storage/pkg/regexp"
|
||||
)
|
||||
|
||||
var jsonRegex = regexp.MustCompile(`^\s*(json|{{\s*json\s*(\.)?\s*}})\s*$`)
|
||||
// Check for json, {{json }} and {{ json. }} which are not valid go template,
|
||||
// {{json .}} is valid and thus not matched to let the template handle it like docker does.
|
||||
var jsonRegex = regexp.Delayed(`^\s*(json|{{\s*json\.?\s*}})\s*$`)
|
||||
|
||||
// JSONFormat test CLI --format string to be a JSON request
|
||||
// if report.IsJSON(cmd.Flag("format").Value.String()) {
|
||||
// ... process JSON and output
|
||||
// }
|
||||
//
|
||||
// if report.IsJSON(cmd.Flag("format").Value.String()) {
|
||||
// ... process JSON and output
|
||||
// }
|
||||
func IsJSON(s string) bool {
|
||||
return jsonRegex.MatchString(s)
|
||||
}
|
||||
|
Reference in New Issue
Block a user