add defualt tag suffix

This commit is contained in:
Brad Rydzewski
2017-10-31 08:49:56 -07:00
parent 6f5d6e2481
commit 88ae029815
3 changed files with 81 additions and 3 deletions

19
tags.go
View File

@@ -7,7 +7,24 @@ import (
"github.com/coreos/go-semver/semver"
)
// Default tags returns a set of default suggested tags based on
// DefaultTagSuffix returns a set of default suggested tags
// based on the commit ref with an attached suffix.
func DefaultTagSuffix(ref, suffix string) []string {
tags := DefaultTags(ref)
if len(suffix) == 0 {
return tags
}
for i, tag := range tags {
if tag == "latest" {
tags[i] = suffix
} else {
tags[i] = fmt.Sprintf("%s-%s", tag, suffix)
}
}
return tags
}
// DefaultTags returns a set of default suggested tags based on
// the commit ref.
func DefaultTags(ref string) []string {
if !strings.HasPrefix(ref, "refs/tags/") {