Skip to content

Commit

Permalink
Switch from x/net/context to context
Browse files Browse the repository at this point in the history
Since Go 1.7, context is a standard package, superceding the
"x/net/context". Since Go 1.9, the latter only provides a few type
aliases from the former. Therefore, it makes sense to switch to the
standard package.

This commit was generated by the following script (with a couple of
minor fixups to remove extra changes done by goimports):

	#!/bin/bash

	if [ $# -ge 1 ]; then
		FILES=$*
	else
		FILES=$(git ls-files \*.go | grep -vF ".pb.go" | grep -v
	^vendor/)
	fi

	for f in $FILES; do
		printf .
		sed -i -e 's|"golang.org/x/net/context"$|"context"|' $f
		goimports -w $f
		awk '	/^$/ {e=1; next;}
			/[[:space:]]"context"$/ {e=0;}
			{if (e) {print ""; e=0}; print;}' < $f > $f.new && \
				mv $f.new $f
		goimports -w $f
	done
	echo

Signed-off-by: Kir Kolyshkin <[email protected]>
  • Loading branch information
kolyshkin committed Apr 24, 2018
1 parent 9d0d4b8 commit bbe14f0
Show file tree
Hide file tree
Showing 24 changed files with 39 additions and 25 deletions.
3 changes: 1 addition & 2 deletions cmd/ctr/commands/shim/shim.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,11 @@
package shim

import (
gocontext "context"
"fmt"
"io/ioutil"
"net"

gocontext "context"

"github.com/containerd/console"
"github.com/containerd/containerd/cmd/ctr/commands"
shim "github.com/containerd/containerd/linux/shim/v1"
Expand Down
3 changes: 2 additions & 1 deletion grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
package containerd

import (
"context"

"github.com/containerd/containerd/namespaces"
"golang.org/x/net/context"
"google.golang.org/grpc"
)

Expand Down
3 changes: 2 additions & 1 deletion leases/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
package leases

import (
"golang.org/x/net/context"
"context"

"google.golang.org/grpc/metadata"
)

Expand Down
3 changes: 2 additions & 1 deletion metrics/cgroups/cgroups.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
package cgroups

import (
"context"

"github.com/containerd/cgroups"
eventstypes "github.com/containerd/containerd/api/events"
"github.com/containerd/containerd/events"
Expand All @@ -30,7 +32,6 @@ import (
"github.com/containerd/containerd/runtime"
metrics "github.com/docker/go-metrics"
"github.com/sirupsen/logrus"
"golang.org/x/net/context"
)

// Config for the cgroups monitor
Expand Down
3 changes: 2 additions & 1 deletion namespaces/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
package namespaces

import (
"golang.org/x/net/context"
"context"

"google.golang.org/grpc/metadata"
)

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

import (
"context"
"crypto/rand"
"encoding/base64"
"fmt"
Expand All @@ -30,7 +31,6 @@ import (
"github.com/opencontainers/image-spec/identity"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors"
"golang.org/x/net/context"
)

// Layer represents the descriptors for a layer diff. These descriptions
Expand Down
2 changes: 1 addition & 1 deletion rootfs/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
package rootfs

import (
"context"
"fmt"

"github.com/containerd/containerd/diff"
"github.com/containerd/containerd/mount"
"github.com/containerd/containerd/snapshots"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"golang.org/x/net/context"
)

// CreateDiff creates a layer diff for the given snapshot identifier from the
Expand Down
2 changes: 1 addition & 1 deletion server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package server

import (
"context"
"expvar"
"io"
"net"
Expand All @@ -37,7 +38,6 @@ import (
metrics "github.com/docker/go-metrics"
grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
"github.com/pkg/errors"
"golang.org/x/net/context"

"google.golang.org/grpc"
)
Expand Down
2 changes: 1 addition & 1 deletion server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
package server

import (
"context"
"testing"

"github.com/gotestyourself/gotestyourself/assert"
is "github.com/gotestyourself/gotestyourself/assert/cmp"
"golang.org/x/net/context"
)

func TestNewErrorsWithSamePathForRootAndState(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion services/containers/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
package containers

import (
"context"

"github.com/boltdb/bolt"
eventstypes "github.com/containerd/containerd/api/events"
api "github.com/containerd/containerd/api/services/containers/v1"
Expand All @@ -27,7 +29,6 @@ import (
"github.com/containerd/containerd/plugin"
"github.com/containerd/containerd/services"
ptypes "github.com/gogo/protobuf/types"
"golang.org/x/net/context"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
Expand Down
3 changes: 2 additions & 1 deletion services/containers/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@
package containers

import (
"context"

api "github.com/containerd/containerd/api/services/containers/v1"
"github.com/containerd/containerd/plugin"
"github.com/containerd/containerd/services"
ptypes "github.com/gogo/protobuf/types"
"github.com/pkg/errors"
"golang.org/x/net/context"
"google.golang.org/grpc"
)

Expand Down
2 changes: 1 addition & 1 deletion services/content/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package content

import (
"context"
"io"
"sync"

Expand All @@ -30,7 +31,6 @@ import (
digest "github.com/opencontainers/go-digest"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"golang.org/x/net/context"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
Expand Down
3 changes: 2 additions & 1 deletion services/diff/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
package diff

import (
"context"

diffapi "github.com/containerd/containerd/api/services/diff/v1"
"github.com/containerd/containerd/api/types"
"github.com/containerd/containerd/diff"
Expand All @@ -26,7 +28,6 @@ import (
"github.com/containerd/containerd/services"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors"
"golang.org/x/net/context"
"google.golang.org/grpc"
)

Expand Down
3 changes: 2 additions & 1 deletion services/diff/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@
package diff

import (
"context"

diffapi "github.com/containerd/containerd/api/services/diff/v1"
"github.com/containerd/containerd/plugin"
"github.com/containerd/containerd/services"
"github.com/pkg/errors"
"golang.org/x/net/context"
"google.golang.org/grpc"
)

Expand Down
3 changes: 2 additions & 1 deletion services/events/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@
package events

import (
"context"

api "github.com/containerd/containerd/api/services/events/v1"
"github.com/containerd/containerd/errdefs"
"github.com/containerd/containerd/events"
"github.com/containerd/containerd/events/exchange"
"github.com/containerd/containerd/plugin"
ptypes "github.com/gogo/protobuf/types"
"github.com/pkg/errors"
"golang.org/x/net/context"
"google.golang.org/grpc"
)

Expand Down
3 changes: 2 additions & 1 deletion services/images/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@
package images

import (
"context"

imagesapi "github.com/containerd/containerd/api/services/images/v1"
"github.com/containerd/containerd/plugin"
"github.com/containerd/containerd/services"
ptypes "github.com/gogo/protobuf/types"
"github.com/pkg/errors"
"golang.org/x/net/context"
"google.golang.org/grpc"
)

Expand Down
3 changes: 2 additions & 1 deletion services/introspection/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@
package introspection

import (
context "context"

api "github.com/containerd/containerd/api/services/introspection/v1"
"github.com/containerd/containerd/api/types"
"github.com/containerd/containerd/errdefs"
"github.com/containerd/containerd/filters"
"github.com/containerd/containerd/plugin"
"github.com/gogo/googleapis/google/rpc"
ptypes "github.com/gogo/protobuf/types"
context "golang.org/x/net/context"
"google.golang.org/grpc"
"google.golang.org/grpc/status"
)
Expand Down
2 changes: 1 addition & 1 deletion services/leases/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package leases

import (
"context"
"crypto/rand"
"encoding/base64"
"fmt"
Expand All @@ -30,7 +31,6 @@ import (
"github.com/containerd/containerd/plugin"
"github.com/containerd/containerd/services"
ptypes "github.com/gogo/protobuf/types"
"golang.org/x/net/context"
)

func init() {
Expand Down
3 changes: 2 additions & 1 deletion services/leases/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@
package leases

import (
"context"

"google.golang.org/grpc"

api "github.com/containerd/containerd/api/services/leases/v1"
"github.com/containerd/containerd/plugin"
"github.com/containerd/containerd/services"
ptypes "github.com/gogo/protobuf/types"
"github.com/pkg/errors"
"golang.org/x/net/context"
)

func init() {
Expand Down
2 changes: 1 addition & 1 deletion services/namespaces/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package namespaces

import (
"context"
"strings"

"github.com/boltdb/bolt"
Expand All @@ -29,7 +30,6 @@ import (
"github.com/containerd/containerd/plugin"
"github.com/containerd/containerd/services"
ptypes "github.com/gogo/protobuf/types"
"golang.org/x/net/context"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
Expand Down
3 changes: 2 additions & 1 deletion services/namespaces/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@
package namespaces

import (
"context"

api "github.com/containerd/containerd/api/services/namespaces/v1"
"github.com/containerd/containerd/plugin"
"github.com/containerd/containerd/services"
ptypes "github.com/gogo/protobuf/types"
"github.com/pkg/errors"
"golang.org/x/net/context"
"google.golang.org/grpc"
)

Expand Down
2 changes: 1 addition & 1 deletion services/tasks/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package tasks

import (
"bytes"
"context"
"fmt"
"io"
"io/ioutil"
Expand Down Expand Up @@ -45,7 +46,6 @@ import (
"github.com/containerd/typeurl"
ptypes "github.com/gogo/protobuf/types"
"github.com/pkg/errors"
"golang.org/x/net/context"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
Expand Down
3 changes: 2 additions & 1 deletion services/tasks/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@
package tasks

import (
"context"

api "github.com/containerd/containerd/api/services/tasks/v1"
"github.com/containerd/containerd/plugin"
"github.com/containerd/containerd/services"
ptypes "github.com/gogo/protobuf/types"
"github.com/pkg/errors"
"golang.org/x/net/context"
"google.golang.org/grpc"
)

Expand Down
3 changes: 2 additions & 1 deletion services/version/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@
package version

import (
"context"

api "github.com/containerd/containerd/api/services/version/v1"
"github.com/containerd/containerd/plugin"
ctrdversion "github.com/containerd/containerd/version"
ptypes "github.com/gogo/protobuf/types"
"golang.org/x/net/context"
"google.golang.org/grpc"
)

Expand Down

0 comments on commit bbe14f0

Please sign in to comment.