context pkg: untangle
Since Go 1.7, "context" is a standard package, superceding the "x/net/context". Since Go 1.9, the latter only provides type aliases from the former. Therefore, it makes sense to switch to the standard package, and the change is not disruptive in any sense. This commit deals with a few cases where both packages happened to be imported by the same source file. A choice between "context" and "gocontext" was made for each file in order to minimize the patch. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
parent
f337075620
commit
9d0d4b806c
@ -17,7 +17,7 @@
|
|||||||
package command
|
package command
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
gocontext "context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
golog "log"
|
golog "log"
|
||||||
@ -35,7 +35,6 @@ import (
|
|||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
gocontext "golang.org/x/net/context"
|
|
||||||
"google.golang.org/grpc/grpclog"
|
"google.golang.org/grpc/grpclog"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -168,7 +167,7 @@ func App() *cli.App {
|
|||||||
return app
|
return app
|
||||||
}
|
}
|
||||||
|
|
||||||
func serve(ctx context.Context, l net.Listener, serveFunc func(net.Listener) error) {
|
func serve(ctx gocontext.Context, l net.Listener, serveFunc func(net.Listener) error) {
|
||||||
path := l.Addr().String()
|
path := l.Addr().String()
|
||||||
log.G(ctx).WithField("address", path).Info("serving...")
|
log.G(ctx).WithField("address", path).Info("serving...")
|
||||||
go func() {
|
go func() {
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
package images
|
package images
|
||||||
|
|
||||||
import (
|
import (
|
||||||
gocontext "context"
|
"context"
|
||||||
|
|
||||||
eventstypes "github.com/containerd/containerd/api/events"
|
eventstypes "github.com/containerd/containerd/api/events"
|
||||||
imagesapi "github.com/containerd/containerd/api/services/images/v1"
|
imagesapi "github.com/containerd/containerd/api/services/images/v1"
|
||||||
@ -30,7 +30,6 @@ import (
|
|||||||
"github.com/containerd/containerd/plugin"
|
"github.com/containerd/containerd/plugin"
|
||||||
"github.com/containerd/containerd/services"
|
"github.com/containerd/containerd/services"
|
||||||
ptypes "github.com/gogo/protobuf/types"
|
ptypes "github.com/gogo/protobuf/types"
|
||||||
"golang.org/x/net/context"
|
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
"google.golang.org/grpc/codes"
|
"google.golang.org/grpc/codes"
|
||||||
"google.golang.org/grpc/status"
|
"google.golang.org/grpc/status"
|
||||||
@ -64,7 +63,7 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type gcScheduler interface {
|
type gcScheduler interface {
|
||||||
ScheduleAndWait(gocontext.Context) (gc.Stats, error)
|
ScheduleAndWait(context.Context) (gc.Stats, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type local struct {
|
type local struct {
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
package snapshots
|
package snapshots
|
||||||
|
|
||||||
import (
|
import (
|
||||||
gocontext "context"
|
"context"
|
||||||
|
|
||||||
snapshotsapi "github.com/containerd/containerd/api/services/snapshots/v1"
|
snapshotsapi "github.com/containerd/containerd/api/services/snapshots/v1"
|
||||||
"github.com/containerd/containerd/api/types"
|
"github.com/containerd/containerd/api/types"
|
||||||
@ -29,7 +29,6 @@ import (
|
|||||||
"github.com/containerd/containerd/snapshots"
|
"github.com/containerd/containerd/snapshots"
|
||||||
ptypes "github.com/gogo/protobuf/types"
|
ptypes "github.com/gogo/protobuf/types"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"golang.org/x/net/context"
|
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -216,7 +215,7 @@ func (s *service) List(sr *snapshotsapi.ListSnapshotsRequest, ss snapshotsapi.Sn
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
err = sn.Walk(ss.Context(), func(ctx gocontext.Context, info snapshots.Info) error {
|
err = sn.Walk(ss.Context(), func(ctx context.Context, info snapshots.Info) error {
|
||||||
buffer = append(buffer, fromInfo(info))
|
buffer = append(buffer, fromInfo(info))
|
||||||
|
|
||||||
if len(buffer) >= 100 {
|
if len(buffer) >= 100 {
|
||||||
|
Loading…
Reference in New Issue
Block a user