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 (
|
require (
|
||||||
github.com/containerd/containerd v1.5.9
|
github.com/containerd/containerd v1.5.9
|
||||||
github.com/containernetworking/cni v1.0.1
|
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/image/v5 v5.18.0
|
||||||
github.com/containers/ocicrypt v1.1.2
|
github.com/containers/ocicrypt v1.1.2
|
||||||
github.com/containers/storage v1.38.0
|
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 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 h1:wwCfYbTCj5FC0EJgyzyjTXmqysOiJE9r712Z+2KVZAk=
|
||||||
github.com/containernetworking/plugins v1.0.1/go.mod h1:QHCfGpaTwYTbbH+nZXKVTxNBDZcxSOplJT5ico8/FLE=
|
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.47.0 h1:3O+EVHvFz/VrBoffhCdzyNd49WZkTJ/VsZzDgQjR+nA=
|
||||||
github.com/containers/common v0.46.1-0.20220119203335-0e7aca71d00a/go.mod h1:zIOEbgW3aBOXx9lsi91kcbX784HVH60ePkEBgbvPJ7g=
|
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 h1:YbvpXl5zd6IbZnt4XiOU0+c24xBQAQL9q3/e5kyk19k=
|
||||||
github.com/containers/image/v5 v5.18.0/go.mod h1:ybujPwS7YEAPhLXJ3vvZGdKftk+sPSvp/djg9qTPvro=
|
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=
|
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/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 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/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.5 h1:GlvfUwHk62RokgqVNvYsku0TATCF7bAHVwEXoBh3iJg=
|
||||||
github.com/jinzhu/copier v0.3.4/go.mod h1:DfbEm0FYsaqBcKcFuvmOZb218JkPGtvSHsKg8S8hyyg=
|
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-20160202185014-0b12d6b521d8/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
|
||||||
github.com/jmespath/go-jmespath v0.0.0-20160803190731-bd40a432e4c7/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=
|
github.com/joefitzgerald/rainbow-reporter v0.1.0/go.mod h1:481CNgqmVHQZzdIbN52CupLJyoVwB10FQ/IQlF1pdL8=
|
||||||
|
|
|
||||||
|
|
@ -181,11 +181,6 @@ type ContainersConfig struct {
|
||||||
// performance implications.
|
// performance implications.
|
||||||
PrepareVolumeOnCreate bool `toml:"prepare_volume_on_create,omitempty"`
|
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
|
// SeccompProfile is the seccomp.json profile path which is used as the
|
||||||
// default for the runtime.
|
// default for the runtime.
|
||||||
SeccompProfile string `toml:"seccomp_profile,omitempty"`
|
SeccompProfile string `toml:"seccomp_profile,omitempty"`
|
||||||
|
|
|
||||||
|
|
@ -197,10 +197,6 @@ default_sysctls = [
|
||||||
#
|
#
|
||||||
#prepare_volume_on_create = false
|
#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
|
# Path to the seccomp.json profile which is used as the default seccomp profile
|
||||||
# for the runtime.
|
# for the runtime.
|
||||||
#
|
#
|
||||||
|
|
|
||||||
|
|
@ -177,23 +177,22 @@ func DefaultConfig() (*Config, error) {
|
||||||
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
|
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
|
||||||
"TERM=xterm",
|
"TERM=xterm",
|
||||||
},
|
},
|
||||||
EnvHost: false,
|
EnvHost: false,
|
||||||
HTTPProxy: true,
|
HTTPProxy: true,
|
||||||
Init: false,
|
Init: false,
|
||||||
InitPath: "",
|
InitPath: "",
|
||||||
IPCNS: "private",
|
IPCNS: "private",
|
||||||
LogDriver: defaultLogDriver(),
|
LogDriver: defaultLogDriver(),
|
||||||
LogSizeMax: DefaultLogSizeMax,
|
LogSizeMax: DefaultLogSizeMax,
|
||||||
NetNS: "private",
|
NetNS: "private",
|
||||||
NoHosts: false,
|
NoHosts: false,
|
||||||
PidsLimit: DefaultPidsLimit,
|
PidsLimit: DefaultPidsLimit,
|
||||||
PidNS: "private",
|
PidNS: "private",
|
||||||
RootlessNetworking: getDefaultRootlessNetwork(),
|
ShmSize: DefaultShmSize,
|
||||||
ShmSize: DefaultShmSize,
|
TZ: "",
|
||||||
TZ: "",
|
Umask: "0022",
|
||||||
Umask: "0022",
|
UTSNS: "private",
|
||||||
UTSNS: "private",
|
UserNSSize: DefaultUserNSSize,
|
||||||
UserNSSize: DefaultUserNSSize,
|
|
||||||
},
|
},
|
||||||
Network: NetworkConfig{
|
Network: NetworkConfig{
|
||||||
DefaultNetwork: "podman",
|
DefaultNetwork: "podman",
|
||||||
|
|
@ -566,9 +565,3 @@ func (c *Config) LogDriver() string {
|
||||||
func (c *Config) MachineEnabled() bool {
|
func (c *Config) MachineEnabled() bool {
|
||||||
return c.Engine.MachineEnabled
|
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"
|
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
|
// 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
|
// 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
|
// to (oldMaxSize) 1048576 (2^20), see: http://stackoverflow.com/a/1213069/1811501
|
||||||
|
|
|
||||||
|
|
@ -13,12 +13,6 @@ func getDefaultMachineUser() string {
|
||||||
return "core"
|
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.
|
// isCgroup2UnifiedMode returns whether we are running in cgroup2 mode.
|
||||||
func isCgroup2UnifiedMode() (isUnified bool, isUnifiedErr error) {
|
func isCgroup2UnifiedMode() (isUnified bool, isUnifiedErr error) {
|
||||||
return false, nil
|
return false, nil
|
||||||
|
|
|
||||||
|
|
@ -11,12 +11,6 @@ func getDefaultMachineUser() string {
|
||||||
return "user"
|
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.
|
// isCgroup2UnifiedMode returns whether we are running in cgroup2 mode.
|
||||||
func isCgroup2UnifiedMode() (isUnified bool, isUnifiedErr error) {
|
func isCgroup2UnifiedMode() (isUnified bool, isUnifiedErr error) {
|
||||||
return false, nil
|
return false, nil
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package version
|
package version
|
||||||
|
|
||||||
// Version is the version of the build.
|
// 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
|
// Denotes that the value as been copied
|
||||||
hasCopied
|
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
|
// 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)
|
// struct having all it's fields set to their zero values respectively (see IsZero() in reflect/value.go)
|
||||||
IgnoreEmpty bool
|
IgnoreEmpty bool
|
||||||
DeepCopy 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
|
// 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) {
|
func copier(toValue interface{}, fromValue interface{}, opt Option) (err error) {
|
||||||
var (
|
var (
|
||||||
isSlice bool
|
isSlice bool
|
||||||
amount = 1
|
amount = 1
|
||||||
from = indirect(reflect.ValueOf(fromValue))
|
from = indirect(reflect.ValueOf(fromValue))
|
||||||
to = indirect(reflect.ValueOf(toValue))
|
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() {
|
if !to.CanAddr() {
|
||||||
return ErrInvalidCopyDestination
|
return ErrInvalidCopyDestination
|
||||||
}
|
}
|
||||||
|
|
@ -113,13 +147,16 @@ func copier(toValue interface{}, fromValue interface{}, opt Option) (err error)
|
||||||
|
|
||||||
for _, k := range from.MapKeys() {
|
for _, k := range from.MapKeys() {
|
||||||
toKey := indirect(reflect.New(toType.Key()))
|
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())
|
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))
|
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 {
|
if err = copier(toValue.Addr().Interface(), from.MapIndex(k).Interface(), opt); err != nil {
|
||||||
return err
|
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()))
|
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
|
// ignore error while copy slice element
|
||||||
err = copier(to.Index(i).Addr().Interface(), from.Index(i).Interface(), opt)
|
err = copier(to.Index(i).Addr().Interface(), from.Index(i).Interface(), opt)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -203,6 +240,8 @@ func copier(toValue interface{}, fromValue interface{}, opt Option) (err error)
|
||||||
|
|
||||||
// check source
|
// check source
|
||||||
if source.IsValid() {
|
if source.IsValid() {
|
||||||
|
copyUnexportedStructFields(dest, source)
|
||||||
|
|
||||||
// Copy from source field to dest field or method
|
// Copy from source field to dest field or method
|
||||||
fromTypeFields := deepFields(fromType)
|
fromTypeFields := deepFields(fromType)
|
||||||
for _, field := range fromTypeFields {
|
for _, field := range fromTypeFields {
|
||||||
|
|
@ -249,7 +288,7 @@ func copier(toValue interface{}, fromValue interface{}, opt Option) (err error)
|
||||||
toField := dest.FieldByName(destFieldName)
|
toField := dest.FieldByName(destFieldName)
|
||||||
if toField.IsValid() {
|
if toField.IsValid() {
|
||||||
if toField.CanSet() {
|
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 {
|
if err := copier(toField.Addr().Interface(), fromField.Interface(), opt); err != nil {
|
||||||
return err
|
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() {
|
if toField := dest.FieldByName(destFieldName); toField.IsValid() && toField.CanSet() {
|
||||||
values := fromMethod.Call([]reflect.Value{})
|
values := fromMethod.Call([]reflect.Value{})
|
||||||
if len(values) >= 1 {
|
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 {
|
if to.Len() < i+1 {
|
||||||
to.Set(reflect.Append(to, dest.Addr()))
|
to.Set(reflect.Append(to, dest.Addr()))
|
||||||
} else {
|
} 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
|
// ignore error while copy slice element
|
||||||
err = copier(to.Index(i).Addr().Interface(), dest.Addr().Interface(), opt)
|
err = copier(to.Index(i).Addr().Interface(), dest.Addr().Interface(), opt)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -315,7 +354,7 @@ func copier(toValue interface{}, fromValue interface{}, opt Option) (err error)
|
||||||
if to.Len() < i+1 {
|
if to.Len() < i+1 {
|
||||||
to.Set(reflect.Append(to, dest))
|
to.Set(reflect.Append(to, dest))
|
||||||
} else {
|
} else {
|
||||||
if !set(to.Index(i), dest, opt.DeepCopy) {
|
if !set(to.Index(i), dest, opt.DeepCopy, converters) {
|
||||||
// ignore error while copy slice element
|
// ignore error while copy slice element
|
||||||
err = copier(to.Index(i).Addr().Interface(), dest.Interface(), opt)
|
err = copier(to.Index(i).Addr().Interface(), dest.Interface(), opt)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -334,6 +373,24 @@ func copier(toValue interface{}, fromValue interface{}, opt Option) (err error)
|
||||||
return
|
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 {
|
func shouldIgnore(v reflect.Value, ignoreEmpty bool) bool {
|
||||||
if !ignoreEmpty {
|
if !ignoreEmpty {
|
||||||
return false
|
return false
|
||||||
|
|
@ -352,10 +409,10 @@ func deepFields(reflectType reflect.Type) []reflect.StructField {
|
||||||
// field name. It is empty for upper case (exported) field names.
|
// field name. It is empty for upper case (exported) field names.
|
||||||
// See https://golang.org/ref/spec#Uniqueness_of_identifiers
|
// See https://golang.org/ref/spec#Uniqueness_of_identifiers
|
||||||
if v.PkgPath == "" {
|
if v.PkgPath == "" {
|
||||||
|
fields = append(fields, v)
|
||||||
if v.Anonymous {
|
if v.Anonymous {
|
||||||
|
// also consider fields of anonymous fields as fields of the root
|
||||||
fields = append(fields, deepFields(v.Type)...)
|
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
|
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 from.IsValid() {
|
||||||
|
if ok, err := lookupAndCopyWithConverter(to, from, converters); err != nil {
|
||||||
|
return false
|
||||||
|
} else if ok {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
if to.Kind() == reflect.Ptr {
|
if to.Kind() == reflect.Ptr {
|
||||||
// set `to` to nil if from is nil
|
// set `to` to nil if from is nil
|
||||||
if from.Kind() == reflect.Ptr && from.IsNil() {
|
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()
|
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 {
|
if toKind == reflect.Struct || toKind == reflect.Map || toKind == reflect.Slice {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
@ -457,7 +523,7 @@ func set(to, from reflect.Value, deepCopy bool) bool {
|
||||||
to.Set(rv)
|
to.Set(rv)
|
||||||
}
|
}
|
||||||
} else if from.Kind() == reflect.Ptr {
|
} else if from.Kind() == reflect.Ptr {
|
||||||
return set(to, from.Elem(), deepCopy)
|
return set(to, from.Elem(), deepCopy, converters)
|
||||||
} else {
|
} else {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
@ -466,6 +532,33 @@ func set(to, from reflect.Value, deepCopy bool) bool {
|
||||||
return true
|
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.
|
// parseTags Parses struct tags and returns uint8 bit flags.
|
||||||
func parseTags(tag string) (flg uint8, name string, err error) {
|
func parseTags(tag string) (flg uint8, name string, err error) {
|
||||||
for _, t := range strings.Split(tag, ",") {
|
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/cni/pkg/version
|
||||||
# github.com/containernetworking/plugins v1.0.1
|
# github.com/containernetworking/plugins v1.0.1
|
||||||
github.com/containernetworking/plugins/pkg/ns
|
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
|
||||||
github.com/containers/common/libimage/manifests
|
github.com/containers/common/libimage/manifests
|
||||||
github.com/containers/common/libnetwork/cni
|
github.com/containers/common/libnetwork/cni
|
||||||
|
|
@ -309,7 +309,7 @@ github.com/imdario/mergo
|
||||||
github.com/inconshreveable/mousetrap
|
github.com/inconshreveable/mousetrap
|
||||||
# github.com/ishidawataru/sctp v0.0.0-20210226210310-f2269e66cdee
|
# github.com/ishidawataru/sctp v0.0.0-20210226210310-f2269e66cdee
|
||||||
github.com/ishidawataru/sctp
|
github.com/ishidawataru/sctp
|
||||||
# github.com/jinzhu/copier v0.3.4
|
# github.com/jinzhu/copier v0.3.5
|
||||||
github.com/jinzhu/copier
|
github.com/jinzhu/copier
|
||||||
# github.com/json-iterator/go v1.1.12
|
# github.com/json-iterator/go v1.1.12
|
||||||
github.com/json-iterator/go
|
github.com/json-iterator/go
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue