2017-06-15 14:41:54 -04:00
|
|
|
package manifest
|
|
|
|
|
|
|
|
import (
|
2018-05-03 21:02:44 -04:00
|
|
|
"context"
|
|
|
|
|
2023-08-30 18:36:58 -04:00
|
|
|
"github.com/distribution/reference"
|
2017-06-15 14:41:54 -04:00
|
|
|
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"
|
|
|
|
"github.com/opencontainers/go-digest"
|
2017-06-15 14:41:54 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
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)
|
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
|
|
|
|
}
|
2018-03-08 13:20:42 -05:00
|
|
|
|
|
|
|
var _ client.RegistryClient = &fakeRegistryClient{}
|