Files
skopeo/docker_utils.go
Antonio Murdaca f43a92a78f *: split docker.go for future pkg creation
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
2016-05-09 21:13:17 +02:00

23 lines
536 B
Go

package main
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
}