func (r *RepoURL) GetURLWithoutTag() string {
	if r.namespace == "" {
		return r.registry + "/" + r.repo
	}
	return r.registry + "/" + r.namespace + "/" + r.repo
}
GetURLWithoutTag returns registry/namespace/repository in a url
package utils
import (
	"fmt"
	"strings"
)
type RepoURL struct {
	url string
	registry  string
	namespace string
	repo      string
	tag       string
}
func NewRepoURL(url string) (*RepoURL, error) {
	slice := strings.SplitN(url, "/", 3)
	var tag, repo string
	repoAndTag := slice[len(slice)-1]
	s := strings.Split(repoAndTag, ":")
	if len(s) > 2 {
		return nil, fmt.Errorf("invalid repository url: %v", url)
	} else if len(s) == 2 {
		repo = s[0]
		tag = s[1]
	} else {
		repo = s[0]
		tag = ""
	}
	if len(slice) == 3 {
		return &RepoURL{
			url:       url,
			registry:  slice[0],
			namespace: slice[1],
			repo:      repo,
			tag:       tag,
		}, nil
	} else if len(slice) == 2 {
		if strings.Contains(slice[0], ".") {
			return &RepoURL{
				url:       url,
				registry:  slice[0],
				namespace: "",
				repo:      repo,
				tag:       tag,
			}, nil
		}
		return &RepoURL{
			url:       url,
			registry:  "registry.hub.docker.com",
			namespace: slice[0],
			repo:      repo,
			tag:       tag,
		}, nil
	} else {
		return &RepoURL{
			url:       url,
			registry:  "registry.hub.docker.com",
			namespace: "library",
			repo:      repo,
			tag:       tag,
		}, nil
	}
}
func (r *RepoURL) GetURL() string {
	url := r.GetURLWithoutTag()
	if r.tag != "" {
		url = url + ":" + r.tag
	}
	return url
}
func (r *RepoURL) GetOriginURL() string {
	return r.url
}
func (r *RepoURL) GetRegistry() string {
	return r.registry
}
func (r *RepoURL) GetNamespace() string {
	return r.namespace
}
func (r *RepoURL) GetRepo() string {
	return r.repo
}
func (r *RepoURL) GetTag() string {
	return r.tag
}
func (r *RepoURL) GetRepoWithNamespace() string {
	if r.namespace == "" {
		return r.repo
	}
	return r.namespace + "/" + r.repo
}
func (r *RepoURL) GetRepoWithTag() string {
	if r.tag == "" {
		return r.repo
	}
	return r.repo + ":" + r.tag
}