2017-06-15 14:41:54 -04:00
|
|
|
package manifest
|
|
|
|
|
|
|
|
import (
|
|
|
|
manifesttypes "github.com/docker/cli/cli/manifest/types"
|
|
|
|
"github.com/docker/cli/cli/registry/client"
|
2017-09-26 18:15:04 -04:00
|
|
|
"github.com/docker/distribution"
|
2017-06-15 14:41:54 -04:00
|
|
|
"github.com/docker/distribution/reference"
|
2017-09-26 18:15:04 -04:00
|
|
|
"github.com/opencontainers/go-digest"
|
2017-06-15 14:41:54 -04:00
|
|
|
"golang.org/x/net/context"
|
|
|
|
)
|
|
|
|
|
|
|
|
type fakeRegistryClient struct {
|
|
|
|
client.RegistryClient
|
|
|
|
getManifestFunc func(ctx context.Context, ref reference.Named) (manifesttypes.ImageManifest, error)
|
|
|
|
getManifestListFunc func(ctx context.Context, ref reference.Named) ([]manifesttypes.ImageManifest, error)
|
2017-09-26 18:15:04 -04:00
|
|
|
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)
|
2017-06-15 14:41:54 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
2017-09-26 18:15:04 -04:00
|
|
|
|
|
|
|
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
|
|
|
|
}
|