Skip to content

Commit

Permalink
Consolidate gogo/protobuf dependencies under our own protobuf package
Browse files Browse the repository at this point in the history
This would make gogo/protobuf migration easier.

Signed-off-by: Kazuyoshi Kato <[email protected]>
  • Loading branch information
kzys committed Apr 19, 2022
1 parent 184883b commit 88c0c72
Show file tree
Hide file tree
Showing 69 changed files with 133 additions and 77 deletions.
2 changes: 1 addition & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ import (
"github.com/containerd/containerd/pkg/dialer"
"github.com/containerd/containerd/platforms"
"github.com/containerd/containerd/plugin"
ptypes "github.com/containerd/containerd/protobuf/types"
"github.com/containerd/containerd/remotes"
"github.com/containerd/containerd/remotes/docker"
"github.com/containerd/containerd/sandbox"
"github.com/containerd/containerd/services/introspection"
"github.com/containerd/containerd/snapshots"
snproxy "github.com/containerd/containerd/snapshots/proxy"
"github.com/containerd/typeurl"
ptypes "github.com/gogo/protobuf/types"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/opencontainers/runtime-spec/specs-go"
"golang.org/x/sync/semaphore"
Expand Down
2 changes: 1 addition & 1 deletion cmd/containerd-shim/main_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ import (
"github.com/containerd/containerd/namespaces"
"github.com/containerd/containerd/pkg/process"
"github.com/containerd/containerd/protobuf"
ptypes "github.com/containerd/containerd/protobuf/types"
shimlog "github.com/containerd/containerd/runtime/v1"
"github.com/containerd/containerd/runtime/v1/shim"
shimapi "github.com/containerd/containerd/runtime/v1/shim/v1"
"github.com/containerd/containerd/sys/reaper"
"github.com/containerd/containerd/version"
"github.com/containerd/ttrpc"
ptypes "github.com/gogo/protobuf/types"
"github.com/sirupsen/logrus"
exec "golang.org/x/sys/execabs"
"golang.org/x/sys/unix"
Expand Down
2 changes: 1 addition & 1 deletion cmd/containerd/command/publish.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
"github.com/containerd/containerd/errdefs"
"github.com/containerd/containerd/namespaces"
"github.com/containerd/containerd/pkg/dialer"
"github.com/gogo/protobuf/types"
"github.com/containerd/containerd/protobuf/types"
"github.com/urfave/cli"
"google.golang.org/grpc"
"google.golang.org/grpc/backoff"
Expand Down
2 changes: 1 addition & 1 deletion cmd/ctr/commands/shim/shim.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ import (
"github.com/containerd/console"
"github.com/containerd/containerd/cmd/ctr/commands"
"github.com/containerd/containerd/namespaces"
ptypes "github.com/containerd/containerd/protobuf/types"
"github.com/containerd/containerd/runtime/v2/shim"
"github.com/containerd/containerd/runtime/v2/task"
"github.com/containerd/ttrpc"
"github.com/containerd/typeurl"
ptypes "github.com/gogo/protobuf/types"
"github.com/opencontainers/runtime-spec/specs-go"
"github.com/sirupsen/logrus"
"github.com/urfave/cli"
Expand Down
4 changes: 2 additions & 2 deletions container_restore_opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import (
"github.com/containerd/containerd/containers"
"github.com/containerd/containerd/content"
"github.com/containerd/containerd/images"
"github.com/gogo/protobuf/proto"
ptypes "github.com/gogo/protobuf/types"
"github.com/containerd/containerd/protobuf/proto"
ptypes "github.com/containerd/containerd/protobuf/types"
"github.com/opencontainers/image-spec/identity"
imagespec "github.com/opencontainers/image-spec/specs-go/v1"
)
Expand Down
2 changes: 1 addition & 1 deletion containerstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import (
"github.com/containerd/containerd/containers"
"github.com/containerd/containerd/errdefs"
"github.com/containerd/containerd/protobuf"
ptypes "github.com/containerd/containerd/protobuf/types"
"github.com/containerd/typeurl"
ptypes "github.com/gogo/protobuf/types"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
Expand Down
2 changes: 1 addition & 1 deletion content/proxy/content_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"github.com/containerd/containerd/content"
"github.com/containerd/containerd/errdefs"
"github.com/containerd/containerd/protobuf"
protobuftypes "github.com/gogo/protobuf/types"
protobuftypes "github.com/containerd/containerd/protobuf/types"
digest "github.com/opencontainers/go-digest"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
)
Expand Down
2 changes: 1 addition & 1 deletion contrib/snapshotservice/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import (
"github.com/containerd/containerd/errdefs"
"github.com/containerd/containerd/mount"
"github.com/containerd/containerd/protobuf"
ptypes "github.com/containerd/containerd/protobuf/types"
"github.com/containerd/containerd/snapshots"
ptypes "github.com/gogo/protobuf/types"
)

var empty = &ptypes.Empty{}
Expand Down
2 changes: 1 addition & 1 deletion diff/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"io"

"github.com/containerd/containerd/mount"
"github.com/gogo/protobuf/types"
"github.com/containerd/containerd/protobuf/types"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
)

Expand Down
2 changes: 1 addition & 1 deletion diff/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (

"github.com/containerd/containerd/archive/compression"
"github.com/containerd/containerd/images"
"github.com/gogo/protobuf/types"
"github.com/containerd/containerd/protobuf/types"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
)

Expand Down
4 changes: 2 additions & 2 deletions diff/stream_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ import (
"os"
"sync"

"github.com/gogo/protobuf/proto"
"github.com/gogo/protobuf/types"
"github.com/containerd/containerd/protobuf/proto"
"github.com/containerd/containerd/protobuf/types"
exec "golang.org/x/sys/execabs"
)

Expand Down
4 changes: 2 additions & 2 deletions diff/stream_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ import (
"sync"

winio "github.com/Microsoft/go-winio"
"github.com/gogo/protobuf/proto"
"github.com/gogo/protobuf/types"
"github.com/containerd/containerd/protobuf/proto"
"github.com/containerd/containerd/protobuf/types"
"github.com/sirupsen/logrus"
exec "golang.org/x/sys/execabs"
)
Expand Down
2 changes: 1 addition & 1 deletion image_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"github.com/containerd/containerd/errdefs"
"github.com/containerd/containerd/images"
"github.com/containerd/containerd/protobuf"
ptypes "github.com/gogo/protobuf/types"
ptypes "github.com/containerd/containerd/protobuf/types"
"github.com/opencontainers/go-digest"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
)
Expand Down
2 changes: 1 addition & 1 deletion integration/client/client_ttrpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ import (
"github.com/containerd/containerd/namespaces"
"github.com/containerd/containerd/pkg/ttrpcutil"
"github.com/containerd/containerd/protobuf"
"github.com/containerd/containerd/protobuf/types"
"github.com/containerd/ttrpc"
"github.com/gogo/protobuf/types"
"github.com/stretchr/testify/assert"
)

Expand Down
2 changes: 1 addition & 1 deletion integration/client/container_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ import (
"github.com/containerd/containerd/oci"
"github.com/containerd/containerd/platforms"
"github.com/containerd/containerd/plugin"
gogotypes "github.com/containerd/containerd/protobuf/types"
_ "github.com/containerd/containerd/runtime"
"github.com/containerd/containerd/runtime/v2/runc/options"
"github.com/containerd/go-runc"
"github.com/containerd/typeurl"
gogotypes "github.com/gogo/protobuf/types"
specs "github.com/opencontainers/runtime-spec/specs-go"
exec "golang.org/x/sys/execabs"
)
Expand Down
2 changes: 1 addition & 1 deletion integration/client/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require (
github.com/containerd/go-runc v1.0.0
github.com/containerd/ttrpc v1.1.0
github.com/containerd/typeurl v1.0.3-0.20220324183432-6193a0e03259
github.com/gogo/protobuf v1.3.2
github.com/gogo/protobuf v1.3.2 // indirect
github.com/opencontainers/go-digest v1.0.0
github.com/opencontainers/image-spec v1.0.3-0.20220303224323-02efb9a75ee1
github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417
Expand Down
4 changes: 2 additions & 2 deletions metadata/boltutil/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ import (
"time"

"github.com/containerd/containerd/protobuf"
"github.com/containerd/containerd/protobuf/proto"
"github.com/containerd/containerd/protobuf/types"
"github.com/containerd/typeurl"
"github.com/gogo/protobuf/proto"
"github.com/gogo/protobuf/types"
bolt "go.etcd.io/bbolt"
)

Expand Down
4 changes: 2 additions & 2 deletions metadata/containers.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ import (
"github.com/containerd/containerd/labels"
"github.com/containerd/containerd/metadata/boltutil"
"github.com/containerd/containerd/namespaces"
"github.com/containerd/containerd/protobuf/proto"
"github.com/containerd/containerd/protobuf/types"
"github.com/containerd/typeurl"
"github.com/gogo/protobuf/proto"
"github.com/gogo/protobuf/types"
bolt "go.etcd.io/bbolt"
)

Expand Down
2 changes: 1 addition & 1 deletion metadata/containers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ import (
"github.com/containerd/containerd/log/logtest"
"github.com/containerd/containerd/namespaces"
"github.com/containerd/containerd/protobuf"
"github.com/containerd/containerd/protobuf/types"
"github.com/containerd/typeurl"
"github.com/gogo/protobuf/types"
"github.com/google/go-cmp/cmp"
"github.com/opencontainers/runtime-spec/specs-go"
"github.com/stretchr/testify/assert"
Expand Down
2 changes: 1 addition & 1 deletion metadata/db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ import (
"github.com/containerd/containerd/leases"
"github.com/containerd/containerd/log/logtest"
"github.com/containerd/containerd/namespaces"
"github.com/containerd/containerd/protobuf/types"
"github.com/containerd/containerd/snapshots"
"github.com/containerd/containerd/snapshots/native"
"github.com/gogo/protobuf/types"
digest "github.com/opencontainers/go-digest"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
bolt "go.etcd.io/bbolt"
Expand Down
2 changes: 1 addition & 1 deletion metadata/namespaces_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (

"github.com/containerd/containerd/containers"
"github.com/containerd/containerd/namespaces"
"github.com/gogo/protobuf/types"
"github.com/containerd/containerd/protobuf/types"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.etcd.io/bbolt"
Expand Down
2 changes: 1 addition & 1 deletion metadata/sandbox_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ import (

"github.com/containerd/containerd/errdefs"
"github.com/containerd/containerd/protobuf"
"github.com/containerd/containerd/protobuf/types"
api "github.com/containerd/containerd/sandbox"
"github.com/containerd/typeurl"
"github.com/gogo/protobuf/types"
)

func TestSandboxCreate(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion metrics/cgroups/common/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ package common
import (
"context"

"github.com/gogo/protobuf/types"
"github.com/containerd/containerd/protobuf/types"
)

// Statable type that returns cgroup metrics
Expand Down
2 changes: 1 addition & 1 deletion metrics/cgroups/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ import (
"github.com/containerd/containerd/protobuf"
"github.com/prometheus/client_golang/prometheus"

"github.com/containerd/containerd/protobuf/types"
metrics "github.com/docker/go-metrics"
"github.com/gogo/protobuf/types"
)

// TestRegressionIssue6772 should not have dead-lock when Collect and Add run
Expand Down
2 changes: 1 addition & 1 deletion namespaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
api "github.com/containerd/containerd/api/services/namespaces/v1"
"github.com/containerd/containerd/errdefs"
"github.com/containerd/containerd/namespaces"
"github.com/gogo/protobuf/types"
"github.com/containerd/containerd/protobuf/types"
)

// NewNamespaceStoreFromClient returns a new namespace store
Expand Down
2 changes: 1 addition & 1 deletion pkg/cri/server/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ import (
containerstore "github.com/containerd/containerd/pkg/cri/store/container"
imagestore "github.com/containerd/containerd/pkg/cri/store/image"
"github.com/containerd/containerd/plugin"
"github.com/containerd/containerd/protobuf/types"
"github.com/containerd/containerd/reference/docker"
"github.com/containerd/containerd/runtime/linux/runctypes"
runcoptions "github.com/containerd/containerd/runtime/v2/runc/options"
"github.com/containerd/typeurl"
"github.com/gogo/protobuf/types"

imagedigest "github.com/opencontainers/go-digest"
runtimespec "github.com/opencontainers/runtime-spec/specs-go"
Expand Down
2 changes: 1 addition & 1 deletion pkg/process/deleted_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (

"github.com/containerd/console"
"github.com/containerd/containerd/errdefs"
google_protobuf "github.com/gogo/protobuf/types"
google_protobuf "github.com/containerd/containerd/protobuf/types"
)

type deletedState struct {
Expand Down
2 changes: 1 addition & 1 deletion pkg/process/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ import (
"github.com/containerd/containerd/log"
"github.com/containerd/containerd/mount"
"github.com/containerd/containerd/pkg/stdio"
google_protobuf "github.com/containerd/containerd/protobuf/types"
"github.com/containerd/fifo"
runc "github.com/containerd/go-runc"
google_protobuf "github.com/gogo/protobuf/types"
specs "github.com/opencontainers/runtime-spec/specs-go"
"golang.org/x/sys/unix"
)
Expand Down
2 changes: 1 addition & 1 deletion pkg/process/init_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import (
"errors"
"fmt"

google_protobuf "github.com/containerd/containerd/protobuf/types"
runc "github.com/containerd/go-runc"
google_protobuf "github.com/gogo/protobuf/types"
"github.com/sirupsen/logrus"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/process/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package process

import (
google_protobuf "github.com/gogo/protobuf/types"
google_protobuf "github.com/containerd/containerd/protobuf/types"
)

// Mount holds filesystem mount configuration
Expand Down
6 changes: 3 additions & 3 deletions protobuf/any.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
package protobuf

import (
"github.com/containerd/containerd/protobuf/types"
"github.com/containerd/typeurl"
"github.com/gogo/protobuf/types"
)

// FromAny converts typeurl.Any to github.com/gogo/protobuf/types.Any.
// FromAny converts typeurl.Any to github.com/containerd/containerd/protobuf/types.Any.
func FromAny(from typeurl.Any) *types.Any {
if from == nil {
return nil
Expand All @@ -37,7 +37,7 @@ func FromAny(from typeurl.Any) *types.Any {
}
}

// FromAny converts an arbitrary interface to github.com/gogo/protobuf/types.Any.
// FromAny converts an arbitrary interface to github.com/containerd/containerd/protobuf/types.Any.
func MarshalAnyToProto(from interface{}) (*types.Any, error) {
any, err := typeurl.MarshalAny(from)
if err != nil {
Expand Down
30 changes: 30 additions & 0 deletions protobuf/proto/proto.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
Copyright The containerd Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// Package proto provides convinient aliases that make google.golang.org/protobuf migration easier.
package proto

import (
gogo "github.com/gogo/protobuf/proto"
)

func Marshal(input gogo.Message) ([]byte, error) {
return gogo.Marshal(input)
}

func Unmarshal(input []byte, output gogo.Message) error {
return gogo.Unmarshal(input, output)
}
26 changes: 26 additions & 0 deletions protobuf/types/types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
Copyright The containerd Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// Package types provides convinient aliases that make google.golang.org/protobuf migration easier.
package types

import (
gogo "github.com/gogo/protobuf/types"
)

type Empty = gogo.Empty
type Any = gogo.Any
type FieldMask = gogo.FieldMask
Loading

0 comments on commit 88c0c72

Please sign in to comment.