Skip to content

Commit 6419d94

Browse files
committed
Remove gogo protobuf support
Signed-off-by: Derek McGowan <[email protected]>
1 parent 30fd8da commit 6419d94

File tree

6 files changed

+15
-151
lines changed

6 files changed

+15
-151
lines changed

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ As a containerd sub-project, you will find the:
1919

2020
information in our [`containerd/project`](https://github.com/containerd/project) repository.
2121

22-
## Optional
22+
## Gogo Protobuf Support Deprecation
2323

24-
By default, support for gogoproto is available along side the standard Google
25-
protobuf types.
26-
You can choose to leave gogo support out by using the `!no_gogo` build tag.
24+
Support for gogoprotobuf was removed in v2.3.0. The upstream package has been deprecated since 2022 and users of
25+
typeurl should not rely on Gogo Protobuf support anymore. Users which are still transitioning away from it may
26+
continue to use the v2.2 release until that transition is complete. Since v2.2.1, gogo proto support can be
27+
explicitly removed using the `!no_gogo` build tag.

go.mod

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ module github.com/containerd/typeurl/v2
22

33
go 1.21
44

5-
require (
6-
github.com/gogo/protobuf v1.3.2
7-
google.golang.org/protobuf v1.33.0
8-
)
5+
require google.golang.org/protobuf v1.33.0
6+
7+
require golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect

go.sum

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,5 @@
1-
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
2-
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
31
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
42
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
5-
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
6-
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
7-
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
8-
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
9-
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
10-
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
11-
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
12-
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
13-
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
14-
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
15-
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
16-
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
17-
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
18-
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
19-
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
20-
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
21-
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
22-
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
23-
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
24-
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
25-
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
26-
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
27-
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
28-
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
29-
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
30-
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
31-
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
32-
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
333
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
344
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
355
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=

types.go

Lines changed: 6 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,8 @@ import (
3232
var (
3333
mu sync.RWMutex
3434
registry = make(map[reflect.Type]string)
35-
handlers []handler
3635
)
3736

38-
type handler interface {
39-
Marshaller(interface{}) func() ([]byte, error)
40-
Unmarshaller(interface{}) func([]byte) error
41-
TypeURL(interface{}) string
42-
GetType(url string) reflect.Type
43-
}
44-
4537
// Definitions of common error types used throughout typeurl.
4638
//
4739
// These error types are used with errors.Wrap and errors.Wrapf to add context
@@ -120,11 +112,6 @@ func TypeURL(v interface{}) (string, error) {
120112
case proto.Message:
121113
return string(t.ProtoReflect().Descriptor().FullName()), nil
122114
default:
123-
for _, h := range handlers {
124-
if u := h.TypeURL(v); u != "" {
125-
return u, nil
126-
}
127-
}
128115
return "", fmt.Errorf("type %s: %w", reflect.TypeOf(v), ErrNotFound)
129116
}
130117
}
@@ -160,18 +147,7 @@ func MarshalAny(v interface{}) (Any, error) {
160147
return proto.Marshal(t)
161148
}
162149
default:
163-
for _, h := range handlers {
164-
if m := h.Marshaller(v); m != nil {
165-
marshal = func(v interface{}) ([]byte, error) {
166-
return m()
167-
}
168-
break
169-
}
170-
}
171-
172-
if marshal == nil {
173-
marshal = json.Marshal
174-
}
150+
marshal = json.Marshal
175151
}
176152

177153
url, err := TypeURL(v)
@@ -260,17 +236,12 @@ func unmarshal(typeURL string, value []byte, v interface{}) (interface{}, error)
260236

261237
pm, ok := v.(proto.Message)
262238
if ok {
263-
return v, proto.Unmarshal(value, pm)
264-
}
265-
266-
for _, h := range handlers {
267-
if unmarshal := h.Unmarshaller(v); unmarshal != nil {
268-
return v, unmarshal(value)
269-
}
239+
err = proto.Unmarshal(value, pm)
240+
} else {
241+
err = json.Unmarshal(value, v)
270242
}
271243

272-
// fallback to json unmarshaller
273-
return v, json.Unmarshal(value, v)
244+
return v, err
274245
}
275246

276247
func getTypeByUrl(url string) (reflect.Type, error) {
@@ -284,16 +255,7 @@ func getTypeByUrl(url string) (reflect.Type, error) {
284255
mu.RUnlock()
285256
mt, err := protoregistry.GlobalTypes.FindMessageByURL(url)
286257
if err != nil {
287-
e := protoregistry.NotFound
288-
if !errors.Is(err, e) {
289-
return nil, fmt.Errorf("type with url %s: %w", url, ErrNotFound)
290-
}
291-
292-
for _, h := range handlers {
293-
if t := h.GetType(url); t != nil {
294-
return t, nil
295-
}
296-
}
258+
return nil, fmt.Errorf("type with url %s: %w", url, ErrNotFound)
297259
}
298260
empty := mt.New().Interface()
299261
return reflect.TypeOf(empty).Elem(), nil

types_gogo.go

Lines changed: 0 additions & 68 deletions
This file was deleted.

types_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222
"testing"
2323
"time"
2424

25-
"github.com/gogo/protobuf/proto"
25+
"google.golang.org/protobuf/proto"
2626
"google.golang.org/protobuf/types/known/anypb"
2727
"google.golang.org/protobuf/types/known/timestamppb"
2828
)

0 commit comments

Comments
 (0)