Since go 1.7, "context" is a standard package. Since go 1.9,
x/net/context merely provides some types aliased to those in
the standard context package.
The changes were performed by the following script:
for f in $(git ls-files \*.go | grep -v ^vendor/); do
sed -i 's|golang.org/x/net/context|context|' $f
goimports -w $f
for i in 1 2; do
awk '/^$/ {e=1; next;}
/\t"context"$/ {e=0;}
{if (e) {print ""; e=0}; print;}' < $f > $f.new && \
mv $f.new $f
goimports -w $f
done
done
[v2: do awk/goimports fixup twice]
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
46 lines
1.6 KiB
Go
46 lines
1.6 KiB
Go
package network
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/docker/docker/api/types"
|
|
"github.com/docker/docker/api/types/network"
|
|
"github.com/docker/docker/client"
|
|
)
|
|
|
|
type fakeClient struct {
|
|
client.Client
|
|
networkCreateFunc func(ctx context.Context, name string, options types.NetworkCreate) (types.NetworkCreateResponse, error)
|
|
networkConnectFunc func(ctx context.Context, networkID, container string, config *network.EndpointSettings) error
|
|
networkDisconnectFunc func(ctx context.Context, networkID, container string, force bool) error
|
|
networkListFunc func(ctx context.Context, options types.NetworkListOptions) ([]types.NetworkResource, error)
|
|
}
|
|
|
|
func (c *fakeClient) NetworkCreate(ctx context.Context, name string, options types.NetworkCreate) (types.NetworkCreateResponse, error) {
|
|
if c.networkCreateFunc != nil {
|
|
return c.networkCreateFunc(ctx, name, options)
|
|
}
|
|
return types.NetworkCreateResponse{}, nil
|
|
}
|
|
|
|
func (c *fakeClient) NetworkConnect(ctx context.Context, networkID, container string, config *network.EndpointSettings) error {
|
|
if c.networkConnectFunc != nil {
|
|
return c.networkConnectFunc(ctx, networkID, container, config)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (c *fakeClient) NetworkDisconnect(ctx context.Context, networkID, container string, force bool) error {
|
|
if c.networkDisconnectFunc != nil {
|
|
return c.networkDisconnectFunc(ctx, networkID, container, force)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (c *fakeClient) NetworkList(ctx context.Context, options types.NetworkListOptions) ([]types.NetworkResource, error) {
|
|
if c.networkListFunc != nil {
|
|
return c.networkListFunc(ctx, options)
|
|
}
|
|
return []types.NetworkResource{}, nil
|
|
}
|