Remove gogo/protobuf and adjust types
This commit migrates containerd/protobuf from github.com/gogo/protobuf to google.golang.org/protobuf and adjust types. Proto-generated structs cannot be passed as values. Fixes #6564. Signed-off-by: Kazuyoshi Kato <katokazu@amazon.com>
This commit is contained in:
		| @@ -29,8 +29,9 @@ import ( | ||||
| 	"github.com/containerd/containerd/plugin" | ||||
| 	ptypes "github.com/containerd/containerd/protobuf/types" | ||||
| 	"github.com/containerd/containerd/services" | ||||
| 	"github.com/gogo/googleapis/google/rpc" | ||||
| 	"github.com/google/uuid" | ||||
| 	"google.golang.org/genproto/googleapis/rpc/code" | ||||
| 	rpc "google.golang.org/genproto/googleapis/rpc/status" | ||||
| 	"google.golang.org/grpc" | ||||
| 	"google.golang.org/grpc/status" | ||||
| ) | ||||
| @@ -55,7 +56,7 @@ type Local struct { | ||||
| 	mu          sync.Mutex | ||||
| 	root        string | ||||
| 	plugins     *plugin.Set | ||||
| 	pluginCache []api.Plugin | ||||
| 	pluginCache []*api.Plugin | ||||
| } | ||||
|  | ||||
| var _ = (api.IntrospectionClient)(&Local{}) | ||||
| @@ -79,7 +80,7 @@ func (l *Local) Plugins(ctx context.Context, req *api.PluginsRequest, _ ...grpc. | ||||
| 	for _, p := range allPlugins { | ||||
| 		p := p | ||||
| 		if filter.Match(adaptPlugin(p)) { | ||||
| 			plugins = append(plugins, &p) | ||||
| 			plugins = append(plugins, p) | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| @@ -88,7 +89,7 @@ func (l *Local) Plugins(ctx context.Context, req *api.PluginsRequest, _ ...grpc. | ||||
| 	}, nil | ||||
| } | ||||
|  | ||||
| func (l *Local) getPlugins() []api.Plugin { | ||||
| func (l *Local) getPlugins() []*api.Plugin { | ||||
| 	l.mu.Lock() | ||||
| 	defer l.mu.Unlock() | ||||
| 	plugins := l.plugins.GetAll() | ||||
| @@ -148,7 +149,7 @@ func (l *Local) uuidPath() string { | ||||
| } | ||||
|  | ||||
| func adaptPlugin(o interface{}) filters.Adaptor { | ||||
| 	obj := o.(api.Plugin) | ||||
| 	obj := o.(*api.Plugin) | ||||
| 	return filters.AdapterFunc(func(fieldpath []string) (string, bool) { | ||||
| 		if len(fieldpath) == 0 { | ||||
| 			return "", false | ||||
| @@ -174,8 +175,8 @@ func adaptPlugin(o interface{}) filters.Adaptor { | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| func pluginsToPB(plugins []*plugin.Plugin) []api.Plugin { | ||||
| 	var pluginsPB []api.Plugin | ||||
| func pluginsToPB(plugins []*plugin.Plugin) []*api.Plugin { | ||||
| 	var pluginsPB []*api.Plugin | ||||
| 	for _, p := range plugins { | ||||
| 		var platforms []*types.Platform | ||||
| 		for _, p := range p.Meta.Platforms { | ||||
| @@ -209,13 +210,13 @@ func pluginsToPB(plugins []*plugin.Plugin) []api.Plugin { | ||||
| 				} | ||||
| 			} else { | ||||
| 				initErr = &rpc.Status{ | ||||
| 					Code:    int32(rpc.UNKNOWN), | ||||
| 					Code:    int32(code.Code_UNKNOWN), | ||||
| 					Message: err.Error(), | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		pluginsPB = append(pluginsPB, api.Plugin{ | ||||
| 		pluginsPB = append(pluginsPB, &api.Plugin{ | ||||
| 			Type:         p.Registration.Type.String(), | ||||
| 			ID:           p.Registration.ID, | ||||
| 			Requires:     requires, | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Kazuyoshi Kato
					Kazuyoshi Kato