Remove all gogoproto extensions

This commit removes the following gogoproto extensions;

- gogoproto.nullable
- gogoproto.customename
- gogoproto.unmarshaller_all
- gogoproto.stringer_all
- gogoproto.sizer_all
- gogoproto.marshaler_all
- gogoproto.goproto_unregonized_all
- gogoproto.goproto_stringer_all
- gogoproto.goproto_getters_all

None of them are supported by Google's toolchain (see #6564).

Signed-off-by: Kazuyoshi Kato <katokazu@amazon.com>
This commit is contained in:
Kazuyoshi Kato
2022-04-20 03:30:52 +00:00
parent 9b33526ef6
commit 237ef0de9b
48 changed files with 1301 additions and 1246 deletions

View File

@@ -24,8 +24,8 @@ import (
"github.com/containerd/typeurl"
)
func containersToProto(containers []containers.Container) []api.Container {
var containerspb []api.Container
func containersToProto(containers []containers.Container) []*api.Container {
var containerspb []*api.Container
for _, image := range containers {
image := image
@@ -35,12 +35,12 @@ func containersToProto(containers []containers.Container) []api.Container {
return containerspb
}
func containerToProto(container *containers.Container) api.Container {
extensions := make(map[string]types.Any)
func containerToProto(container *containers.Container) *api.Container {
extensions := make(map[string]*types.Any)
for k, v := range container.Extensions {
extensions[k] = *protobuf.FromAny(v)
extensions[k] = protobuf.FromAny(v)
}
return api.Container{
return &api.Container{
ID: container.ID,
Labels: container.Labels,
Image: container.Image,
@@ -69,7 +69,7 @@ func containerFromProto(containerpb *api.Container) containers.Container {
extensions := make(map[string]typeurl.Any)
for k, v := range containerpb.Extensions {
v := v
extensions[k] = &v
extensions[k] = v
}
return containers.Container{
ID: containerpb.ID,

View File

@@ -117,7 +117,7 @@ func (l *local) Create(ctx context.Context, req *api.CreateContainerRequest, _ .
var resp api.CreateContainerResponse
if err := l.withStoreUpdate(ctx, func(ctx context.Context) error {
container := containerFromProto(&req.Container)
container := containerFromProto(req.Container)
created, err := l.Store.Create(ctx, container)
if err != nil {
@@ -150,7 +150,7 @@ func (l *local) Update(ctx context.Context, req *api.UpdateContainerRequest, _ .
}
var (
resp api.UpdateContainerResponse
container = containerFromProto(&req.Container)
container = containerFromProto(req.Container)
)
if err := l.withStoreUpdate(ctx, func(ctx context.Context) error {
@@ -214,7 +214,7 @@ func (l *local) withStoreUpdate(ctx context.Context, fn func(ctx context.Context
type localStream struct {
ctx context.Context
containers []api.Container
containers []*api.Container
i int
}
@@ -225,7 +225,7 @@ func (s *localStream) Recv() (*api.ListContainerMessage, error) {
c := s.containers[s.i]
s.i++
return &api.ListContainerMessage{
Container: &c,
Container: c,
}, nil
}

View File

@@ -91,8 +91,8 @@ func (s *service) Update(ctx context.Context, req *api.UpdateRequest) (*api.Upda
func (s *service) List(req *api.ListContentRequest, session api.Content_ListServer) error {
var (
buffer []api.Info
sendBlock = func(block []api.Info) error {
buffer []*api.Info
sendBlock = func(block []*api.Info) error {
// send last block
return session.Send(&api.ListContentResponse{
Info: block,
@@ -101,7 +101,7 @@ func (s *service) List(req *api.ListContentRequest, session api.Content_ListServ
)
if err := s.store.Walk(session.Context(), func(info content.Info) error {
buffer = append(buffer, api.Info{
buffer = append(buffer, &api.Info{
Digest: info.Digest.String(),
Size_: info.Size,
CreatedAt: protobuf.ToTimestamp(info.CreatedAt),
@@ -240,7 +240,7 @@ func (s *service) ListStatuses(ctx context.Context, req *api.ListStatusesRequest
var resp api.ListStatusesResponse
for _, status := range statuses {
resp.Statuses = append(resp.Statuses, api.Status{
resp.Statuses = append(resp.Statuses, &api.Status{
StartedAt: protobuf.ToTimestamp(status.StartedAt),
UpdatedAt: protobuf.ToTimestamp(status.UpdatedAt),
Ref: status.Ref,
@@ -452,8 +452,8 @@ func (s *service) Abort(ctx context.Context, req *api.AbortRequest) (*ptypes.Emp
return &ptypes.Empty{}, nil
}
func infoToGRPC(info content.Info) api.Info {
return api.Info{
func infoToGRPC(info content.Info) *api.Info {
return &api.Info{
Digest: info.Digest.String(),
Size_: info.Size,
CreatedAt: protobuf.ToTimestamp(info.CreatedAt),
@@ -462,7 +462,7 @@ func infoToGRPC(info content.Info) api.Info {
}
}
func infoFromGRPC(info api.Info) content.Info {
func infoFromGRPC(info *api.Info) content.Info {
return content.Info{
Digest: digest.Digest(info.Digest),
Size: info.Size_,

View File

@@ -25,8 +25,8 @@ import (
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
)
func imagesToProto(images []images.Image) []imagesapi.Image {
var imagespb []imagesapi.Image
func imagesToProto(images []images.Image) []*imagesapi.Image {
var imagespb []*imagesapi.Image
for _, image := range images {
image := image
@@ -36,8 +36,8 @@ func imagesToProto(images []images.Image) []imagesapi.Image {
return imagespb
}
func imageToProto(image *images.Image) imagesapi.Image {
return imagesapi.Image{
func imageToProto(image *images.Image) *imagesapi.Image {
return &imagesapi.Image{
Name: image.Name,
Labels: image.Labels,
Target: descToProto(&image.Target),
@@ -50,7 +50,7 @@ func imageFromProto(imagepb *imagesapi.Image) images.Image {
return images.Image{
Name: imagepb.Name,
Labels: imagepb.Labels,
Target: descFromProto(&imagepb.Target),
Target: descFromProto(imagepb.Target),
CreatedAt: protobuf.FromTimestamp(imagepb.CreatedAt),
UpdatedAt: protobuf.FromTimestamp(imagepb.UpdatedAt),
}
@@ -65,8 +65,8 @@ func descFromProto(desc *types.Descriptor) ocispec.Descriptor {
}
}
func descToProto(desc *ocispec.Descriptor) types.Descriptor {
return types.Descriptor{
func descToProto(desc *ocispec.Descriptor) *types.Descriptor {
return &types.Descriptor{
MediaType: desc.MediaType,
Size_: desc.Size,
Digest: desc.Digest.String(),

View File

@@ -82,7 +82,7 @@ func (l *local) Get(ctx context.Context, req *imagesapi.GetImageRequest, _ ...gr
imagepb := imageToProto(&image)
return &imagesapi.GetImageResponse{
Image: &imagepb,
Image: imagepb,
}, nil
}
@@ -104,7 +104,7 @@ func (l *local) Create(ctx context.Context, req *imagesapi.CreateImageRequest, _
}
var (
image = imageFromProto(&req.Image)
image = imageFromProto(req.Image)
resp imagesapi.CreateImageResponse
)
created, err := l.store.Create(ctx, image)
@@ -131,7 +131,7 @@ func (l *local) Update(ctx context.Context, req *imagesapi.UpdateImageRequest, _
}
var (
image = imageFromProto(&req.Image)
image = imageFromProto(req.Image)
resp imagesapi.UpdateImageResponse
fieldpaths []string
)

View File

@@ -74,14 +74,13 @@ func (l *Local) Plugins(ctx context.Context, req *api.PluginsRequest, _ ...grpc.
return nil, errdefs.ToGRPCf(errdefs.ErrInvalidArgument, err.Error())
}
var plugins []api.Plugin
var plugins []*api.Plugin
allPlugins := l.getPlugins()
for _, p := range allPlugins {
if !filter.Match(adaptPlugin(p)) {
continue
p := p
if filter.Match(adaptPlugin(p)) {
plugins = append(plugins, &p)
}
plugins = append(plugins, p)
}
return &api.PluginsResponse{
@@ -178,9 +177,9 @@ func adaptPlugin(o interface{}) filters.Adaptor {
func pluginsToPB(plugins []*plugin.Plugin) []api.Plugin {
var pluginsPB []api.Plugin
for _, p := range plugins {
var platforms []types.Platform
var platforms []*types.Platform
for _, p := range p.Meta.Platforms {
platforms = append(platforms, types.Platform{
platforms = append(platforms, &types.Platform{
OS: p.OS,
Architecture: p.Architecture,
Variant: p.Variant,

View File

@@ -141,9 +141,9 @@ func (s *service) ListResources(ctx context.Context, r *api.ListResourcesRequest
return nil, errdefs.ToGRPC(err)
}
apiResources := make([]api.Resource, 0, len(rs))
apiResources := make([]*api.Resource, 0, len(rs))
for _, i := range rs {
apiResources = append(apiResources, api.Resource{
apiResources = append(apiResources, &api.Resource{
ID: i.ID,
Type: i.Type,
})

View File

@@ -79,7 +79,7 @@ func (l *local) Get(ctx context.Context, req *api.GetNamespaceRequest, _ ...grpc
return errdefs.ToGRPC(err)
}
resp.Namespace = api.Namespace{
resp.Namespace = &api.Namespace{
Name: req.Name,
Labels: labels,
}
@@ -105,7 +105,7 @@ func (l *local) List(ctx context.Context, req *api.ListNamespacesRequest, _ ...g
return errdefs.ToGRPC(err)
}
resp.Namespaces = append(resp.Namespaces, api.Namespace{
resp.Namespaces = append(resp.Namespaces, &api.Namespace{
Name: namespace,
Labels: labels,
})

View File

@@ -61,7 +61,7 @@ type sandboxLocal struct {
var _ = (api.StoreClient)(&sandboxLocal{})
func (s *sandboxLocal) Create(ctx context.Context, in *api.StoreCreateRequest, _ ...grpc.CallOption) (*api.StoreCreateResponse, error) {
sb, err := s.store.Create(ctx, sandbox.FromProto(&in.Sandbox))
sb, err := s.store.Create(ctx, sandbox.FromProto(in.Sandbox))
if err != nil {
return nil, errdefs.ToGRPC(err)
}
@@ -70,7 +70,7 @@ func (s *sandboxLocal) Create(ctx context.Context, in *api.StoreCreateRequest, _
}
func (s *sandboxLocal) Update(ctx context.Context, in *api.StoreUpdateRequest, _ ...grpc.CallOption) (*api.StoreUpdateResponse, error) {
sb, err := s.store.Update(ctx, sandbox.FromProto(&in.Sandbox), in.Fields...)
sb, err := s.store.Update(ctx, sandbox.FromProto(in.Sandbox), in.Fields...)
if err != nil {
return nil, errdefs.ToGRPC(err)
}
@@ -85,7 +85,7 @@ func (s *sandboxLocal) Get(ctx context.Context, in *api.StoreGetRequest, _ ...gr
}
desc := sandbox.ToProto(&resp)
return &api.StoreGetResponse{Sandbox: &desc}, nil
return &api.StoreGetResponse{Sandbox: desc}, nil
}
func (s *sandboxLocal) List(ctx context.Context, in *api.StoreListRequest, _ ...grpc.CallOption) (*api.StoreListResponse, error) {
@@ -94,7 +94,7 @@ func (s *sandboxLocal) List(ctx context.Context, in *api.StoreListRequest, _ ...
return nil, errdefs.ToGRPC(err)
}
list := make([]types.Sandbox, len(resp))
list := make([]*types.Sandbox, len(resp))
for i := range resp {
list[i] = sandbox.ToProto(&resp[i])
}

View File

@@ -209,8 +209,8 @@ func (s *service) List(sr *snapshotsapi.ListSnapshotsRequest, ss snapshotsapi.Sn
}
var (
buffer []snapshotsapi.Info
sendBlock = func(block []snapshotsapi.Info) error {
buffer []*snapshotsapi.Info
sendBlock = func(block []*snapshotsapi.Info) error {
return ss.Send(&snapshotsapi.ListSnapshotsResponse{
Info: block,
})
@@ -285,8 +285,8 @@ func fromKind(kind snapshots.Kind) snapshotsapi.Kind {
return snapshotsapi.Kind_COMMITTED
}
func fromInfo(info snapshots.Info) snapshotsapi.Info {
return snapshotsapi.Info{
func fromInfo(info snapshots.Info) *snapshotsapi.Info {
return &snapshotsapi.Info{
Name: info.Name,
Parent: info.Parent,
Kind: fromKind(info.Kind),
@@ -315,7 +315,7 @@ func fromMounts(mounts []mount.Mount) []*types.Mount {
return out
}
func toInfo(info snapshotsapi.Info) snapshots.Info {
func toInfo(info *snapshotsapi.Info) snapshots.Info {
return snapshots.Info{
Name: info.Name,
Parent: info.Parent,