Vendor in latest containers/image
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
parent
b6f6306231
commit
79a3808366
2
go.mod
2
go.mod
|
|
@ -5,7 +5,7 @@ go 1.13
|
|||
require (
|
||||
github.com/containerd/containerd v1.5.9
|
||||
github.com/containernetworking/cni v1.0.1
|
||||
github.com/containers/common v0.46.1-0.20220119203335-0e7aca71d00a
|
||||
github.com/containers/common v0.47.0
|
||||
github.com/containers/image/v5 v5.18.0
|
||||
github.com/containers/ocicrypt v1.1.2
|
||||
github.com/containers/storage v1.38.0
|
||||
|
|
|
|||
8
go.sum
8
go.sum
|
|
@ -270,8 +270,8 @@ github.com/containernetworking/plugins v0.8.6/go.mod h1:qnw5mN19D8fIwkqW7oHHYDHV
|
|||
github.com/containernetworking/plugins v0.9.1/go.mod h1:xP/idU2ldlzN6m4p5LmGiwRDjeJr6FLK6vuiUwoH7P8=
|
||||
github.com/containernetworking/plugins v1.0.1 h1:wwCfYbTCj5FC0EJgyzyjTXmqysOiJE9r712Z+2KVZAk=
|
||||
github.com/containernetworking/plugins v1.0.1/go.mod h1:QHCfGpaTwYTbbH+nZXKVTxNBDZcxSOplJT5ico8/FLE=
|
||||
github.com/containers/common v0.46.1-0.20220119203335-0e7aca71d00a h1:2f2PbMRN/Lu9sJpFFBpKv7g/8izZOUv9HObOnQWlS14=
|
||||
github.com/containers/common v0.46.1-0.20220119203335-0e7aca71d00a/go.mod h1:zIOEbgW3aBOXx9lsi91kcbX784HVH60ePkEBgbvPJ7g=
|
||||
github.com/containers/common v0.47.0 h1:3O+EVHvFz/VrBoffhCdzyNd49WZkTJ/VsZzDgQjR+nA=
|
||||
github.com/containers/common v0.47.0/go.mod h1:9+wnfBX52fFSqMDAvivlBB0WsQdOP3U9UZeKrYhJRTM=
|
||||
github.com/containers/image/v5 v5.18.0 h1:YbvpXl5zd6IbZnt4XiOU0+c24xBQAQL9q3/e5kyk19k=
|
||||
github.com/containers/image/v5 v5.18.0/go.mod h1:ybujPwS7YEAPhLXJ3vvZGdKftk+sPSvp/djg9qTPvro=
|
||||
github.com/containers/libtrust v0.0.0-20190913040956-14b96171aa3b h1:Q8ePgVfHDplZ7U33NwHZkrVELsZP5fYj9pM5WBZB2GE=
|
||||
|
|
@ -581,8 +581,8 @@ github.com/ishidawataru/sctp v0.0.0-20210226210310-f2269e66cdee h1:PAXLXk1heNZ5y
|
|||
github.com/ishidawataru/sctp v0.0.0-20210226210310-f2269e66cdee/go.mod h1:co9pwDoBCm1kGxawmb4sPq0cSIOOWNPT4KnHotMP1Zg=
|
||||
github.com/j-keck/arping v0.0.0-20160618110441-2cf9dc699c56/go.mod h1:ymszkNOg6tORTn+6F6j+Jc8TOr5osrynvN6ivFWZ2GA=
|
||||
github.com/j-keck/arping v1.0.2/go.mod h1:aJbELhR92bSk7tp79AWM/ftfc90EfEi2bQJrbBFOsPw=
|
||||
github.com/jinzhu/copier v0.3.4 h1:mfU6jI9PtCeUjkjQ322dlff9ELjGDu975C2p/nrubVI=
|
||||
github.com/jinzhu/copier v0.3.4/go.mod h1:DfbEm0FYsaqBcKcFuvmOZb218JkPGtvSHsKg8S8hyyg=
|
||||
github.com/jinzhu/copier v0.3.5 h1:GlvfUwHk62RokgqVNvYsku0TATCF7bAHVwEXoBh3iJg=
|
||||
github.com/jinzhu/copier v0.3.5/go.mod h1:DfbEm0FYsaqBcKcFuvmOZb218JkPGtvSHsKg8S8hyyg=
|
||||
github.com/jmespath/go-jmespath v0.0.0-20160202185014-0b12d6b521d8/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
|
||||
github.com/jmespath/go-jmespath v0.0.0-20160803190731-bd40a432e4c7/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
|
||||
github.com/joefitzgerald/rainbow-reporter v0.1.0/go.mod h1:481CNgqmVHQZzdIbN52CupLJyoVwB10FQ/IQlF1pdL8=
|
||||
|
|
|
|||
|
|
@ -181,11 +181,6 @@ type ContainersConfig struct {
|
|||
// performance implications.
|
||||
PrepareVolumeOnCreate bool `toml:"prepare_volume_on_create,omitempty"`
|
||||
|
||||
// RootlessNetworking depicts the "kind" of networking for rootless
|
||||
// containers. Valid options are `slirp4netns` and `cni`. Default is
|
||||
// `slirp4netns` on Linux, and `cni` on non-Linux OSes.
|
||||
RootlessNetworking string `toml:"rootless_networking,omitempty"`
|
||||
|
||||
// SeccompProfile is the seccomp.json profile path which is used as the
|
||||
// default for the runtime.
|
||||
SeccompProfile string `toml:"seccomp_profile,omitempty"`
|
||||
|
|
|
|||
|
|
@ -197,10 +197,6 @@ default_sysctls = [
|
|||
#
|
||||
#prepare_volume_on_create = false
|
||||
|
||||
# Indicates the networking to be used for rootless containers
|
||||
#
|
||||
#rootless_networking = "slirp4netns"
|
||||
|
||||
# Path to the seccomp.json profile which is used as the default seccomp profile
|
||||
# for the runtime.
|
||||
#
|
||||
|
|
|
|||
|
|
@ -177,23 +177,22 @@ func DefaultConfig() (*Config, error) {
|
|||
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
|
||||
"TERM=xterm",
|
||||
},
|
||||
EnvHost: false,
|
||||
HTTPProxy: true,
|
||||
Init: false,
|
||||
InitPath: "",
|
||||
IPCNS: "private",
|
||||
LogDriver: defaultLogDriver(),
|
||||
LogSizeMax: DefaultLogSizeMax,
|
||||
NetNS: "private",
|
||||
NoHosts: false,
|
||||
PidsLimit: DefaultPidsLimit,
|
||||
PidNS: "private",
|
||||
RootlessNetworking: getDefaultRootlessNetwork(),
|
||||
ShmSize: DefaultShmSize,
|
||||
TZ: "",
|
||||
Umask: "0022",
|
||||
UTSNS: "private",
|
||||
UserNSSize: DefaultUserNSSize,
|
||||
EnvHost: false,
|
||||
HTTPProxy: true,
|
||||
Init: false,
|
||||
InitPath: "",
|
||||
IPCNS: "private",
|
||||
LogDriver: defaultLogDriver(),
|
||||
LogSizeMax: DefaultLogSizeMax,
|
||||
NetNS: "private",
|
||||
NoHosts: false,
|
||||
PidsLimit: DefaultPidsLimit,
|
||||
PidNS: "private",
|
||||
ShmSize: DefaultShmSize,
|
||||
TZ: "",
|
||||
Umask: "0022",
|
||||
UTSNS: "private",
|
||||
UserNSSize: DefaultUserNSSize,
|
||||
},
|
||||
Network: NetworkConfig{
|
||||
DefaultNetwork: "podman",
|
||||
|
|
@ -566,9 +565,3 @@ func (c *Config) LogDriver() string {
|
|||
func (c *Config) MachineEnabled() bool {
|
||||
return c.Engine.MachineEnabled
|
||||
}
|
||||
|
||||
// RootlessNetworking returns the "kind" of networking
|
||||
// rootless containers should use
|
||||
func (c *Config) RootlessNetworking() string {
|
||||
return c.Containers.RootlessNetworking
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,12 +24,6 @@ func getDefaultMachineUser() string {
|
|||
return "core"
|
||||
}
|
||||
|
||||
// getDefaultRootlessNetwork returns the default rootless network configuration.
|
||||
// It is "slirp4netns" for Linux.
|
||||
func getDefaultRootlessNetwork() string {
|
||||
return "slirp4netns"
|
||||
}
|
||||
|
||||
// getDefaultProcessLimits returns the nproc for the current process in ulimits format
|
||||
// Note that nfile sometimes cannot be set to unlimited, and the limit is hardcoded
|
||||
// to (oldMaxSize) 1048576 (2^20), see: http://stackoverflow.com/a/1213069/1811501
|
||||
|
|
|
|||
|
|
@ -13,12 +13,6 @@ func getDefaultMachineUser() string {
|
|||
return "core"
|
||||
}
|
||||
|
||||
// getDefaultRootlessNetwork returns the default rootless network configuration.
|
||||
// It is "cni" for non-Linux OSes (to better support `podman-machine` usecases).
|
||||
func getDefaultRootlessNetwork() string {
|
||||
return "cni"
|
||||
}
|
||||
|
||||
// isCgroup2UnifiedMode returns whether we are running in cgroup2 mode.
|
||||
func isCgroup2UnifiedMode() (isUnified bool, isUnifiedErr error) {
|
||||
return false, nil
|
||||
|
|
|
|||
|
|
@ -11,12 +11,6 @@ func getDefaultMachineUser() string {
|
|||
return "user"
|
||||
}
|
||||
|
||||
// getDefaultRootlessNetwork returns the default rootless network configuration.
|
||||
// It is "cni" for non-Linux OSes (to better support `podman-machine` usecases).
|
||||
func getDefaultRootlessNetwork() string {
|
||||
return "cni"
|
||||
}
|
||||
|
||||
// isCgroup2UnifiedMode returns whether we are running in cgroup2 mode.
|
||||
func isCgroup2UnifiedMode() (isUnified bool, isUnifiedErr error) {
|
||||
return false, nil
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package version
|
||||
|
||||
// Version is the version of the build.
|
||||
const Version = "0.46.1-dev"
|
||||
const Version = "0.47.0"
|
||||
|
|
|
|||
|
|
@ -24,6 +24,13 @@ const (
|
|||
|
||||
// Denotes that the value as been copied
|
||||
hasCopied
|
||||
|
||||
// Some default converter types for a nicer syntax
|
||||
String string = ""
|
||||
Bool bool = false
|
||||
Int int = 0
|
||||
Float32 float32 = 0
|
||||
Float64 float64 = 0
|
||||
)
|
||||
|
||||
// Option sets copy options
|
||||
|
|
@ -32,6 +39,18 @@ type Option struct {
|
|||
// struct having all it's fields set to their zero values respectively (see IsZero() in reflect/value.go)
|
||||
IgnoreEmpty bool
|
||||
DeepCopy bool
|
||||
Converters []TypeConverter
|
||||
}
|
||||
|
||||
type TypeConverter struct {
|
||||
SrcType interface{}
|
||||
DstType interface{}
|
||||
Fn func(src interface{}) (interface{}, error)
|
||||
}
|
||||
|
||||
type converterPair struct {
|
||||
SrcType reflect.Type
|
||||
DstType reflect.Type
|
||||
}
|
||||
|
||||
// Tag Flags
|
||||
|
|
@ -59,12 +78,27 @@ func CopyWithOption(toValue interface{}, fromValue interface{}, opt Option) (err
|
|||
|
||||
func copier(toValue interface{}, fromValue interface{}, opt Option) (err error) {
|
||||
var (
|
||||
isSlice bool
|
||||
amount = 1
|
||||
from = indirect(reflect.ValueOf(fromValue))
|
||||
to = indirect(reflect.ValueOf(toValue))
|
||||
isSlice bool
|
||||
amount = 1
|
||||
from = indirect(reflect.ValueOf(fromValue))
|
||||
to = indirect(reflect.ValueOf(toValue))
|
||||
converters map[converterPair]TypeConverter
|
||||
)
|
||||
|
||||
// save convertes into map for faster lookup
|
||||
for i := range opt.Converters {
|
||||
if converters == nil {
|
||||
converters = make(map[converterPair]TypeConverter)
|
||||
}
|
||||
|
||||
pair := converterPair{
|
||||
SrcType: reflect.TypeOf(opt.Converters[i].SrcType),
|
||||
DstType: reflect.TypeOf(opt.Converters[i].DstType),
|
||||
}
|
||||
|
||||
converters[pair] = opt.Converters[i]
|
||||
}
|
||||
|
||||
if !to.CanAddr() {
|
||||
return ErrInvalidCopyDestination
|
||||
}
|
||||
|
|
@ -113,13 +147,16 @@ func copier(toValue interface{}, fromValue interface{}, opt Option) (err error)
|
|||
|
||||
for _, k := range from.MapKeys() {
|
||||
toKey := indirect(reflect.New(toType.Key()))
|
||||
if !set(toKey, k, opt.DeepCopy) {
|
||||
if !set(toKey, k, opt.DeepCopy, converters) {
|
||||
return fmt.Errorf("%w map, old key: %v, new key: %v", ErrNotSupported, k.Type(), toType.Key())
|
||||
}
|
||||
|
||||
elemType, _ := indirectType(toType.Elem())
|
||||
elemType := toType.Elem()
|
||||
if elemType.Kind() != reflect.Slice {
|
||||
elemType, _ = indirectType(elemType)
|
||||
}
|
||||
toValue := indirect(reflect.New(elemType))
|
||||
if !set(toValue, from.MapIndex(k), opt.DeepCopy) {
|
||||
if !set(toValue, from.MapIndex(k), opt.DeepCopy, converters) {
|
||||
if err = copier(toValue.Addr().Interface(), from.MapIndex(k).Interface(), opt); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -148,7 +185,7 @@ func copier(toValue interface{}, fromValue interface{}, opt Option) (err error)
|
|||
to.Set(reflect.Append(to, reflect.New(to.Type().Elem()).Elem()))
|
||||
}
|
||||
|
||||
if !set(to.Index(i), from.Index(i), opt.DeepCopy) {
|
||||
if !set(to.Index(i), from.Index(i), opt.DeepCopy, converters) {
|
||||
// ignore error while copy slice element
|
||||
err = copier(to.Index(i).Addr().Interface(), from.Index(i).Interface(), opt)
|
||||
if err != nil {
|
||||
|
|
@ -203,6 +240,8 @@ func copier(toValue interface{}, fromValue interface{}, opt Option) (err error)
|
|||
|
||||
// check source
|
||||
if source.IsValid() {
|
||||
copyUnexportedStructFields(dest, source)
|
||||
|
||||
// Copy from source field to dest field or method
|
||||
fromTypeFields := deepFields(fromType)
|
||||
for _, field := range fromTypeFields {
|
||||
|
|
@ -249,7 +288,7 @@ func copier(toValue interface{}, fromValue interface{}, opt Option) (err error)
|
|||
toField := dest.FieldByName(destFieldName)
|
||||
if toField.IsValid() {
|
||||
if toField.CanSet() {
|
||||
if !set(toField, fromField, opt.DeepCopy) {
|
||||
if !set(toField, fromField, opt.DeepCopy, converters) {
|
||||
if err := copier(toField.Addr().Interface(), fromField.Interface(), opt); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -291,7 +330,7 @@ func copier(toValue interface{}, fromValue interface{}, opt Option) (err error)
|
|||
if toField := dest.FieldByName(destFieldName); toField.IsValid() && toField.CanSet() {
|
||||
values := fromMethod.Call([]reflect.Value{})
|
||||
if len(values) >= 1 {
|
||||
set(toField, values[0], opt.DeepCopy)
|
||||
set(toField, values[0], opt.DeepCopy, converters)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -303,7 +342,7 @@ func copier(toValue interface{}, fromValue interface{}, opt Option) (err error)
|
|||
if to.Len() < i+1 {
|
||||
to.Set(reflect.Append(to, dest.Addr()))
|
||||
} else {
|
||||
if !set(to.Index(i), dest.Addr(), opt.DeepCopy) {
|
||||
if !set(to.Index(i), dest.Addr(), opt.DeepCopy, converters) {
|
||||
// ignore error while copy slice element
|
||||
err = copier(to.Index(i).Addr().Interface(), dest.Addr().Interface(), opt)
|
||||
if err != nil {
|
||||
|
|
@ -315,7 +354,7 @@ func copier(toValue interface{}, fromValue interface{}, opt Option) (err error)
|
|||
if to.Len() < i+1 {
|
||||
to.Set(reflect.Append(to, dest))
|
||||
} else {
|
||||
if !set(to.Index(i), dest, opt.DeepCopy) {
|
||||
if !set(to.Index(i), dest, opt.DeepCopy, converters) {
|
||||
// ignore error while copy slice element
|
||||
err = copier(to.Index(i).Addr().Interface(), dest.Interface(), opt)
|
||||
if err != nil {
|
||||
|
|
@ -334,6 +373,24 @@ func copier(toValue interface{}, fromValue interface{}, opt Option) (err error)
|
|||
return
|
||||
}
|
||||
|
||||
func copyUnexportedStructFields(to, from reflect.Value) {
|
||||
if from.Kind() != reflect.Struct || to.Kind() != reflect.Struct || !from.Type().AssignableTo(to.Type()) {
|
||||
return
|
||||
}
|
||||
|
||||
// create a shallow copy of 'to' to get all fields
|
||||
tmp := indirect(reflect.New(to.Type()))
|
||||
tmp.Set(from)
|
||||
|
||||
// revert exported fields
|
||||
for i := 0; i < to.NumField(); i++ {
|
||||
if tmp.Field(i).CanSet() {
|
||||
tmp.Field(i).Set(to.Field(i))
|
||||
}
|
||||
}
|
||||
to.Set(tmp)
|
||||
}
|
||||
|
||||
func shouldIgnore(v reflect.Value, ignoreEmpty bool) bool {
|
||||
if !ignoreEmpty {
|
||||
return false
|
||||
|
|
@ -352,10 +409,10 @@ func deepFields(reflectType reflect.Type) []reflect.StructField {
|
|||
// field name. It is empty for upper case (exported) field names.
|
||||
// See https://golang.org/ref/spec#Uniqueness_of_identifiers
|
||||
if v.PkgPath == "" {
|
||||
fields = append(fields, v)
|
||||
if v.Anonymous {
|
||||
// also consider fields of anonymous fields as fields of the root
|
||||
fields = append(fields, deepFields(v.Type)...)
|
||||
} else {
|
||||
fields = append(fields, v)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -381,8 +438,14 @@ func indirectType(reflectType reflect.Type) (_ reflect.Type, isPtr bool) {
|
|||
return reflectType, isPtr
|
||||
}
|
||||
|
||||
func set(to, from reflect.Value, deepCopy bool) bool {
|
||||
func set(to, from reflect.Value, deepCopy bool, converters map[converterPair]TypeConverter) bool {
|
||||
if from.IsValid() {
|
||||
if ok, err := lookupAndCopyWithConverter(to, from, converters); err != nil {
|
||||
return false
|
||||
} else if ok {
|
||||
return true
|
||||
}
|
||||
|
||||
if to.Kind() == reflect.Ptr {
|
||||
// set `to` to nil if from is nil
|
||||
if from.Kind() == reflect.Ptr && from.IsNil() {
|
||||
|
|
@ -416,6 +479,9 @@ func set(to, from reflect.Value, deepCopy bool) bool {
|
|||
toKind = reflect.TypeOf(to.Interface()).Kind()
|
||||
}
|
||||
}
|
||||
if from.Kind() == reflect.Ptr && from.IsNil() {
|
||||
return true
|
||||
}
|
||||
if toKind == reflect.Struct || toKind == reflect.Map || toKind == reflect.Slice {
|
||||
return false
|
||||
}
|
||||
|
|
@ -457,7 +523,7 @@ func set(to, from reflect.Value, deepCopy bool) bool {
|
|||
to.Set(rv)
|
||||
}
|
||||
} else if from.Kind() == reflect.Ptr {
|
||||
return set(to, from.Elem(), deepCopy)
|
||||
return set(to, from.Elem(), deepCopy, converters)
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
|
|
@ -466,6 +532,33 @@ func set(to, from reflect.Value, deepCopy bool) bool {
|
|||
return true
|
||||
}
|
||||
|
||||
// lookupAndCopyWithConverter looks up the type pair, on success the TypeConverter Fn func is called to copy src to dst field.
|
||||
func lookupAndCopyWithConverter(to, from reflect.Value, converters map[converterPair]TypeConverter) (copied bool, err error) {
|
||||
pair := converterPair{
|
||||
SrcType: from.Type(),
|
||||
DstType: to.Type(),
|
||||
}
|
||||
|
||||
if cnv, ok := converters[pair]; ok {
|
||||
result, err := cnv.Fn(from.Interface())
|
||||
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
if result != nil {
|
||||
to.Set(reflect.ValueOf(result))
|
||||
} else {
|
||||
// in case we've got a nil value to copy
|
||||
to.Set(reflect.Zero(to.Type()))
|
||||
}
|
||||
|
||||
return true, nil
|
||||
}
|
||||
|
||||
return false, nil
|
||||
}
|
||||
|
||||
// parseTags Parses struct tags and returns uint8 bit flags.
|
||||
func parseTags(tag string) (flg uint8, name string, err error) {
|
||||
for _, t := range strings.Split(tag, ",") {
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ github.com/containernetworking/cni/pkg/utils
|
|||
github.com/containernetworking/cni/pkg/version
|
||||
# github.com/containernetworking/plugins v1.0.1
|
||||
github.com/containernetworking/plugins/pkg/ns
|
||||
# github.com/containers/common v0.46.1-0.20220119203335-0e7aca71d00a
|
||||
# github.com/containers/common v0.47.0
|
||||
github.com/containers/common/libimage
|
||||
github.com/containers/common/libimage/manifests
|
||||
github.com/containers/common/libnetwork/cni
|
||||
|
|
@ -309,7 +309,7 @@ github.com/imdario/mergo
|
|||
github.com/inconshreveable/mousetrap
|
||||
# github.com/ishidawataru/sctp v0.0.0-20210226210310-f2269e66cdee
|
||||
github.com/ishidawataru/sctp
|
||||
# github.com/jinzhu/copier v0.3.4
|
||||
# github.com/jinzhu/copier v0.3.5
|
||||
github.com/jinzhu/copier
|
||||
# github.com/json-iterator/go v1.1.12
|
||||
github.com/json-iterator/go
|
||||
|
|
|
|||
Loading…
Reference in New Issue