Move match function to helpers

Update match function to operate on familiar names

Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
This commit is contained in:
Derek McGowan 2017-01-13 17:08:46 -08:00
parent 69c7f303d5
commit 3b0497541a
No known key found for this signature in database
GPG key ID: F58C5D0A4405ACDB
4 changed files with 90 additions and 89 deletions

View file

@ -27,7 +27,6 @@ package reference
import (
"errors"
"fmt"
"path"
"strings"
"github.com/opencontainers/go-digest"
@ -317,16 +316,6 @@ func WithDigest(name Named, digest digest.Digest) (Canonical, error) {
}, nil
}
// Match reports whether ref matches the specified pattern.
// See https://godoc.org/path#Match for supported patterns.
func Match(pattern string, ref Reference) (bool, error) {
matched, err := path.Match(pattern, ref.String())
if namedRef, isNamed := ref.(Named); isNamed && !matched {
matched, _ = path.Match(pattern, namedRef.Name())
}
return matched, err
}
// TrimNamed removes any tag or digest from the named reference.
func TrimNamed(ref Named) Named {
domain, path := SplitHostname(ref)