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>
49 lines
1.7 KiB
Go
49 lines
1.7 KiB
Go
package manifest
|
|
|
|
import (
|
|
"context"
|
|
|
|
manifesttypes "github.com/docker/cli/cli/manifest/types"
|
|
"github.com/docker/cli/cli/registry/client"
|
|
"github.com/docker/distribution"
|
|
"github.com/docker/distribution/reference"
|
|
"github.com/opencontainers/go-digest"
|
|
)
|
|
|
|
type fakeRegistryClient struct {
|
|
getManifestFunc func(ctx context.Context, ref reference.Named) (manifesttypes.ImageManifest, error)
|
|
getManifestListFunc func(ctx context.Context, ref reference.Named) ([]manifesttypes.ImageManifest, error)
|
|
mountBlobFunc func(ctx context.Context, source reference.Canonical, target reference.Named) error
|
|
putManifestFunc func(ctx context.Context, source reference.Named, mf distribution.Manifest) (digest.Digest, error)
|
|
}
|
|
|
|
func (c *fakeRegistryClient) GetManifest(ctx context.Context, ref reference.Named) (manifesttypes.ImageManifest, error) {
|
|
if c.getManifestFunc != nil {
|
|
return c.getManifestFunc(ctx, ref)
|
|
}
|
|
return manifesttypes.ImageManifest{}, nil
|
|
}
|
|
|
|
func (c *fakeRegistryClient) GetManifestList(ctx context.Context, ref reference.Named) ([]manifesttypes.ImageManifest, error) {
|
|
if c.getManifestListFunc != nil {
|
|
return c.getManifestListFunc(ctx, ref)
|
|
}
|
|
return nil, nil
|
|
}
|
|
|
|
func (c *fakeRegistryClient) MountBlob(ctx context.Context, source reference.Canonical, target reference.Named) error {
|
|
if c.mountBlobFunc != nil {
|
|
return c.mountBlobFunc(ctx, source, target)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (c *fakeRegistryClient) PutManifest(ctx context.Context, ref reference.Named, mf distribution.Manifest) (digest.Digest, error) {
|
|
if c.putManifestFunc != nil {
|
|
return c.putManifestFunc(ctx, ref, mf)
|
|
}
|
|
return digest.Digest(""), nil
|
|
}
|
|
|
|
var _ client.RegistryClient = &fakeRegistryClient{}
|