github.com/mssola/docker@v1.8.1/graph/tags/tags.go (about) 1 package tags 2 3 import ( 4 "fmt" 5 6 "github.com/docker/distribution/registry/api/v2" 7 ) 8 9 const DEFAULTTAG = "latest" 10 11 type ErrTagInvalidFormat struct { 12 name string 13 } 14 15 func (e ErrTagInvalidFormat) Error() string { 16 return fmt.Sprintf("Illegal tag name (%s): only [A-Za-z0-9_.-] are allowed ('.' and '-' are NOT allowed in the initial), minimum 1, maximum 128 in length", e.name) 17 } 18 19 // ValidateTagName validates the name of a tag 20 func ValidateTagName(name string) error { 21 if name == "" { 22 return fmt.Errorf("tag name can't be empty") 23 } 24 25 if !v2.TagNameAnchoredRegexp.MatchString(name) { 26 return ErrTagInvalidFormat{name} 27 } 28 return nil 29 }