...
1 package ociregistry
2
3 import (
4 "regexp"
5
6 "github.com/opencontainers/go-digest"
7 )
8
9 var (
10 tagPattern = regexp.MustCompile(`^[a-zA-Z0-9_][a-zA-Z0-9._-]{0,127}$`)
11 repoNamePattern = regexp.MustCompile(`^[a-z0-9]+([._-][a-z0-9]+)*(/[a-z0-9]+([._-][a-z0-9]+)*)*$`)
12 )
13
14
15
16 func IsValidRepoName(repoName string) bool {
17 return repoNamePattern.MatchString(repoName)
18 }
19
20
21
22 func IsValidTag(tag string) bool {
23 return tagPattern.MatchString(tag)
24 }
25
26
27 func IsValidDigest(d string) bool {
28 _, err := digest.Parse(d)
29 return err == nil
30 }
31
View as plain text