Merge pull request #142 from runcom/vendor-contimage

Vendor containers/image
This commit is contained in:
Antonio Murdaca 2016-07-04 12:46:10 +02:00 committed by GitHub
commit 29d76eb5ca
10 changed files with 36 additions and 36 deletions

View File

@ -37,7 +37,7 @@ var layersCmd = cli.Command{
if err != nil {
return err
}
dest := directory.NewDirImageDestination(tmpDir)
dest := directory.NewImageDestination(tmpDir)
manifest, _, err := src.Manifest()
if err != nil {
return err

View File

@ -34,11 +34,11 @@ func parseImage(c *cli.Context) (types.Image, error) {
)
switch {
case strings.HasPrefix(imgName, dockerPrefix):
return docker.NewDockerImage(strings.TrimPrefix(imgName, dockerPrefix), certPath, tlsVerify)
return docker.NewImage(strings.TrimPrefix(imgName, dockerPrefix), certPath, tlsVerify)
//case strings.HasPrefix(img, appcPrefix):
//
case strings.HasPrefix(imgName, directoryPrefix):
src := directory.NewDirImageSource(strings.TrimPrefix(imgName, directoryPrefix))
src := directory.NewImageSource(strings.TrimPrefix(imgName, directoryPrefix))
return image.FromSource(src, nil), nil
}
return nil, errors.New("no valid prefix provided")
@ -52,11 +52,11 @@ func parseImageSource(c *cli.Context, name string) (types.ImageSource, error) {
)
switch {
case strings.HasPrefix(name, dockerPrefix):
return docker.NewDockerImageSource(strings.TrimPrefix(name, dockerPrefix), certPath, tlsVerify)
return docker.NewImageSource(strings.TrimPrefix(name, dockerPrefix), certPath, tlsVerify)
case strings.HasPrefix(name, atomicPrefix):
return openshift.NewOpenshiftImageSource(strings.TrimPrefix(name, atomicPrefix), certPath, tlsVerify)
return openshift.NewImageSource(strings.TrimPrefix(name, atomicPrefix), certPath, tlsVerify)
case strings.HasPrefix(name, directoryPrefix):
return directory.NewDirImageSource(strings.TrimPrefix(name, directoryPrefix)), nil
return directory.NewImageSource(strings.TrimPrefix(name, directoryPrefix)), nil
}
return nil, fmt.Errorf("Unrecognized image reference %s", name)
}
@ -69,13 +69,13 @@ func parseImageDestination(c *cli.Context, name string) (types.ImageDestination,
)
switch {
case strings.HasPrefix(name, dockerPrefix):
return docker.NewDockerImageDestination(strings.TrimPrefix(name, dockerPrefix), certPath, tlsVerify)
return docker.NewImageDestination(strings.TrimPrefix(name, dockerPrefix), certPath, tlsVerify)
case strings.HasPrefix(name, atomicPrefix):
return openshift.NewOpenshiftImageDestination(strings.TrimPrefix(name, atomicPrefix), certPath, tlsVerify)
return openshift.NewImageDestination(strings.TrimPrefix(name, atomicPrefix), certPath, tlsVerify)
case strings.HasPrefix(name, directoryPrefix):
return directory.NewDirImageDestination(strings.TrimPrefix(name, directoryPrefix)), nil
return directory.NewImageDestination(strings.TrimPrefix(name, directoryPrefix)), nil
case strings.HasPrefix(name, ociPrefix):
return oci.NewOCIImageDestination(strings.TrimPrefix(name, ociPrefix))
return oci.NewImageDestination(strings.TrimPrefix(name, ociPrefix))
}
return nil, fmt.Errorf("Unrecognized image reference %s", name)
}

View File

