Skip to content

Commit bbe14f0

Browse files
committed
Switch from x/net/context to context
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 <kolyshkin@gmail.com>
1 parent 9d0d4b8 commit bbe14f0

File tree

24 files changed

+39
-25
lines changed

24 files changed

+39
-25
lines changed

cmd/ctr/commands/shim/shim.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,11 @@
1919
package shim
2020

2121
import (
22+
gocontext "context"
2223
"fmt"
2324
"io/ioutil"
2425
"net"
2526

26-
gocontext "context"
27-
2827
"github.com/containerd/console"
2928
"github.com/containerd/containerd/cmd/ctr/commands"
3029
shim "github.com/containerd/containerd/linux/shim/v1"

grpc.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@
1717
package containerd
1818

1919
import (
20+
"context"
21+
2022
"github.com/containerd/containerd/namespaces"
21-
"golang.org/x/net/context"
2223
"google.golang.org/grpc"
2324
)
2425

leases/grpc.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
package leases
1818

1919
import (
20-
"golang.org/x/net/context"
20+
"context"
21+
2122
"google.golang.org/grpc/metadata"
2223
)
2324

metrics/cgroups/cgroups.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
package cgroups
2020

2121
import (
22+
"context"
23+
2224
"github.com/containerd/cgroups"
2325
eventstypes "github.com/containerd/containerd/api/events"
2426
"github.com/containerd/containerd/events"
@@ -30,7 +32,6 @@ import (
3032
"github.com/containerd/containerd/runtime"
3133
metrics "github.com/docker/go-metrics"
3234
"github.com/sirupsen/logrus"
33-
"golang.org/x/net/context"
3435
)
3536

3637
// Config for the cgroups monitor

namespaces/grpc.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
package namespaces
1818

1919
import (
20-
"golang.org/x/net/context"
20+
"context"
21+
2122
"google.golang.org/grpc/metadata"
2223
)
2324

rootfs/apply.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package rootfs
1818

1919
import (
20+
"context"
2021
"crypto/rand"
2122
"encoding/base64"
2223
"fmt"
@@ -30,7 +31,6 @@ import (
3031
"github.com/opencontainers/image-spec/identity"
3132
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
3233
"github.com/pkg/errors"
33-
"golang.org/x/net/context"
3434
)
3535

3636
// Layer represents the descriptors for a layer diff. These descriptions

rootfs/diff.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
1717
package rootfs
1818

1919
import (
20+
"context"
2021
"fmt"
2122

2223
"github.com/containerd/containerd/diff"
2324
"github.com/containerd/containerd/mount"
2425
"github.com/containerd/containerd/snapshots"
2526
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
26-
"golang.org/x/net/context"
2727
)
2828

2929
// CreateDiff creates a layer diff for the given snapshot identifier from the

server/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package server
1818

1919
import (
20+
"context"
2021
"expvar"
2122
"io"
2223
"net"
@@ -37,7 +38,6 @@ import (
3738
metrics "github.com/docker/go-metrics"
3839
grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
3940
"github.com/pkg/errors"
40-
"golang.org/x/net/context"
4141

4242
"google.golang.org/grpc"
4343
)

server/server_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
package server
1818

1919
import (
20+
"context"
2021
"testing"
2122

2223
"github.com/gotestyourself/gotestyourself/assert"
2324
is "github.com/gotestyourself/gotestyourself/assert/cmp"
24-
"golang.org/x/net/context"
2525
)
2626

2727
func TestNewErrorsWithSamePathForRootAndState(t *testing.T) {

services/containers/local.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
package containers
1818

1919
import (
20+
"context"
21+
2022
"github.com/boltdb/bolt"
2123
eventstypes "github.com/containerd/containerd/api/events"
2224
api "github.com/containerd/containerd/api/services/containers/v1"
@@ -27,7 +29,6 @@ import (
2729
"github.com/containerd/containerd/plugin"
2830
"github.com/containerd/containerd/services"
2931
ptypes "github.com/gogo/protobuf/types"
30-
"golang.org/x/net/context"
3132
"google.golang.org/grpc"
3233
"google.golang.org/grpc/codes"
3334
"google.golang.org/grpc/status"

0 commit comments

Comments
 (0)