forked from toolshed/abra
cli
cmd
pkg
scripts
tests
vendor
coopcloud.tech
dario.cat
git.coopcloud.tech
github.com
AlecAivazis
Azure
BurntSushi
Microsoft
ProtonMail
aymanbagabas
beorn7
cenkalti
cespare
charmbracelet
cloudflare
containerd
containers
cpuguy83
cyphar
davecgh
decentral1se
distribution
reference
.gitattributes
.gitignore
.golangci.yml
CODE-OF-CONDUCT.md
CONTRIBUTING.md
GOVERNANCE.md
LICENSE
MAINTAINERS
Makefile
README.md
SECURITY.md
distribution-logo.svg
helpers.go
normalize.go
reference.go
regexp.go
sort.go
docker
emirpasic
felixge
fvbommel
ghodss
go-git
go-logfmt
go-logr
go-viper
gogo
golang
google
gorilla
grpc-ecosystem
hashicorp
inconshreveable
jbenet
kballard
kevinburke
klauspost
lucasb-eyer
mattn
mgutz
miekg
mitchellh
mmcloughlin
moby
morikuni
muesli
munnerz
opencontainers
pjbgf
pkg
pmezard
prometheus
rivo
russross
schollz
sergi
sirupsen
skeema
spf13
stretchr
theupdateframework
xanzy
xeipuuv
go.opentelemetry.io
golang.org
google.golang.org
gopkg.in
gotest.tools
modules.txt
.dockerignore
.drone.yml
.envrc.sample
.gitignore
.goreleaser.yml
AUTHORS.md
Dockerfile
LICENSE
Makefile
README.md
go.mod
go.sum
renovate.json
43 lines
1.1 KiB
Go
43 lines
1.1 KiB
Go
package reference
|
|
|
|
import "path"
|
|
|
|
// IsNameOnly returns true if reference only contains a repo name.
|
|
func IsNameOnly(ref Named) bool {
|
|
if _, ok := ref.(NamedTagged); ok {
|
|
return false
|
|
}
|
|
if _, ok := ref.(Canonical); ok {
|
|
return false
|
|
}
|
|
return true
|
|
}
|
|
|
|
// FamiliarName returns the familiar name string
|
|
// for the given named, familiarizing if needed.
|
|
func FamiliarName(ref Named) string {
|
|
if nn, ok := ref.(normalizedNamed); ok {
|
|
return nn.Familiar().Name()
|
|
}
|
|
return ref.Name()
|
|
}
|
|
|
|
// FamiliarString returns the familiar string representation
|
|
// for the given reference, familiarizing if needed.
|
|
func FamiliarString(ref Reference) string {
|
|
if nn, ok := ref.(normalizedNamed); ok {
|
|
return nn.Familiar().String()
|
|
}
|
|
return ref.String()
|
|
}
|
|
|
|
// FamiliarMatch reports whether ref matches the specified pattern.
|
|
// See [path.Match] for supported patterns.
|
|
func FamiliarMatch(pattern string, ref Reference) (bool, error) {
|
|
matched, err := path.Match(pattern, FamiliarString(ref))
|
|
if namedRef, isNamed := ref.(Named); isNamed && !matched {
|
|
matched, _ = path.Match(pattern, FamiliarName(namedRef))
|
|
}
|
|
return matched, err
|
|
}
|