func appendTag()

in pkg/docker.go [99:126]


func appendTag(tagOps []TagOp, dcli *client.Client, tagSuffix string, repoTag string) ([]TagOp, error) {
	imageName, tag, err := GetImageAndTag(repoTag)
	if err != nil {
		return tagOps, err
	}
	// Skip implicit "latest" tag. Images should not be named
	// "latest-<suffix>" (or seen another way, have a "latest-" tag
	// prefix).
	if tag == "latest" {
		fmt.Printf("skipping %v (avoid tagging '%v-%v')\n", repoTag, tag, tagSuffix)
		return tagOps, nil
	}
	if strings.HasSuffix(repoTag, "-"+tagSuffix) {
		fmt.Printf("skipping %v (already has suffix '-%v')\n", repoTag, tagSuffix)
		return tagOps, nil
	}
	var newTag string = tag + "-" + tagSuffix
	if !isValidTag(newTag) {
		return tagOps, fmt.Errorf("new tag %v is invalid", newTag)
	}
	var newRepoTag string = imageName + ":" + newTag
	if repoTagExists(dcli, newRepoTag) {
		fmt.Printf("skipping %v (already suffixed to '-%v')\n", repoTag, tagSuffix)
		return tagOps, nil
	}
	tagOps = append(tagOps, TagOp{repoTag, newRepoTag})
	return tagOps, nil
}