Files
skopeo/types/types.go
Miloslav Trmač a4aedae063 Add types.ImageSource and types.ImageDestination
Right now, only a declaration.

This will allow writing generalized push/pull between various storage
mechanisms, and reuse of the Docker Registry client code for the Docker
Registry embedded in OpenShift.
2016-05-02 19:43:16 +02:00

74 lines
2.1 KiB
Go

package types
import (
"fmt"
"io"
"time"
)
const (
// DockerPrefix is the URL-like schema prefix used for Docker image references.
DockerPrefix = "docker://"
)
// Registry is a service providing repositories.
type Registry interface {
Repositories() []Repository
Repository(ref string) Repository
Lookup(term string) []Image // docker registry v1 only AFAICT, v2 can be built hacking with Images()
}
// Repository is a set of images.
type Repository interface {
Images() []Image
Image(ref string) Image // ref == image name w/o registry part
}
// ImageSource is a service, possibly remote (= slow), to download components of a single image.
type ImageSource interface {
GetManifest() (manifest []byte, unverifiedCanonicalDigest string, err error)
GetLayer(digest string) (io.ReadCloser, error)
GetSignatures() ([][]byte, error)
}
// ImageDestination is a service, possibly remote (= slow), to store components of a single image.
type ImageDestination interface {
PutManifest([]byte) error
PutLayer(digest string, stream io.Reader) error
PutSignatures(signatures [][]byte) error
}
// Image is a Docker image in a repository.
type Image interface {
// ref to repository?
Layers(layers ...string) error // configure download directory? Call it DownloadLayers?
Manifest() (ImageManifest, error)
RawManifest(version string) ([]byte, error)
DockerTar() ([]byte, error) // ??? also, configure output directory
}
// ImageManifest is the interesting subset of metadata about an Image.
// TODO(runcom)
type ImageManifest interface {
String() string
}
// DockerImageManifest is a set of metadata describing Docker images and their manifest.json files.
// Note that this is not exactly manifest.json, e.g. some fields have been added.
type DockerImageManifest struct {
Name string
Tag string
Digest string
RepoTags []string
Created time.Time
DockerVersion string
Labels map[string]string
Architecture string
Os string
Layers []string
}
func (m *DockerImageManifest) String() string {
return fmt.Sprintf("%s:%s", m.Name, m.Tag)
}