@ -13,8 +13,8 @@ type dirImageDestination struct {
dir string
}
// NewDirImageDestination returns an ImageDestination for writing to an existing directory.
func NewDirImageDestination(dir string) types.ImageDestination {
// NewImageDestination returns an ImageDestination for writing to an existing directory.
func NewImageDestination(dir string) types.ImageDestination {
return &dirImageDestination{dir}
}

View File

@ -13,8 +13,8 @@ type dirImageSource struct {
dir string
}
// NewDirImageSource returns an ImageSource reading from an existing directory.
func NewDirImageSource(dir string) types.ImageSource {
// NewImageSource returns an ImageSource reading from an existing directory.
func NewImageSource(dir string) types.ImageSource {
return &dirImageSource{dir}
}

View File

@ -16,9 +16,9 @@ type Image struct {
src *dockerImageSource
}
// NewDockerImage returns a new Image interface type after setting up
// NewImage returns a new Image interface type after setting up
// a client to the registry hosting the given image.
func NewDockerImage(img, certPath string, tlsVerify bool) (types.Image, error) {
func NewImage(img, certPath string, tlsVerify bool) (types.Image, error) {
s, err := newDockerImageSource(img, certPath, tlsVerify)
if err != nil {
return nil, err

View File

@ -8,9 +8,9 @@ import (
"net/http"
"github.com/Sirupsen/logrus"
"github.com/docker/docker/reference"
"github.com/containers/image/manifest"
"github.com/containers/image/types"
"github.com/docker/docker/reference"
)
type dockerImageDestination struct {
@ -19,9 +19,9 @@ type dockerImageDestination struct {
c *dockerClient
}
// NewDockerImageDestination creates a new ImageDestination for the specified image and connection specification.
func NewDockerImageDestination(img, certPath string, tlsVerify bool) (types.ImageDestination, error) {
ref, tag, err := parseDockerImageName(img)
// NewImageDestination creates a new ImageDestination for the specified image and connection specification.
func NewImageDestination(img, certPath string, tlsVerify bool) (types.ImageDestination, error) {
ref, tag, err := parseImageName(img)
if err != nil {
return nil, err
}
@ -51,7 +51,7 @@ func (d *dockerImageDestination) CanonicalDockerReference() (string, error) {
func (d *dockerImageDestination) PutManifest(m []byte) error {
// FIXME: This only allows upload by digest, not creating a tag. See the
// corresponding comment in NewOpenshiftImageDestination.
// corresponding comment in openshift.NewImageDestination.
digest, err := manifest.Digest(m)
if err != nil {
return err

View File

@ -9,9 +9,9 @@ import (
"strconv"
"github.com/Sirupsen/logrus"
"github.com/docker/docker/reference"
"github.com/containers/image/manifest"
"github.com/containers/image/types"
"github.com/docker/docker/reference"
)
type errFetchManifest struct {
@ -29,9 +29,9 @@ type dockerImageSource struct {
c *dockerClient
}
// newDockerImageSource is the same as NewDockerImageSource, only it returns the more specific *dockerImageSource type.
// newDockerImageSource is the same as NewImageSource, only it returns the more specific *dockerImageSource type.
func newDockerImageSource(img, certPath string, tlsVerify bool) (*dockerImageSource, error) {
ref, tag, err := parseDockerImageName(img)
ref, tag, err := parseImageName(img)
if err != nil {
return nil, err
}
@ -46,8 +46,8 @@ func newDockerImageSource(img, certPath string, tlsVerify bool) (*dockerImageSou
}, nil
}
// NewDockerImageSource creates a new ImageSource for the specified image and connection specification.
func NewDockerImageSource(img, certPath string, tlsVerify bool) (types.ImageSource, error) {
// NewImageSource creates a new ImageSource for the specified image and connection specification.
func NewImageSource(img, certPath string, tlsVerify bool) (types.ImageSource, error) {
return newDockerImageSource(img, certPath, tlsVerify)
}

View File

@ -2,8 +2,8 @@ package docker
import "github.com/docker/docker/reference"
// parseDockerImageName converts a string into a reference and tag value.
func parseDockerImageName(img string) (reference.Named, string, error) {
// parseImageName converts a string into a reference and tag value.
func parseImageName(img string) (reference.Named, string, error) {
ref, err := reference.ParseNamed(img)
if err != nil {
return nil, "", err

View File

@ -35,8 +35,8 @@ type ociImageDestination struct {
var refRegexp = regexp.MustCompile(`^([A-Za-z0-9._-]+)+$`)
// NewOCIImageDestination returns an ImageDestination for writing to an existing directory.
func NewOCIImageDestination(dest string) (types.ImageDestination, error) {
// NewImageDestination returns an ImageDestination for writing to an existing directory.
func NewImageDestination(dest string) (types.ImageDestination, error) {
dir := dest
sep := strings.LastIndex(dest, ":")
tag := "latest"

View File

@ -172,8 +172,8 @@ type openshiftImageSource struct {
imageStreamImageName string // Resolved image identifier, or "" if not known yet
}
// NewOpenshiftImageSource creates a new ImageSource for the specified image and connection specification.
func NewOpenshiftImageSource(imageName, certPath string, tlsVerify bool) (types.ImageSource, error) {
// NewImageSource creates a new ImageSource for the specified image and connection specification.
func NewImageSource(imageName, certPath string, tlsVerify bool) (types.ImageSource, error) {
client, err := newOpenshiftClient(imageName)
if err != nil {
return nil, err
@ -247,7 +247,7 @@ func (s *openshiftImageSource) ensureImageIsResolved() error {
return err
}
logrus.Debugf("Resolved reference %#v", dockerRef)
d, err := docker.NewDockerImageSource(dockerRef, s.certPath, s.tlsVerify)
d, err := docker.NewImageSource(dockerRef, s.certPath, s.tlsVerify)
if err != nil {
return err
}
@ -261,8 +261,8 @@ type openshiftImageDestination struct {
docker types.ImageDestination // The Docker Registry endpoint
}
// NewOpenshiftImageDestination creates a new ImageDestination for the specified image and connection specification.
func NewOpenshiftImageDestination(imageName, certPath string, tlsVerify bool) (types.ImageDestination, error) {
// NewImageDestination creates a new ImageDestination for the specified image and connection specification.
func NewImageDestination(imageName, certPath string, tlsVerify bool) (types.ImageDestination, error) {
client, err := newOpenshiftClient(imageName)
if err != nil {
return nil, err
@ -272,7 +272,7 @@ func NewOpenshiftImageDestination(imageName, certPath string, tlsVerify bool) (t
// i.e. a single signed image cannot be available under multiple tags. But with types.ImageDestination, we don't know
// the manifest digest at this point.
dockerRef := fmt.Sprintf("%s/%s/%s:%s", client.dockerRegistryHostPart(), client.namespace, client.stream, client.tag)
docker, err := docker.NewDockerImageDestination(dockerRef, certPath, tlsVerify)
docker, err := docker.NewImageDestination(dockerRef, certPath, tlsVerify)
if err != nil {
return nil, err
}