Merge pull request #16274 from containers/dependabot/go_modules/github.com/BurntSushi/toml-1.2.1

build(deps): bump github.com/BurntSushi/toml from 1.2.0 to 1.2.1
This commit is contained in:
OpenShift Merge Robot
2022-10-24 18:53:07 -04:00
committed by GitHub
10 changed files with 102 additions and 86 deletions

2
go.mod
View File

@ -3,7 +3,7 @@ module github.com/containers/podman/v4
go 1.17 go 1.17
require ( require (
github.com/BurntSushi/toml v1.2.0 github.com/BurntSushi/toml v1.2.1
github.com/blang/semver/v4 v4.0.0 github.com/blang/semver/v4 v4.0.0
github.com/buger/goterm v1.0.4 github.com/buger/goterm v1.0.4
github.com/checkpoint-restore/checkpointctl v0.0.0-20220321135231-33f4a66335f0 github.com/checkpoint-restore/checkpointctl v0.0.0-20220321135231-33f4a66335f0

3
go.sum
View File

@ -106,8 +106,9 @@ github.com/Azure/go-autorest/tracing v0.6.0/go.mod h1:+vhtPC754Xsa23ID7GlGsrdKBp
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/toml v0.4.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= github.com/BurntSushi/toml v0.4.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
github.com/BurntSushi/toml v1.1.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= github.com/BurntSushi/toml v1.1.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
github.com/BurntSushi/toml v1.2.0 h1:Rt8g24XnyGTyglgET/PRUNlrUeu9F5L+7FilkXfZgs0=
github.com/BurntSushi/toml v1.2.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= github.com/BurntSushi/toml v1.2.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
github.com/BurntSushi/toml v1.2.1 h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak=
github.com/BurntSushi/toml v1.2.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM=
github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=

View File

@ -21,7 +21,9 @@ type Unmarshaler interface {
UnmarshalTOML(interface{}) error UnmarshalTOML(interface{}) error
} }
// Unmarshal decodes the contents of `data` in TOML format into a pointer `v`. // Unmarshal decodes the contents of data in TOML format into a pointer v.
//
// See [Decoder] for a description of the decoding process.
func Unmarshal(data []byte, v interface{}) error { func Unmarshal(data []byte, v interface{}) error {
_, err := NewDecoder(bytes.NewReader(data)).Decode(v) _, err := NewDecoder(bytes.NewReader(data)).Decode(v)
return err return err
@ -29,13 +31,12 @@ func Unmarshal(data []byte, v interface{}) error {
// Decode the TOML data in to the pointer v. // Decode the TOML data in to the pointer v.
// //
// See the documentation on Decoder for a description of the decoding process. // See [Decoder] for a description of the decoding process.
func Decode(data string, v interface{}) (MetaData, error) { func Decode(data string, v interface{}) (MetaData, error) {
return NewDecoder(strings.NewReader(data)).Decode(v) return NewDecoder(strings.NewReader(data)).Decode(v)
} }
// DecodeFile is just like Decode, except it will automatically read the // DecodeFile reads the contents of a file and decodes it with [Decode].
// contents of the file at path and decode it for you.
func DecodeFile(path string, v interface{}) (MetaData, error) { func DecodeFile(path string, v interface{}) (MetaData, error) {
fp, err := os.Open(path) fp, err := os.Open(path)
if err != nil { if err != nil {
@ -48,7 +49,7 @@ func DecodeFile(path string, v interface{}) (MetaData, error) {
// Primitive is a TOML value that hasn't been decoded into a Go value. // Primitive is a TOML value that hasn't been decoded into a Go value.
// //
// This type can be used for any value, which will cause decoding to be delayed. // This type can be used for any value, which will cause decoding to be delayed.
// You can use the PrimitiveDecode() function to "manually" decode these values. // You can use [PrimitiveDecode] to "manually" decode these values.
// //
// NOTE: The underlying representation of a `Primitive` value is subject to // NOTE: The underlying representation of a `Primitive` value is subject to
// change. Do not rely on it. // change. Do not rely on it.
@ -70,15 +71,15 @@ const (
// Decoder decodes TOML data. // Decoder decodes TOML data.
// //
// TOML tables correspond to Go structs or maps (dealer's choice they can be // TOML tables correspond to Go structs or maps; they can be used
// used interchangeably). // interchangeably, but structs offer better type safety.
// //
// TOML table arrays correspond to either a slice of structs or a slice of maps. // TOML table arrays correspond to either a slice of structs or a slice of maps.
// //
// TOML datetimes correspond to Go time.Time values. Local datetimes are parsed // TOML datetimes correspond to [time.Time]. Local datetimes are parsed in the
// in the local timezone. // local timezone.
// //
// time.Duration types are treated as nanoseconds if the TOML value is an // [time.Duration] types are treated as nanoseconds if the TOML value is an
// integer, or they're parsed with time.ParseDuration() if they're strings. // integer, or they're parsed with time.ParseDuration() if they're strings.
// //
// All other TOML types (float, string, int, bool and array) correspond to the // All other TOML types (float, string, int, bool and array) correspond to the
@ -90,7 +91,7 @@ const (
// UnmarshalText method. See the Unmarshaler example for a demonstration with // UnmarshalText method. See the Unmarshaler example for a demonstration with
// email addresses. // email addresses.
// //
// Key mapping // ### Key mapping
// //
// TOML keys can map to either keys in a Go map or field names in a Go struct. // TOML keys can map to either keys in a Go map or field names in a Go struct.
// The special `toml` struct tag can be used to map TOML keys to struct fields // The special `toml` struct tag can be used to map TOML keys to struct fields
@ -168,17 +169,16 @@ func (dec *Decoder) Decode(v interface{}) (MetaData, error) {
return md, md.unify(p.mapping, rv) return md, md.unify(p.mapping, rv)
} }
// PrimitiveDecode is just like the other `Decode*` functions, except it // PrimitiveDecode is just like the other Decode* functions, except it decodes a
// decodes a TOML value that has already been parsed. Valid primitive values // TOML value that has already been parsed. Valid primitive values can *only* be
// can *only* be obtained from values filled by the decoder functions, // obtained from values filled by the decoder functions, including this method.
// including this method. (i.e., `v` may contain more `Primitive` // (i.e., v may contain more [Primitive] values.)
// values.)
// //
// Meta data for primitive values is included in the meta data returned by // Meta data for primitive values is included in the meta data returned by the
// the `Decode*` functions with one exception: keys returned by the Undecoded // Decode* functions with one exception: keys returned by the Undecoded method
// method will only reflect keys that were decoded. Namely, any keys hidden // will only reflect keys that were decoded. Namely, any keys hidden behind a
// behind a Primitive will be considered undecoded. Executing this method will // Primitive will be considered undecoded. Executing this method will update the
// update the undecoded keys in the meta data. (See the example.) // undecoded keys in the meta data. (See the example.)
func (md *MetaData) PrimitiveDecode(primValue Primitive, v interface{}) error { func (md *MetaData) PrimitiveDecode(primValue Primitive, v interface{}) error {
md.context = primValue.context md.context = primValue.context
defer func() { md.context = nil }() defer func() { md.context = nil }()

View File

@ -7,8 +7,8 @@ import (
"io/fs" "io/fs"
) )
// DecodeFS is just like Decode, except it will automatically read the contents // DecodeFS reads the contents of a file from [fs.FS] and decodes it with
// of the file at `path` from a fs.FS instance. // [Decode].
func DecodeFS(fsys fs.FS, path string, v interface{}) (MetaData, error) { func DecodeFS(fsys fs.FS, path string, v interface{}) (MetaData, error) {
fp, err := fsys.Open(path) fp, err := fsys.Open(path)
if err != nil { if err != nil {

View File

@ -1,13 +1,11 @@
/* // Package toml implements decoding and encoding of TOML files.
Package toml implements decoding and encoding of TOML files. //
// This package supports TOML v1.0.0, as specified at https://toml.io
This package supports TOML v1.0.0, as listed on https://toml.io //
// There is also support for delaying decoding with the Primitive type, and
There is also support for delaying decoding with the Primitive type, and // querying the set of keys in a TOML document with the MetaData type.
querying the set of keys in a TOML document with the MetaData type. //
// The github.com/BurntSushi/toml/cmd/tomlv package implements a TOML validator,
The github.com/BurntSushi/toml/cmd/tomlv package implements a TOML validator, // and can be used to verify if TOML document is valid. It can also be used to
and can be used to verify if TOML document is valid. It can also be used to // print the type of each key.
print the type of each key.
*/
package toml package toml

View File

@ -79,12 +79,12 @@ type Marshaler interface {
// Encoder encodes a Go to a TOML document. // Encoder encodes a Go to a TOML document.
// //
// The mapping between Go values and TOML values should be precisely the same as // The mapping between Go values and TOML values should be precisely the same as
// for the Decode* functions. // for [Decode].
// //
// time.Time is encoded as a RFC 3339 string, and time.Duration as its string // time.Time is encoded as a RFC 3339 string, and time.Duration as its string
// representation. // representation.
// //
// The toml.Marshaler and encoder.TextMarshaler interfaces are supported to // The [Marshaler] and [encoding.TextMarshaler] interfaces are supported to
// encoding the value as custom TOML. // encoding the value as custom TOML.
// //
// If you want to write arbitrary binary data then you will need to use // If you want to write arbitrary binary data then you will need to use
@ -130,7 +130,7 @@ func NewEncoder(w io.Writer) *Encoder {
} }
} }
// Encode writes a TOML representation of the Go value to the Encoder's writer. // Encode writes a TOML representation of the Go value to the [Encoder]'s writer.
// //
// An error is returned if the value given cannot be encoded to a valid TOML // An error is returned if the value given cannot be encoded to a valid TOML
// document. // document.
@ -261,7 +261,7 @@ func (enc *Encoder) eElement(rv reflect.Value) {
enc.eElement(reflect.ValueOf(v)) enc.eElement(reflect.ValueOf(v))
return return
} }
encPanic(errors.New(fmt.Sprintf("Unable to convert \"%s\" to neither int64 nor float64", n))) encPanic(fmt.Errorf("unable to convert %q to int64 or float64", n))
} }
switch rv.Kind() { switch rv.Kind() {
@ -504,7 +504,8 @@ func (enc *Encoder) eStruct(key Key, rv reflect.Value, inline bool) {
if opts.name != "" { if opts.name != "" {
keyName = opts.name keyName = opts.name
} }
if opts.omitempty && isEmpty(fieldVal) {
if opts.omitempty && enc.isEmpty(fieldVal) {
continue continue
} }
if opts.omitzero && isZero(fieldVal) { if opts.omitzero && isZero(fieldVal) {
@ -648,12 +649,26 @@ func isZero(rv reflect.Value) bool {
return false return false
} }
func isEmpty(rv reflect.Value) bool { func (enc *Encoder) isEmpty(rv reflect.Value) bool {
switch rv.Kind() { switch rv.Kind() {
case reflect.Array, reflect.Slice, reflect.Map, reflect.String: case reflect.Array, reflect.Slice, reflect.Map, reflect.String:
return rv.Len() == 0 return rv.Len() == 0
case reflect.Struct: case reflect.Struct:
return reflect.Zero(rv.Type()).Interface() == rv.Interface() if rv.Type().Comparable() {
return reflect.Zero(rv.Type()).Interface() == rv.Interface()
}
// Need to also check if all the fields are empty, otherwise something
// like this with uncomparable types will always return true:
//
// type a struct{ field b }
// type b struct{ s []string }
// s := a{field: b{s: []string{"AAA"}}}
for i := 0; i < rv.NumField(); i++ {
if !enc.isEmpty(rv.Field(i)) {
return false
}
}
return true
case reflect.Bool: case reflect.Bool:
return !rv.Bool() return !rv.Bool()
} }
@ -668,16 +683,15 @@ func (enc *Encoder) newline() {
// Write a key/value pair: // Write a key/value pair:
// //
// key = <any value> // key = <any value>
// //
// This is also used for "k = v" in inline tables; so something like this will // This is also used for "k = v" in inline tables; so something like this will
// be written in three calls: // be written in three calls:
// //
// ┌────────────────────┐ //───────────────────┐
// │ ┌───┐ ┌────┐│ // │ ┌───┐ ┌────┐│
// v v v v vv // v v v v vv
// key = {k = v, k2 = v2} // key = {k = 1, k2 = 2}
//
func (enc *Encoder) writeKeyValue(key Key, val reflect.Value, inline bool) { func (enc *Encoder) writeKeyValue(key Key, val reflect.Value, inline bool) {
if len(key) == 0 { if len(key) == 0 {
encPanic(errNoKey) encPanic(errNoKey)

View File

@ -5,57 +5,60 @@ import (
"strings" "strings"
) )
// ParseError is returned when there is an error parsing the TOML syntax. // ParseError is returned when there is an error parsing the TOML syntax such as
// // invalid syntax, duplicate keys, etc.
// For example invalid syntax, duplicate keys, etc.
// //
// In addition to the error message itself, you can also print detailed location // In addition to the error message itself, you can also print detailed location
// information with context by using ErrorWithPosition(): // information with context by using [ErrorWithPosition]:
// //
// toml: error: Key 'fruit' was already created and cannot be used as an array. // toml: error: Key 'fruit' was already created and cannot be used as an array.
// //
// At line 4, column 2-7: // At line 4, column 2-7:
// //
// 2 | fruit = [] // 2 | fruit = []
// 3 | // 3 |
// 4 | [[fruit]] # Not allowed // 4 | [[fruit]] # Not allowed
// ^^^^^ // ^^^^^
// //
// Furthermore, the ErrorWithUsage() can be used to print the above with some // [ErrorWithUsage] can be used to print the above with some more detailed usage
// more detailed usage guidance: // guidance:
// //
// toml: error: newlines not allowed within inline tables // toml: error: newlines not allowed within inline tables
// //
// At line 1, column 18: // At line 1, column 18:
// //
// 1 | x = [{ key = 42 # // 1 | x = [{ key = 42 #
// ^ // ^
// //
// Error help: // Error help:
// //
// Inline tables must always be on a single line: // Inline tables must always be on a single line:
// //
// table = {key = 42, second = 43} // table = {key = 42, second = 43}
// //
// It is invalid to split them over multiple lines like so: // It is invalid to split them over multiple lines like so:
// //
// # INVALID // # INVALID
// table = { // table = {
// key = 42, // key = 42,
// second = 43 // second = 43
// } // }
// //
// Use regular for this: // Use regular for this:
// //
// [table] // [table]
// key = 42 // key = 42
// second = 43 // second = 43
type ParseError struct { type ParseError struct {
Message string // Short technical message. Message string // Short technical message.
Usage string // Longer message with usage guidance; may be blank. Usage string // Longer message with usage guidance; may be blank.
Position Position // Position of the error Position Position // Position of the error
LastKey string // Last parsed key, may be blank. LastKey string // Last parsed key, may be blank.
Line int // Line the error occurred. Deprecated: use Position.
// Line the error occurred.
//
// Deprecated: use [Position].
Line int
err error err error
input string input string
@ -83,7 +86,7 @@ func (pe ParseError) Error() string {
// ErrorWithUsage() returns the error with detailed location context. // ErrorWithUsage() returns the error with detailed location context.
// //
// See the documentation on ParseError. // See the documentation on [ParseError].
func (pe ParseError) ErrorWithPosition() string { func (pe ParseError) ErrorWithPosition() string {
if pe.input == "" { // Should never happen, but just in case. if pe.input == "" { // Should never happen, but just in case.
return pe.Error() return pe.Error()
@ -124,7 +127,7 @@ func (pe ParseError) ErrorWithPosition() string {
// ErrorWithUsage() returns the error with detailed location context and usage // ErrorWithUsage() returns the error with detailed location context and usage
// guidance. // guidance.
// //
// See the documentation on ParseError. // See the documentation on [ParseError].
func (pe ParseError) ErrorWithUsage() string { func (pe ParseError) ErrorWithUsage() string {
m := pe.ErrorWithPosition() m := pe.ErrorWithPosition()
if u, ok := pe.err.(interface{ Usage() string }); ok && u.Usage() != "" { if u, ok := pe.err.(interface{ Usage() string }); ok && u.Usage() != "" {

View File

@ -771,7 +771,7 @@ func lexRawString(lx *lexer) stateFn {
} }
// lexMultilineRawString consumes a raw string. Nothing can be escaped in such // lexMultilineRawString consumes a raw string. Nothing can be escaped in such
// a string. It assumes that the beginning "'''" has already been consumed and // a string. It assumes that the beginning ''' has already been consumed and
// ignored. // ignored.
func lexMultilineRawString(lx *lexer) stateFn { func lexMultilineRawString(lx *lexer) stateFn {
r := lx.next() r := lx.next()

View File

@ -71,7 +71,7 @@ func (md *MetaData) Keys() []Key {
// Undecoded returns all keys that have not been decoded in the order in which // Undecoded returns all keys that have not been decoded in the order in which
// they appear in the original TOML document. // they appear in the original TOML document.
// //
// This includes keys that haven't been decoded because of a Primitive value. // This includes keys that haven't been decoded because of a [Primitive] value.
// Once the Primitive value is decoded, the keys will be considered decoded. // Once the Primitive value is decoded, the keys will be considered decoded.
// //
// Also note that decoding into an empty interface will result in no decoding, // Also note that decoding into an empty interface will result in no decoding,
@ -89,7 +89,7 @@ func (md *MetaData) Undecoded() []Key {
return undecoded return undecoded
} }
// Key represents any TOML key, including key groups. Use (MetaData).Keys to get // Key represents any TOML key, including key groups. Use [MetaData.Keys] to get
// values of this type. // values of this type.
type Key []string type Key []string

2
vendor/modules.txt vendored
View File

@ -2,7 +2,7 @@
## explicit; go 1.16 ## explicit; go 1.16
github.com/Azure/go-ansiterm github.com/Azure/go-ansiterm
github.com/Azure/go-ansiterm/winterm github.com/Azure/go-ansiterm/winterm
# github.com/BurntSushi/toml v1.2.0 # github.com/BurntSushi/toml v1.2.1
## explicit; go 1.16 ## explicit; go 1.16
github.com/BurntSushi/toml github.com/BurntSushi/toml
github.com/BurntSushi/toml/internal github.com/BurntSushi/toml/internal