mirror of
https://github.com/containers/skopeo.git
synced 2025-08-28 11:03:19 +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
|
||||
}
|
||||
|
||||
// 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.
|
||||
func (i *Image) SourceRefFullName() (string, error) {
|
||||
// FIXME? Breaking the abstraction.
|
||||
return i.genericImage.src.ref.FullName(), nil
|
||||
src, err := i.dockerSource()
|
||||
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.
|
||||
func (i *Image) GetRepositoryTags() ([]string, error) {
|
||||
// FIXME? Breaking the abstraction.
|
||||
url := fmt.Sprintf(tagsURL, i.genericImage.src.ref.RemoteName())
|
||||
res, err := i.genericImage.src.c.makeRequest("GET", url, nil, nil)
|
||||
src, err := i.dockerSource()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
url := fmt.Sprintf(tagsURL, src.ref.RemoteName())
|
||||
res, err := src.c.makeRequest("GET", url, nil, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -18,9 +18,10 @@ var (
|
||||
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 {
|
||||
src *dockerImageSource
|
||||
src types.ImageSource
|
||||
cachedManifest []byte // Private cache for Manifest(); nil if not yet known.
|
||||
cachedSignatures [][]byte // Private cache for Signatures(); nil if not yet known.
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user