diff --git a/go.mod b/go.mod index 8fcdb94bd..d51032920 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/blang/semver/v4 v4.0.0 github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f github.com/coreos/ignition v0.35.0 - github.com/coreos/ignition/v2 v2.9.0 + github.com/coreos/ignition/v2 v2.14.0 github.com/ghodss/yaml v1.0.1-0.20190212211648-25d852aebe32 github.com/google/go-cmp v0.5.6 github.com/jaypipes/ghw v0.8.1-0.20210605191321-eb162add542b @@ -24,7 +24,7 @@ require ( github.com/pkg/errors v0.9.1 github.com/sirupsen/logrus v1.8.1 github.com/spf13/cobra v1.2.1 - github.com/spf13/pflag v1.0.5 + github.com/spf13/pflag v1.0.6-0.20210604193023-d5e0c0615ace k8s.io/api v0.23.3 k8s.io/apiextensions-apiserver v0.23.3 k8s.io/apimachinery v0.23.3 @@ -56,7 +56,7 @@ require ( github.com/cespare/xxhash/v2 v2.1.1 // indirect github.com/coreos/go-semver v0.3.0 // indirect github.com/coreos/go-systemd/v22 v22.3.2 // indirect - github.com/coreos/vcontext v0.0.0-20201120045928-b0e13dab675c // indirect + github.com/coreos/vcontext v0.0.0-20211021162308-f1dbbca7bef4 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/evanphx/json-patch v4.12.0+incompatible // indirect github.com/fatih/color v1.12.0 // indirect @@ -106,7 +106,7 @@ require ( github.com/prometheus/client_model v0.2.0 // indirect github.com/prometheus/common v0.28.0 // indirect github.com/prometheus/procfs v0.6.0 // indirect - github.com/vincent-petithory/dataurl v0.0.0-20191104211930-d1553a71de50 // indirect + github.com/vincent-petithory/dataurl v1.0.0 // indirect go.mongodb.org/mongo-driver v1.3.0 // indirect go.uber.org/atomic v1.7.0 // indirect go.uber.org/multierr v1.6.0 // indirect diff --git a/go.sum b/go.sum index 1dfb52408..3028b31c0 100644 --- a/go.sum +++ b/go.sum @@ -123,6 +123,7 @@ github.com/aws/aws-sdk-go v1.19.11/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpi github.com/aws/aws-sdk-go v1.30.28/go.mod h1:5zCpMtNQVjRREroY7sYe8lOMRSxkhG6MZveU8YkpAk0= github.com/aws/aws-sdk-go v1.35.24/go.mod h1:tlPOdRjfxPBpNIwqDj61rmsnA85v9jc0Ps9+muhnW+k= github.com/aws/aws-sdk-go v1.38.49/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro= +github.com/beevik/etree v1.1.1-0.20200718192613-4a2f8b9d084c/go.mod h1:0yGO2rna3S9DkITDWHY1bMtcY4IJ4w+4S+EooZUR0bE= github.com/benbjohnson/clock v1.0.3/go.mod h1:bGMdMPoPVvcYyt1gHDf4J2KE153Yf9BuiUKYMaxlTDM= github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= @@ -197,7 +198,7 @@ github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/fcct v0.5.0/go.mod h1:cbE+j77YSQwFB2fozWVB3qsI2Pi3YiVEbDz/b6Yywdo= github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= -github.com/coreos/go-json v0.0.0-20170920214419-6a2fe990e083/go.mod h1:FmxyHfvrCFfCsXRylD4QQRlQmvzl+DG6iTHyEEykPfU= +github.com/coreos/go-json v0.0.0-20211020211907-c63f628265de/go.mod h1:lryFBkhadOfv8Jue2Vr/f/Yviw8h1DQPQojbXqEChY0= github.com/coreos/go-oidc v2.1.0+incompatible/go.mod h1:CgnwVTmzoESiwO9qyAFEMiHoZ1nMCKZlZ9V6mm3/LKc= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-semver v0.3.0 h1:wkHLiw0WNATZnSG7epLsujiMCgPAc9xhjJ4tgnAxmfM= @@ -215,13 +216,13 @@ github.com/coreos/ignition v0.35.0 h1:UFodoYq1mOPrbEjtxIsZbThcDyQwAI1owczRDqWmKk github.com/coreos/ignition v0.35.0/go.mod h1:WJQapxzEn9DE0ryxsGvm8QnBajm/XsS/PkrDqSpz+bA= github.com/coreos/ignition/v2 v2.1.1/go.mod h1:RqmqU64zxarUJa3l4cHtbhcSwfQLpUhv0WVziZwoXvE= github.com/coreos/ignition/v2 v2.7.0/go.mod h1:3CjaRpg51hmJzPjarbzB0RvSZbLkNOczxKJobTl6nOY= -github.com/coreos/ignition/v2 v2.9.0 h1:Zl5N08OyqlECB8BrBlMDp3Jf1ShwVTtREPcUq/YO034= -github.com/coreos/ignition/v2 v2.9.0/go.mod h1:A5lFFzA2/zvZQPVEvI1lR5WPLWRb7KZ7Q1QOeUMtcAc= +github.com/coreos/ignition/v2 v2.14.0 h1:KfkCCnA6AK0kts/1zxzzNH5lDMCQN9sqqGcGs+RJVX4= +github.com/coreos/ignition/v2 v2.14.0/go.mod h1:wxc4qdYEIHLygzWbVVEuoD7lQGTZmMgX0VjAPYBbeEQ= github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/coreos/vcontext v0.0.0-20190529201340-22b159166068/go.mod h1:E+6hug9bFSe0KZ2ZAzr8M9F5JlArJjv5D1JS7KSkPKE= github.com/coreos/vcontext v0.0.0-20191017033345-260217907eb5/go.mod h1:E+6hug9bFSe0KZ2ZAzr8M9F5JlArJjv5D1JS7KSkPKE= -github.com/coreos/vcontext v0.0.0-20201120045928-b0e13dab675c h1:jA28WeORitsxGFVWhyWB06sAG2HbLHPQuHwDydhU2CQ= -github.com/coreos/vcontext v0.0.0-20201120045928-b0e13dab675c/go.mod h1:z4pMVvaUrxs98RROlIYdAQCKhEicjnTirOaVyDRH5h8= +github.com/coreos/vcontext v0.0.0-20211021162308-f1dbbca7bef4 h1:pfSsrvbjUFGINaPGy0mm2QKQKTdq7IcbUa+nQwsz2UM= +github.com/coreos/vcontext v0.0.0-20211021162308-f1dbbca7bef4/go.mod h1:HckqHnP/HI41vS0bfVjJ20u6jD0biI5+68QwZm5Xb9U= github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= @@ -940,8 +941,9 @@ github.com/spf13/pflag v0.0.0-20170130214245-9ff6c6923cff/go.mod h1:DYY7MBk1bdzu github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.2/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= -github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/spf13/pflag v1.0.6-0.20210604193023-d5e0c0615ace h1:9PNP1jnUjRhfmGMlkXHjYPishpcw4jpSt/V/xYY3FMA= +github.com/spf13/pflag v1.0.6-0.20210604193023-d5e0c0615ace/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/viper v1.0.2/go.mod h1:A8kyI5cUJhb8N+3pkfONlcEcZbueH6nhAm0Fq7SrnBM= github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= @@ -986,13 +988,15 @@ github.com/vbatts/tar-split v0.11.1/go.mod h1:LEuURwDEiWjRjwu46yU3KVGuUdVv/dcnpc github.com/vbauerster/mpb/v5 v5.2.2/go.mod h1:W5Fvgw4dm3/0NhqzV8j6EacfuTe5SvnzBRwiXxDR9ww= github.com/vektah/gqlparser v1.1.2/go.mod h1:1ycwN7Ij5njmMkPPAOaRFY4rET2Enx7IkVv3vaXspKw= github.com/vincent-petithory/dataurl v0.0.0-20160330182126-9a301d65acbb/go.mod h1:FHafX5vmDzyP+1CQATJn7WFKc9CvnvxyvZy6I1MrG/U= -github.com/vincent-petithory/dataurl v0.0.0-20191104211930-d1553a71de50 h1:uxE3GYdXIOfhMv3unJKETJEhw78gvzuQqRX/rVirc2A= github.com/vincent-petithory/dataurl v0.0.0-20191104211930-d1553a71de50/go.mod h1:FHafX5vmDzyP+1CQATJn7WFKc9CvnvxyvZy6I1MrG/U= +github.com/vincent-petithory/dataurl v1.0.0 h1:cXw+kPto8NLuJtlMsI152irrVw9fRDX8AbShPRpg2CI= +github.com/vincent-petithory/dataurl v1.0.0/go.mod h1:FHafX5vmDzyP+1CQATJn7WFKc9CvnvxyvZy6I1MrG/U= github.com/vishvananda/netlink v1.1.0/go.mod h1:cTgwzPIzzgDAYoQrMm0EdrjRUBkTqKYppBueQtXaqoE= github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df/go.mod h1:JP3t17pCcGlemwknint6hfoeCVQrEMVwxRLRjXpq+BU= github.com/vishvananda/netns v0.0.0-20200728191858-db3c7e526aae/go.mod h1:DD4vA1DwXk04H54A1oHXtwZmA0grkVMdPxx/VGLCah0= github.com/vmware/govmomi v0.20.3/go.mod h1:URlwyTFZX72RmxtxuaFL2Uj3fD1JTvZdx59bHWk6aFU= github.com/vmware/vmw-guestinfo v0.0.0-20170707015358-25eff159a728/go.mod h1:x9oS4Wk2s2u4tS29nEaDLdzvuHdB19CvSGJjPgkZJNk= +github.com/vmware/vmw-guestinfo v0.0.0-20220317130741-510905f0efa3/go.mod h1:CSBTxrhePCm0cmXNKDGeu+6bOQzpaEklfCqEpn89JWk= github.com/vmware/vmw-ovflib v0.0.0-20170608004843-1f217b9dc714/go.mod h1:jiPk45kn7klhByRvUq5i2vo1RtHKBHj+iWGFpxbXuuI= github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c/go.mod h1:lB8K/P019DLNhemzwFU4jHLhdvlE6uDZjXFejJXr49I= github.com/xdg/stringprep v0.0.0-20180714160509-73f8eece6fdc/go.mod h1:Jhud4/sHMO4oL310DaZAKk9ZaJ08SJfe+sJh0HrGL1Y= diff --git a/vendor/github.com/coreos/ignition/v2/config/shared/errors/errors.go b/vendor/github.com/coreos/ignition/v2/config/shared/errors/errors.go index 4d9906d9a..492fd7e6c 100644 --- a/vendor/github.com/coreos/ignition/v2/config/shared/errors/errors.go +++ b/vendor/github.com/coreos/ignition/v2/config/shared/errors/errors.go @@ -37,6 +37,7 @@ var ( ErrFileUsedSymlink = errors.New("file path includes link in config") ErrDirectoryUsedSymlink = errors.New("directory path includes link in config") ErrLinkUsedSymlink = errors.New("link path includes link in config") + ErrLinkTargetRequired = errors.New("link target is required") ErrHardLinkToDirectory = errors.New("hard link target is a directory") ErrDiskDeviceRequired = errors.New("disk device is required") ErrPartitionNumbersCollide = errors.New("partition numbers collide") @@ -55,11 +56,13 @@ var ( ErrLuksLabelTooLong = errors.New("luks device labels cannot be longer than 47 characters") ErrLuksNameContainsSlash = errors.New("device names cannot contain slashes") ErrInvalidLuksKeyFile = errors.New("invalid key-file source") + ErrClevisPinRequired = errors.New("missing required custom clevis pin") ErrUnknownClevisPin = errors.New("unsupported clevis pin") ErrClevisConfigRequired = errors.New("missing required custom clevis config") ErrClevisCustomWithOthers = errors.New("cannot use custom clevis config with tpm2, tang, or threshold") ErrTangThumbprintRequired = errors.New("thumbprint is required") ErrFileIllegalMode = errors.New("illegal file mode") + ErrModeSpecialBits = errors.New("setuid/setgid/sticky bits are not supported in spec versions older than 3.4.0") ErrBothIDAndNameSet = errors.New("cannot set both id and name") ErrLabelTooLong = errors.New("partition labels may not exceed 36 characters") ErrDoesntMatchGUIDRegex = errors.New("doesn't match the form \"01234567-89AB-CDEF-EDCB-A98765432101\"") @@ -67,8 +70,10 @@ var ( ErrNoPath = errors.New("path not specified") ErrPathRelative = errors.New("path not absolute") ErrDirtyPath = errors.New("path is not fully simplified") - ErrSparesUnsupportedForLevel = errors.New("spares unsupported for arrays with a level greater than 0") + ErrRaidLevelRequired = errors.New("raid level is required") + ErrSparesUnsupportedForLevel = errors.New("spares unsupported for linear and raid0 arrays") ErrUnrecognizedRaidLevel = errors.New("unrecognized raid level") + ErrRaidDevicesRequired = errors.New("raid devices required") ErrShouldNotExistWithOthers = errors.New("shouldExist specified false with other options also specified") ErrZeroesWithShouldNotExist = errors.New("shouldExist is false for a partition and other partition(s) has start or size 0") ErrNeedLabelOrNumber = errors.New("a partition number >= 1 or a label must be specified") @@ -95,6 +100,7 @@ var ( ErrEngineConfiguration = errors.New("engine incorrectly configured") // AWS S3 specific errors + ErrInvalidS3ARN = errors.New("invalid S3 ARN format") ErrInvalidS3ObjectVersionId = errors.New("invalid S3 object VersionId") // Obsolete errors, left here for ABI compatibility diff --git a/vendor/github.com/coreos/ignition/v2/config/util/config.go b/vendor/github.com/coreos/ignition/v2/config/util/config.go new file mode 100644 index 000000000..85cd7fa7c --- /dev/null +++ b/vendor/github.com/coreos/ignition/v2/config/util/config.go @@ -0,0 +1,45 @@ +// Copyright 2021 Red Hat, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +package util + +import ( + "github.com/coreos/ignition/v2/config/shared/errors" + + "github.com/coreos/go-semver/semver" + "github.com/coreos/vcontext/report" +) + +type versionStub struct { + Ignition struct { + Version string + } +} + +// GetConfigVersion parses the version from the given raw config +func GetConfigVersion(raw []byte) (semver.Version, report.Report, error) { + if len(raw) == 0 { + return semver.Version{}, report.Report{}, errors.ErrEmpty + } + + stub := versionStub{} + if rpt, err := HandleParseErrors(raw, &stub); err != nil { + return semver.Version{}, rpt, err + } + + version, err := semver.NewVersion(stub.Ignition.Version) + if err != nil { + return semver.Version{}, report.Report{}, errors.ErrInvalidVersion + } + return *version, report.Report{}, nil +} diff --git a/vendor/github.com/coreos/ignition/v2/config/util/helpers.go b/vendor/github.com/coreos/ignition/v2/config/util/helpers.go index 9c8b04413..9be42800b 100644 --- a/vendor/github.com/coreos/ignition/v2/config/util/helpers.go +++ b/vendor/github.com/coreos/ignition/v2/config/util/helpers.go @@ -33,3 +33,11 @@ func NilOrEmpty(s *string) bool { func NotEmpty(s *string) bool { return s != nil && *s != "" } + +func IsTrue(b *bool) bool { + return b != nil && *b +} + +func IsFalse(b *bool) bool { + return b != nil && !*b +} diff --git a/vendor/github.com/coreos/ignition/v2/config/util/reflection.go b/vendor/github.com/coreos/ignition/v2/config/util/reflection.go index 561a8706b..51df4e124 100644 --- a/vendor/github.com/coreos/ignition/v2/config/util/reflection.go +++ b/vendor/github.com/coreos/ignition/v2/config/util/reflection.go @@ -15,6 +15,7 @@ package util import ( + "fmt" "reflect" ) @@ -53,3 +54,38 @@ func IsInvalidInConfig(k reflect.Kind) bool { return true } } + +// Return a fully non-zero value for the specified type, recursively +// setting all fields and slices. +func NonZeroValue(t reflect.Type) reflect.Value { + v := reflect.New(t).Elem() + setNonZero(v) + return v +} + +func setNonZero(v reflect.Value) { + switch v.Kind() { + case reflect.Bool: + v.SetBool(true) + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + v.SetInt(1) + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: + v.SetUint(1) + case reflect.Float32, reflect.Float64: + v.SetFloat(1) + case reflect.String: + v.SetString("aardvark") + case reflect.Ptr: + v.Set(reflect.New(v.Type().Elem())) + setNonZero(v.Elem()) + case reflect.Slice: + v.Set(reflect.MakeSlice(v.Type(), 1, 1)) + setNonZero(v.Index(0)) + case reflect.Struct: + for i := 0; i < v.NumField(); i++ { + setNonZero(v.Field(i)) + } + default: + panic(fmt.Sprintf("unexpected kind %s", v.Kind())) + } +} diff --git a/vendor/github.com/coreos/ignition/v2/config/v3_2/types/custom.go b/vendor/github.com/coreos/ignition/v2/config/v3_2/types/custom.go index 1b0c77b8b..2a1231cb3 100644 --- a/vendor/github.com/coreos/ignition/v2/config/v3_2/types/custom.go +++ b/vendor/github.com/coreos/ignition/v2/config/v3_2/types/custom.go @@ -21,10 +21,6 @@ import ( "github.com/coreos/vcontext/report" ) -func (cu Custom) Key() string { - return cu.Pin -} - func (cu Custom) Validate(c path.ContextPath) (r report.Report) { if cu.Pin == "" && cu.Config == "" { return diff --git a/vendor/github.com/coreos/ignition/v2/config/v3_2/types/directory.go b/vendor/github.com/coreos/ignition/v2/config/v3_2/types/directory.go index f6f068455..b01a6bf9d 100644 --- a/vendor/github.com/coreos/ignition/v2/config/v3_2/types/directory.go +++ b/vendor/github.com/coreos/ignition/v2/config/v3_2/types/directory.go @@ -22,5 +22,6 @@ import ( func (d Directory) Validate(c path.ContextPath) (r report.Report) { r.Merge(d.Node.Validate(c)) r.AddOnError(c.Append("mode"), validateMode(d.Mode)) + r.AddOnWarn(c.Append("mode"), validateModeSpecialBits(d.Mode)) return } diff --git a/vendor/github.com/coreos/ignition/v2/config/v3_2/types/disk.go b/vendor/github.com/coreos/ignition/v2/config/v3_2/types/disk.go index 17856e07a..8caf8499d 100644 --- a/vendor/github.com/coreos/ignition/v2/config/v3_2/types/disk.go +++ b/vendor/github.com/coreos/ignition/v2/config/v3_2/types/disk.go @@ -16,6 +16,7 @@ package types import ( "github.com/coreos/ignition/v2/config/shared/errors" + "github.com/coreos/ignition/v2/config/util" "github.com/coreos/vcontext/path" "github.com/coreos/vcontext/report" @@ -127,7 +128,7 @@ func (n Disk) partitionsMixZeroesAndNonexistence() bool { hasZero := false hasShouldNotExist := false for _, p := range n.Partitions { - hasShouldNotExist = hasShouldNotExist || (p.ShouldExist != nil && !*p.ShouldExist) + hasShouldNotExist = hasShouldNotExist || util.IsFalse(p.ShouldExist) hasZero = hasZero || (p.Number == 0) } return hasZero && hasShouldNotExist diff --git a/vendor/github.com/coreos/ignition/v2/config/v3_2/types/file.go b/vendor/github.com/coreos/ignition/v2/config/v3_2/types/file.go index 04b14288d..4e7566bd3 100644 --- a/vendor/github.com/coreos/ignition/v2/config/v3_2/types/file.go +++ b/vendor/github.com/coreos/ignition/v2/config/v3_2/types/file.go @@ -16,6 +16,7 @@ package types import ( "github.com/coreos/ignition/v2/config/shared/errors" + "github.com/coreos/ignition/v2/config/util" "github.com/coreos/vcontext/path" "github.com/coreos/vcontext/report" @@ -24,12 +25,13 @@ import ( func (f File) Validate(c path.ContextPath) (r report.Report) { r.Merge(f.Node.Validate(c)) r.AddOnError(c.Append("mode"), validateMode(f.Mode)) + r.AddOnWarn(c.Append("mode"), validateModeSpecialBits(f.Mode)) r.AddOnError(c.Append("overwrite"), f.validateOverwrite()) return } func (f File) validateOverwrite() error { - if f.Overwrite != nil && *f.Overwrite && f.Contents.Source == nil { + if util.IsTrue(f.Overwrite) && f.Contents.Source == nil { return errors.ErrOverwriteAndNilSource } return nil diff --git a/vendor/github.com/coreos/ignition/v2/config/v3_2/types/filesystem.go b/vendor/github.com/coreos/ignition/v2/config/v3_2/types/filesystem.go index 39a158969..3bf064f35 100644 --- a/vendor/github.com/coreos/ignition/v2/config/v3_2/types/filesystem.go +++ b/vendor/github.com/coreos/ignition/v2/config/v3_2/types/filesystem.go @@ -50,7 +50,7 @@ func (f Filesystem) validateFormat() error { if util.NotEmpty(f.Path) || util.NotEmpty(f.Label) || util.NotEmpty(f.UUID) || - f.WipeFilesystem != nil && *f.WipeFilesystem || + util.IsTrue(f.WipeFilesystem) || len(f.MountOptions) != 0 || len(f.Options) != 0 { return errors.ErrFormatNilWithOthers diff --git a/vendor/github.com/coreos/ignition/v2/config/v3_2/types/luks.go b/vendor/github.com/coreos/ignition/v2/config/v3_2/types/luks.go index d7cd29bac..123392b25 100644 --- a/vendor/github.com/coreos/ignition/v2/config/v3_2/types/luks.go +++ b/vendor/github.com/coreos/ignition/v2/config/v3_2/types/luks.go @@ -46,7 +46,7 @@ func (l Luks) Validate(c path.ContextPath) (r report.Report) { } if l.Clevis != nil { - if l.Clevis.Custom != nil && (len(l.Clevis.Tang) > 0 || (l.Clevis.Tpm2 != nil && *l.Clevis.Tpm2) || (l.Clevis.Threshold != nil && *l.Clevis.Threshold != 0)) { + if l.Clevis.Custom != nil && (len(l.Clevis.Tang) > 0 || util.IsTrue(l.Clevis.Tpm2) || (l.Clevis.Threshold != nil && *l.Clevis.Threshold != 0)) { r.AddOnError(c.Append("clevis"), errors.ErrClevisCustomWithOthers) } } diff --git a/vendor/github.com/coreos/ignition/v2/config/v3_2/types/mode.go b/vendor/github.com/coreos/ignition/v2/config/v3_2/types/mode.go index 9eb7573d8..ad3e51c22 100644 --- a/vendor/github.com/coreos/ignition/v2/config/v3_2/types/mode.go +++ b/vendor/github.com/coreos/ignition/v2/config/v3_2/types/mode.go @@ -24,3 +24,13 @@ func validateMode(m *int) error { } return nil } + +func validateModeSpecialBits(m *int) error { + if m != nil { + mode := uint32(*m) + if mode&07000 != 0 { + return errors.ErrModeSpecialBits + } + } + return nil +} diff --git a/vendor/github.com/coreos/ignition/v2/config/v3_2/types/node.go b/vendor/github.com/coreos/ignition/v2/config/v3_2/types/node.go index 52576a924..248276e73 100644 --- a/vendor/github.com/coreos/ignition/v2/config/v3_2/types/node.go +++ b/vendor/github.com/coreos/ignition/v2/config/v3_2/types/node.go @@ -18,6 +18,7 @@ import ( "path" "github.com/coreos/ignition/v2/config/shared/errors" + "github.com/coreos/ignition/v2/config/util" vpath "github.com/coreos/vcontext/path" "github.com/coreos/vcontext/report" @@ -41,7 +42,7 @@ func (n Node) Depth() int { } func validateIDorName(id *int, name *string) error { - if id != nil && (name != nil && *name != "") { + if id != nil && util.NotEmpty(name) { return errors.ErrBothIDAndNameSet } return nil diff --git a/vendor/github.com/coreos/ignition/v2/config/v3_2/types/partition.go b/vendor/github.com/coreos/ignition/v2/config/v3_2/types/partition.go index 08dca8eaf..1b2d97edf 100644 --- a/vendor/github.com/coreos/ignition/v2/config/v3_2/types/partition.go +++ b/vendor/github.com/coreos/ignition/v2/config/v3_2/types/partition.go @@ -20,6 +20,7 @@ import ( "strings" "github.com/coreos/ignition/v2/config/shared/errors" + "github.com/coreos/ignition/v2/config/util" "github.com/coreos/vcontext/path" "github.com/coreos/vcontext/report" @@ -44,8 +45,8 @@ func (p Partition) Key() string { } func (p Partition) Validate(c path.ContextPath) (r report.Report) { - if p.ShouldExist != nil && !*p.ShouldExist && - (p.Label != nil || (p.TypeGUID != nil && *p.TypeGUID != "") || (p.GUID != nil && *p.GUID != "") || p.StartMiB != nil || p.SizeMiB != nil) { + if util.IsFalse(p.ShouldExist) && + (p.Label != nil || util.NotEmpty(p.TypeGUID) || util.NotEmpty(p.GUID) || p.StartMiB != nil || p.SizeMiB != nil) { r.AddOnError(c, errors.ErrShouldNotExistWithOthers) } if p.Number == 0 && p.Label == nil { diff --git a/vendor/github.com/coreos/ignition/v2/config/v3_2/types/raid.go b/vendor/github.com/coreos/ignition/v2/config/v3_2/types/raid.go index 039e54e66..5ae4f8c09 100644 --- a/vendor/github.com/coreos/ignition/v2/config/v3_2/types/raid.go +++ b/vendor/github.com/coreos/ignition/v2/config/v3_2/types/raid.go @@ -33,6 +33,9 @@ func (r Raid) IgnoreDuplicates() map[string]struct{} { func (ra Raid) Validate(c path.ContextPath) (r report.Report) { r.AddOnError(c.Append("level"), ra.validateLevel()) + if len(ra.Devices) == 0 { + r.AddOnError(c.Append("devices"), errors.ErrRaidDevicesRequired) + } return } diff --git a/vendor/github.com/coreos/ignition/v2/config/v3_2/types/storage.go b/vendor/github.com/coreos/ignition/v2/config/v3_2/types/storage.go index db7e44acd..fd1b8cecf 100644 --- a/vendor/github.com/coreos/ignition/v2/config/v3_2/types/storage.go +++ b/vendor/github.com/coreos/ignition/v2/config/v3_2/types/storage.go @@ -19,6 +19,7 @@ import ( "strings" "github.com/coreos/ignition/v2/config/shared/errors" + "github.com/coreos/ignition/v2/config/util" vpath "github.com/coreos/vcontext/path" "github.com/coreos/vcontext/report" @@ -53,7 +54,7 @@ func (s Storage) Validate(c vpath.ContextPath) (r report.Report) { r.AddOnError(c.Append("links", i), errors.ErrLinkUsedSymlink) } } - if l1.Hard == nil || !*l1.Hard { + if !util.IsTrue(l1.Hard) { continue } target := path.Clean(l1.Target) diff --git a/vendor/github.com/coreos/ignition/v2/config/v3_2/types/unit.go b/vendor/github.com/coreos/ignition/v2/config/v3_2/types/unit.go index 8d1a5f00f..bc2d3299c 100644 --- a/vendor/github.com/coreos/ignition/v2/config/v3_2/types/unit.go +++ b/vendor/github.com/coreos/ignition/v2/config/v3_2/types/unit.go @@ -21,6 +21,7 @@ import ( "github.com/coreos/ignition/v2/config/shared/errors" "github.com/coreos/ignition/v2/config/shared/validations" + "github.com/coreos/ignition/v2/config/util" "github.com/coreos/go-systemd/v22/unit" cpath "github.com/coreos/vcontext/path" @@ -41,8 +42,7 @@ func (u Unit) Validate(c cpath.ContextPath) (r report.Report) { opts, err := validateUnitContent(u.Contents) r.AddOnError(c, err) - isEnabled := u.Enabled != nil && *u.Enabled - r.AddOnWarn(c, validations.ValidateInstallSection(u.Name, isEnabled, (u.Contents == nil || *u.Contents == ""), opts)) + r.AddOnWarn(c, validations.ValidateInstallSection(u.Name, util.IsTrue(u.Enabled), util.NilOrEmpty(u.Contents), opts)) return } diff --git a/vendor/github.com/coreos/vcontext/path/path.go b/vendor/github.com/coreos/vcontext/path/path.go index 3daadc784..58be8baa1 100644 --- a/vendor/github.com/coreos/vcontext/path/path.go +++ b/vendor/github.com/coreos/vcontext/path/path.go @@ -41,6 +41,10 @@ func (c ContextPath) String() string { return strings.Join(strs, ".") } +// Append returns a new ContextPath with the specified elements appended. +// The underlying array is sometimes reused, so if the original path might +// be used in future Append operations, the returned ContextPath should not +// be stored into a long-lived data structure. (Store a copy instead.) func (c ContextPath) Append(e ...interface{}) ContextPath { return ContextPath{ Path: append(c.Path, e...), @@ -48,6 +52,11 @@ func (c ContextPath) Append(e ...interface{}) ContextPath { } } +// Copy returns an identical ContextPath that shares no state with the +// original. When storing a ContextPath into a data structure, usually a +// copy should be stored instead of the original (for example, Report does +// this), since Append sometimes modifies the path's underlying array in +// place. func (c ContextPath) Copy() ContextPath { // make sure to preserve reflect.DeepEqual() equality var path []interface{} diff --git a/vendor/github.com/coreos/vcontext/report/report.go b/vendor/github.com/coreos/vcontext/report/report.go index 5378e8433..618bc7536 100644 --- a/vendor/github.com/coreos/vcontext/report/report.go +++ b/vendor/github.com/coreos/vcontext/report/report.go @@ -131,7 +131,7 @@ func (r *Report) AddOn(c path.ContextPath, err error, k EntryKind) { } r.Entries = append(r.Entries, Entry{ Message: err.Error(), - Context: c, + Context: c.Copy(), Kind: k, }) } diff --git a/vendor/github.com/spf13/pflag/flag.go b/vendor/github.com/spf13/pflag/flag.go index 24a5036e9..7c058de37 100644 --- a/vendor/github.com/spf13/pflag/flag.go +++ b/vendor/github.com/spf13/pflag/flag.go @@ -160,7 +160,7 @@ type FlagSet struct { args []string // arguments after flags argsLenAtDash int // len(args) when a '--' was located when parsing, or -1 if no -- errorHandling ErrorHandling - output io.Writer // nil means stderr; use out() accessor + output io.Writer // nil means stderr; use Output() accessor interspersed bool // allow interspersed option/non-option args normalizeNameFunc func(f *FlagSet, name string) NormalizedName @@ -255,13 +255,20 @@ func (f *FlagSet) normalizeFlagName(name string) NormalizedName { return n(f, name) } -func (f *FlagSet) out() io.Writer { +// Output returns the destination for usage and error messages. os.Stderr is returned if +// output was not set or was set to nil. +func (f *FlagSet) Output() io.Writer { if f.output == nil { return os.Stderr } return f.output } +// Name returns the name of the flag set. +func (f *FlagSet) Name() string { + return f.name +} + // SetOutput sets the destination for usage and error messages. // If output is nil, os.Stderr is used. func (f *FlagSet) SetOutput(output io.Writer) { @@ -358,7 +365,7 @@ func (f *FlagSet) ShorthandLookup(name string) *Flag { } if len(name) > 1 { msg := fmt.Sprintf("can not look up shorthand which is more than one ASCII character: %q", name) - fmt.Fprintf(f.out(), msg) + fmt.Fprintf(f.Output(), msg) panic(msg) } c := name[0] @@ -482,7 +489,7 @@ func (f *FlagSet) Set(name, value string) error { } if flag.Deprecated != "" { - fmt.Fprintf(f.out(), "Flag --%s has been deprecated, %s\n", flag.Name, flag.Deprecated) + fmt.Fprintf(f.Output(), "Flag --%s has been deprecated, %s\n", flag.Name, flag.Deprecated) } return nil } @@ -523,7 +530,7 @@ func Set(name, value string) error { // otherwise, the default values of all defined flags in the set. func (f *FlagSet) PrintDefaults() { usages := f.FlagUsages() - fmt.Fprint(f.out(), usages) + fmt.Fprint(f.Output(), usages) } // defaultIsZeroValue returns true if the default value for this flag represents @@ -758,7 +765,7 @@ func PrintDefaults() { // defaultUsage is the default function to print a usage message. func defaultUsage(f *FlagSet) { - fmt.Fprintf(f.out(), "Usage of %s:\n", f.name) + fmt.Fprintf(f.Output(), "Usage of %s:\n", f.name) f.PrintDefaults() } @@ -844,7 +851,7 @@ func (f *FlagSet) AddFlag(flag *Flag) { _, alreadyThere := f.formal[normalizedFlagName] if alreadyThere { msg := fmt.Sprintf("%s flag redefined: %s", f.name, flag.Name) - fmt.Fprintln(f.out(), msg) + fmt.Fprintln(f.Output(), msg) panic(msg) // Happens only if flags are declared with identical names } if f.formal == nil { @@ -860,7 +867,7 @@ func (f *FlagSet) AddFlag(flag *Flag) { } if len(flag.Shorthand) > 1 { msg := fmt.Sprintf("%q shorthand is more than one ASCII character", flag.Shorthand) - fmt.Fprintf(f.out(), msg) + fmt.Fprintf(f.Output(), msg) panic(msg) } if f.shorthands == nil { @@ -870,7 +877,7 @@ func (f *FlagSet) AddFlag(flag *Flag) { used, alreadyThere := f.shorthands[c] if alreadyThere { msg := fmt.Sprintf("unable to redefine %q shorthand in %q flagset: it's already used for %q flag", c, f.name, used.Name) - fmt.Fprintf(f.out(), msg) + fmt.Fprintf(f.Output(), msg) panic(msg) } f.shorthands[c] = flag @@ -909,7 +916,7 @@ func VarP(value Value, name, shorthand, usage string) { func (f *FlagSet) failf(format string, a ...interface{}) error { err := fmt.Errorf(format, a...) if f.errorHandling != ContinueOnError { - fmt.Fprintln(f.out(), err) + fmt.Fprintln(f.Output(), err) f.usage() } return err @@ -1060,7 +1067,7 @@ func (f *FlagSet) parseSingleShortArg(shorthands string, args []string, fn parse } if flag.ShorthandDeprecated != "" { - fmt.Fprintf(f.out(), "Flag shorthand -%s has been deprecated, %s\n", flag.Shorthand, flag.ShorthandDeprecated) + fmt.Fprintf(f.Output(), "Flag shorthand -%s has been deprecated, %s\n", flag.Shorthand, flag.ShorthandDeprecated) } err = fn(flag, value) diff --git a/vendor/github.com/spf13/pflag/ip.go b/vendor/github.com/spf13/pflag/ip.go index 3d414ba69..06b8bcb57 100644 --- a/vendor/github.com/spf13/pflag/ip.go +++ b/vendor/github.com/spf13/pflag/ip.go @@ -16,6 +16,9 @@ func newIPValue(val net.IP, p *net.IP) *ipValue { func (i *ipValue) String() string { return net.IP(*i).String() } func (i *ipValue) Set(s string) error { + if s == "" { + return nil + } ip := net.ParseIP(strings.TrimSpace(s)) if ip == nil { return fmt.Errorf("failed to parse IP: %q", s) diff --git a/vendor/github.com/spf13/pflag/ipnet_slice.go b/vendor/github.com/spf13/pflag/ipnet_slice.go new file mode 100644 index 000000000..6b541aa87 --- /dev/null +++ b/vendor/github.com/spf13/pflag/ipnet_slice.go @@ -0,0 +1,147 @@ +package pflag + +import ( + "fmt" + "io" + "net" + "strings" +) + +// -- ipNetSlice Value +type ipNetSliceValue struct { + value *[]net.IPNet + changed bool +} + +func newIPNetSliceValue(val []net.IPNet, p *[]net.IPNet) *ipNetSliceValue { + ipnsv := new(ipNetSliceValue) + ipnsv.value = p + *ipnsv.value = val + return ipnsv +} + +// Set converts, and assigns, the comma-separated IPNet argument string representation as the []net.IPNet value of this flag. +// If Set is called on a flag that already has a []net.IPNet assigned, the newly converted values will be appended. +func (s *ipNetSliceValue) Set(val string) error { + + // remove all quote characters + rmQuote := strings.NewReplacer(`"`, "", `'`, "", "`", "") + + // read flag arguments with CSV parser + ipNetStrSlice, err := readAsCSV(rmQuote.Replace(val)) + if err != nil && err != io.EOF { + return err + } + + // parse ip values into slice + out := make([]net.IPNet, 0, len(ipNetStrSlice)) + for _, ipNetStr := range ipNetStrSlice { + _, n, err := net.ParseCIDR(strings.TrimSpace(ipNetStr)) + if err != nil { + return fmt.Errorf("invalid string being converted to CIDR: %s", ipNetStr) + } + out = append(out, *n) + } + + if !s.changed { + *s.value = out + } else { + *s.value = append(*s.value, out...) + } + + s.changed = true + + return nil +} + +// Type returns a string that uniquely represents this flag's type. +func (s *ipNetSliceValue) Type() string { + return "ipNetSlice" +} + +// String defines a "native" format for this net.IPNet slice flag value. +func (s *ipNetSliceValue) String() string { + + ipNetStrSlice := make([]string, len(*s.value)) + for i, n := range *s.value { + ipNetStrSlice[i] = n.String() + } + + out, _ := writeAsCSV(ipNetStrSlice) + return "[" + out + "]" +} + +func ipNetSliceConv(val string) (interface{}, error) { + val = strings.Trim(val, "[]") + // Emtpy string would cause a slice with one (empty) entry + if len(val) == 0 { + return []net.IPNet{}, nil + } + ss := strings.Split(val, ",") + out := make([]net.IPNet, len(ss)) + for i, sval := range ss { + _, n, err := net.ParseCIDR(strings.TrimSpace(sval)) + if err != nil { + return nil, fmt.Errorf("invalid string being converted to CIDR: %s", sval) + } + out[i] = *n + } + return out, nil +} + +// GetIPNetSlice returns the []net.IPNet value of a flag with the given name +func (f *FlagSet) GetIPNetSlice(name string) ([]net.IPNet, error) { + val, err := f.getFlagType(name, "ipNetSlice", ipNetSliceConv) + if err != nil { + return []net.IPNet{}, err + } + return val.([]net.IPNet), nil +} + +// IPNetSliceVar defines a ipNetSlice flag with specified name, default value, and usage string. +// The argument p points to a []net.IPNet variable in which to store the value of the flag. +func (f *FlagSet) IPNetSliceVar(p *[]net.IPNet, name string, value []net.IPNet, usage string) { + f.VarP(newIPNetSliceValue(value, p), name, "", usage) +} + +// IPNetSliceVarP is like IPNetSliceVar, but accepts a shorthand letter that can be used after a single dash. +func (f *FlagSet) IPNetSliceVarP(p *[]net.IPNet, name, shorthand string, value []net.IPNet, usage string) { + f.VarP(newIPNetSliceValue(value, p), name, shorthand, usage) +} + +// IPNetSliceVar defines a []net.IPNet flag with specified name, default value, and usage string. +// The argument p points to a []net.IPNet variable in which to store the value of the flag. +func IPNetSliceVar(p *[]net.IPNet, name string, value []net.IPNet, usage string) { + CommandLine.VarP(newIPNetSliceValue(value, p), name, "", usage) +} + +// IPNetSliceVarP is like IPNetSliceVar, but accepts a shorthand letter that can be used after a single dash. +func IPNetSliceVarP(p *[]net.IPNet, name, shorthand string, value []net.IPNet, usage string) { + CommandLine.VarP(newIPNetSliceValue(value, p), name, shorthand, usage) +} + +// IPNetSlice defines a []net.IPNet flag with specified name, default value, and usage string. +// The return value is the address of a []net.IPNet variable that stores the value of that flag. +func (f *FlagSet) IPNetSlice(name string, value []net.IPNet, usage string) *[]net.IPNet { + p := []net.IPNet{} + f.IPNetSliceVarP(&p, name, "", value, usage) + return &p +} + +// IPNetSliceP is like IPNetSlice, but accepts a shorthand letter that can be used after a single dash. +func (f *FlagSet) IPNetSliceP(name, shorthand string, value []net.IPNet, usage string) *[]net.IPNet { + p := []net.IPNet{} + f.IPNetSliceVarP(&p, name, shorthand, value, usage) + return &p +} + +// IPNetSlice defines a []net.IPNet flag with specified name, default value, and usage string. +// The return value is the address of a []net.IP variable that stores the value of the flag. +func IPNetSlice(name string, value []net.IPNet, usage string) *[]net.IPNet { + return CommandLine.IPNetSliceP(name, "", value, usage) +} + +// IPNetSliceP is like IPNetSlice, but accepts a shorthand letter that can be used after a single dash. +func IPNetSliceP(name, shorthand string, value []net.IPNet, usage string) *[]net.IPNet { + return CommandLine.IPNetSliceP(name, shorthand, value, usage) +} diff --git a/vendor/github.com/spf13/pflag/string_array.go b/vendor/github.com/spf13/pflag/string_array.go index 4894af818..d1ff0a96b 100644 --- a/vendor/github.com/spf13/pflag/string_array.go +++ b/vendor/github.com/spf13/pflag/string_array.go @@ -31,11 +31,7 @@ func (s *stringArrayValue) Append(val string) error { func (s *stringArrayValue) Replace(val []string) error { out := make([]string, len(val)) for i, d := range val { - var err error out[i] = d - if err != nil { - return err - } } *s.value = out return nil diff --git a/vendor/modules.txt b/vendor/modules.txt index b74474d12..f25b57af3 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -66,14 +66,14 @@ github.com/coreos/ignition/config/shared/errors github.com/coreos/ignition/config/shared/validations github.com/coreos/ignition/config/v2_2/types github.com/coreos/ignition/config/validate/report -# github.com/coreos/ignition/v2 v2.9.0 -## explicit; go 1.11 +# github.com/coreos/ignition/v2 v2.14.0 +## explicit; go 1.15 github.com/coreos/ignition/v2/config/shared/errors github.com/coreos/ignition/v2/config/shared/validations github.com/coreos/ignition/v2/config/util github.com/coreos/ignition/v2/config/v3_2/types -# github.com/coreos/vcontext v0.0.0-20201120045928-b0e13dab675c -## explicit; go 1.11 +# github.com/coreos/vcontext v0.0.0-20211021162308-f1dbbca7bef4 +## explicit; go 1.15 github.com/coreos/vcontext/path github.com/coreos/vcontext/report github.com/coreos/vcontext/tree @@ -373,10 +373,10 @@ github.com/sirupsen/logrus # github.com/spf13/cobra v1.2.1 ## explicit; go 1.14 github.com/spf13/cobra -# github.com/spf13/pflag v1.0.5 +# github.com/spf13/pflag v1.0.6-0.20210604193023-d5e0c0615ace ## explicit; go 1.12 github.com/spf13/pflag -# github.com/vincent-petithory/dataurl v0.0.0-20191104211930-d1553a71de50 +# github.com/vincent-petithory/dataurl v1.0.0 ## explicit github.com/vincent-petithory/dataurl # go.mongodb.org/mongo-driver v1.3.0