The reference/docker package was a fork of github.com/distribution/distribution,
which could not easily be used as a direct dependency, as it brought many other
dependencies with it.
The "reference' package has now moved to a separate repository, which means
we can replace the local fork, and use the upstream implementation again.
The new module was extracted from the distribution repository at commit:
b9b19409cf
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
		
	
		
			
				
	
	
		
			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
 | 
						|
}
 |