Files
docker-docs/image.go
Andrea Luzzardi 05864a3b2a Initial commit.
Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
2014-11-07 16:41:33 -08:00

28 lines
457 B
Go

package libcluster
import (
"strings"
)
type ImageInfo struct {
Name string
Tag string
}
// Parse an image name in the format of "name:tag" and return an ImageInfo
// struct. If no tag is defined, assume "latest".
func parseImageName(name string) *ImageInfo {
imageInfo := &ImageInfo{
Name: name,
Tag: "latest",
}
img := strings.Split(name, ":")
if len(img) == 2 {
imageInfo.Name = img[0]
imageInfo.Tag = img[1]
}
return imageInfo
}