Files
skopeo/docker/docker_utils.go
Miloslav Trmač f526328b30 Move directory, docker and openshift from cmd/skopeo to their own subpackages
Does not change behavior.  This is a straightforward move and update of
package references, except for:

- Adding a duplicate definition of manifestSchema1 to
  cmd/skopeo/copy.go.  This will need to be cleaned up later, for now
  preferring to make no design changes in this commit.
- Renaming parseDockerImage to NewDockerImage, to both make it public
  and consistent with common golang conventions.
2016-05-16 18:32:32 +02:00

23 lines
538 B
Go

package docker
import "github.com/projectatomic/skopeo/reference"
// parseDockerImageName converts a string into a reference and tag value.
func parseDockerImageName(img string) (reference.Named, string, error) {
ref, err := reference.ParseNamed(img)
if err != nil {
return nil, "", err
}
if reference.IsNameOnly(ref) {
ref = reference.WithDefaultTag(ref)
}
var tag string
switch x := ref.(type) {
case reference.Canonical:
tag = x.Digest().String()
case reference.NamedTagged:
tag = x.Tag()
}
return ref, tag, nil
}