mirror of
https://github.com/containers/skopeo.git
synced 2025-08-29 03:22:43 +00:00
Use types.ImageSource instead of *dockerImageSource in genericImage
This finally makes genericImage Docker-independent. (dockerImage is still the only implementation of types.Image.)
This commit is contained in:
parent
cada464c90
commit
ea643e8658
@ -24,17 +24,32 @@ func NewDockerImage(img, certPath string, tlsVerify bool) (types.Image, error) {
|
|||||||
return &Image{genericImage{src: s}}, nil
|
return &Image{genericImage{src: s}}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// By construction a, docker.Image.genericImage.src must be a dockerImageSource.
|
||||||
|
// dockerSource returns it.
|
||||||
|
func (i *Image) dockerSource() (*dockerImageSource, error) {
|
||||||
|
if src, ok := i.genericImage.src.(*dockerImageSource); ok {
|
||||||
|
return src, nil
|
||||||
|
}
|
||||||
|
return nil, fmt.Errorf("Unexpected internal inconsistency, docker.Image not based on dockerImageSource")
|
||||||
|
}
|
||||||
|
|
||||||
// SourceRefFullName returns a fully expanded name for the repository this image is in.
|
// SourceRefFullName returns a fully expanded name for the repository this image is in.
|
||||||
func (i *Image) SourceRefFullName() (string, error) {
|
func (i *Image) SourceRefFullName() (string, error) {
|
||||||
// FIXME? Breaking the abstraction.
|
src, err := i.dockerSource()
|
||||||
return i.genericImage.src.ref.FullName(), nil
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
return src.ref.FullName(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRepositoryTags list all tags available in the repository. Note that this has no connection with the tag(s) used for this specific image, if any.
|
// GetRepositoryTags list all tags available in the repository. Note that this has no connection with the tag(s) used for this specific image, if any.
|
||||||
func (i *Image) GetRepositoryTags() ([]string, error) {
|
func (i *Image) GetRepositoryTags() ([]string, error) {
|
||||||
// FIXME? Breaking the abstraction.
|
src, err := i.dockerSource()
|
||||||
url := fmt.Sprintf(tagsURL, i.genericImage.src.ref.RemoteName())
|
if err != nil {
|
||||||
res, err := i.genericImage.src.c.makeRequest("GET", url, nil, nil)
|
return nil, err
|
||||||
|
}
|
||||||
|
url := fmt.Sprintf(tagsURL, src.ref.RemoteName())
|
||||||
|
res, err := src.c.makeRequest("GET", url, nil, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -18,9 +18,10 @@ var (
|
|||||||
validHex = regexp.MustCompile(`^([a-f0-9]{64})$`)
|
validHex = regexp.MustCompile(`^([a-f0-9]{64})$`)
|
||||||
)
|
)
|
||||||
|
|
||||||
// genericImage is a general set of utilities for working with container images.
|
// genericImage is a general set of utilities for working with container images,
|
||||||
|
// whatever is their underlying location (i.e. dockerImageSource-independent).
|
||||||
type genericImage struct {
|
type genericImage struct {
|
||||||
src *dockerImageSource
|
src types.ImageSource
|
||||||
cachedManifest []byte // Private cache for Manifest(); nil if not yet known.
|
cachedManifest []byte // Private cache for Manifest(); nil if not yet known.
|
||||||
cachedSignatures [][]byte // Private cache for Signatures(); nil if not yet known.
|
cachedSignatures [][]byte // Private cache for Signatures(); nil if not yet known.
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user