Merge pull request #10997 from dmcgowan/backport-2.0-typeurl
[release/2.0] bump github.com/containerd/typeurl/v2 from 2.2.2 to 2.2.3
This commit is contained in:
commit
abd8c4c39f
2
go.mod
2
go.mod
@ -27,7 +27,7 @@ require (
|
||||
github.com/containerd/platforms v1.0.0-rc.0
|
||||
github.com/containerd/plugin v1.0.0
|
||||
github.com/containerd/ttrpc v1.2.6
|
||||
github.com/containerd/typeurl/v2 v2.2.2
|
||||
github.com/containerd/typeurl/v2 v2.2.3
|
||||
github.com/containerd/zfs/v2 v2.0.0-rc.0
|
||||
github.com/containernetworking/cni v1.2.3
|
||||
github.com/containernetworking/plugins v1.5.1
|
||||
|
4
go.sum
4
go.sum
@ -698,8 +698,8 @@ github.com/containerd/plugin v1.0.0/go.mod h1:hQfJe5nmWfImiqT1q8Si3jLv3ynMUIBB47
|
||||
github.com/containerd/ttrpc v1.2.2/go.mod h1:sIT6l32Ph/H9cvnJsfXM5drIVzTr5A2flTf1G5tYZak=
|
||||
github.com/containerd/ttrpc v1.2.6 h1:zG+Kn5EZ6MUYCS1t2Hmt2J4tMVaLSFEJVOraDQwNPC4=
|
||||
github.com/containerd/ttrpc v1.2.6/go.mod h1:YCXHsb32f+Sq5/72xHubdiJRQY9inL4a4ZQrAbN1q9o=
|
||||
github.com/containerd/typeurl/v2 v2.2.2 h1:3jN/k2ysKuPCsln5Qv8bzR9cxal8XjkxPogJfSNO31k=
|
||||
github.com/containerd/typeurl/v2 v2.2.2/go.mod h1:95ljDnPfD3bAbDJRugOiShd/DlAAsxGtUBhJxIn7SCk=
|
||||
github.com/containerd/typeurl/v2 v2.2.3 h1:yNA/94zxWdvYACdYO8zofhrTVuQY73fFU1y++dYSw40=
|
||||
github.com/containerd/typeurl/v2 v2.2.3/go.mod h1:95ljDnPfD3bAbDJRugOiShd/DlAAsxGtUBhJxIn7SCk=
|
||||
github.com/containerd/zfs/v2 v2.0.0-rc.0 h1:0dRlgpoaepW7HuovtcvYQMF7NlpceQVdn7+3Udeth4M=
|
||||
github.com/containerd/zfs/v2 v2.0.0-rc.0/go.mod h1:g36g/XCEGDRxUXIFdM3oWAEvmTvhfz/eKWElqg4Secw=
|
||||
github.com/containernetworking/cni v1.2.3 h1:hhOcjNVUQTnzdRJ6alC5XF+wd9mfGIUaj8FuJbEslXM=
|
||||
|
18
vendor/github.com/containerd/typeurl/v2/types.go
generated
vendored
18
vendor/github.com/containerd/typeurl/v2/types.go
generated
vendored
@ -39,7 +39,7 @@ type handler interface {
|
||||
Marshaller(interface{}) func() ([]byte, error)
|
||||
Unmarshaller(interface{}) func([]byte) error
|
||||
TypeURL(interface{}) string
|
||||
GetType(url string) reflect.Type
|
||||
GetType(url string) (reflect.Type, bool)
|
||||
}
|
||||
|
||||
// Definitions of common error types used throughout typeurl.
|
||||
@ -240,7 +240,7 @@ func MarshalAnyToProto(from interface{}) (*anypb.Any, error) {
|
||||
}
|
||||
|
||||
func unmarshal(typeURL string, value []byte, v interface{}) (interface{}, error) {
|
||||
t, err := getTypeByUrl(typeURL)
|
||||
t, isProto, err := getTypeByUrl(typeURL)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -258,6 +258,7 @@ func unmarshal(typeURL string, value []byte, v interface{}) (interface{}, error)
|
||||
}
|
||||
}
|
||||
|
||||
if isProto {
|
||||
pm, ok := v.(proto.Message)
|
||||
if ok {
|
||||
return v, proto.Unmarshal(value, pm)
|
||||
@ -268,17 +269,18 @@ func unmarshal(typeURL string, value []byte, v interface{}) (interface{}, error)
|
||||
return v, unmarshal(value)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// fallback to json unmarshaller
|
||||
return v, json.Unmarshal(value, v)
|
||||
}
|
||||
|
||||
func getTypeByUrl(url string) (reflect.Type, error) {
|
||||
func getTypeByUrl(url string) (_ reflect.Type, isProto bool, _ error) {
|
||||
mu.RLock()
|
||||
for t, u := range registry {
|
||||
if u == url {
|
||||
mu.RUnlock()
|
||||
return t, nil
|
||||
return t, false, nil
|
||||
}
|
||||
}
|
||||
mu.RUnlock()
|
||||
@ -286,15 +288,15 @@ func getTypeByUrl(url string) (reflect.Type, error) {
|
||||
if err != nil {
|
||||
if errors.Is(err, protoregistry.NotFound) {
|
||||
for _, h := range handlers {
|
||||
if t := h.GetType(url); t != nil {
|
||||
return t, nil
|
||||
if t, isProto := h.GetType(url); t != nil {
|
||||
return t, isProto, nil
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil, fmt.Errorf("type with url %s: %w", url, ErrNotFound)
|
||||
return nil, false, fmt.Errorf("type with url %s: %w", url, ErrNotFound)
|
||||
}
|
||||
empty := mt.New().Interface()
|
||||
return reflect.TypeOf(empty).Elem(), nil
|
||||
return reflect.TypeOf(empty).Elem(), true, nil
|
||||
}
|
||||
|
||||
func tryDereference(v interface{}) reflect.Type {
|
||||
|
6
vendor/github.com/containerd/typeurl/v2/types_gogo.go
generated
vendored
6
vendor/github.com/containerd/typeurl/v2/types_gogo.go
generated
vendored
@ -59,10 +59,10 @@ func (gogoHandler) TypeURL(v interface{}) string {
|
||||
return gogoproto.MessageName(pm)
|
||||
}
|
||||
|
||||
func (gogoHandler) GetType(url string) reflect.Type {
|
||||
func (gogoHandler) GetType(url string) (reflect.Type, bool) {
|
||||
t := gogoproto.MessageType(url)
|
||||
if t == nil {
|
||||
return nil
|
||||
return nil, false
|
||||
}
|
||||
return t.Elem()
|
||||
return t.Elem(), true
|
||||
}
|
||||
|
2
vendor/modules.txt
vendored
2
vendor/modules.txt
vendored
@ -194,7 +194,7 @@ github.com/containerd/plugin/registry
|
||||
# github.com/containerd/ttrpc v1.2.6
|
||||
## explicit; go 1.19
|
||||
github.com/containerd/ttrpc
|
||||
# github.com/containerd/typeurl/v2 v2.2.2
|
||||
# github.com/containerd/typeurl/v2 v2.2.3
|
||||
## explicit; go 1.21
|
||||
github.com/containerd/typeurl/v2
|
||||
# github.com/containerd/zfs/v2 v2.0.0-rc.0
|
||||
|
Loading…
Reference in New Issue
Block a user