forked from toolshed/abra
chore: vendor
This commit is contained in:
36
vendor/github.com/containers/image/transports/stub.go
generated
vendored
Normal file
36
vendor/github.com/containers/image/transports/stub.go
generated
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
package transports
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/containers/image/types"
|
||||
)
|
||||
|
||||
// stubTransport is an implementation of types.ImageTransport which has a name, but rejects any references with “the transport $name: is not supported in this build”.
|
||||
type stubTransport string
|
||||
|
||||
// NewStubTransport returns an implementation of types.ImageTransport which has a name, but rejects any references with “the transport $name: is not supported in this build”.
|
||||
func NewStubTransport(name string) types.ImageTransport {
|
||||
return stubTransport(name)
|
||||
}
|
||||
|
||||
// Name returns the name of the transport, which must be unique among other transports.
|
||||
func (s stubTransport) Name() string {
|
||||
return string(s)
|
||||
}
|
||||
|
||||
// ParseReference converts a string, which should not start with the ImageTransport.Name prefix, into an ImageReference.
|
||||
func (s stubTransport) ParseReference(reference string) (types.ImageReference, error) {
|
||||
return nil, fmt.Errorf(`The transport "%s:" is not supported in this build`, string(s))
|
||||
}
|
||||
|
||||
// ValidatePolicyConfigurationScope checks that scope is a valid name for a signature.PolicyTransportScopes keys
|
||||
// (i.e. a valid PolicyConfigurationIdentity() or PolicyConfigurationNamespaces() return value).
|
||||
// It is acceptable to allow an invalid value which will never be matched, it can "only" cause user confusion.
|
||||
// scope passed to this function will not be "", that value is always allowed.
|
||||
func (s stubTransport) ValidatePolicyConfigurationScope(scope string) error {
|
||||
// Allowing any reference in here allows tools with some transports stubbed-out to still
|
||||
// use signature verification policies which refer to these stubbed-out transports.
|
||||
// See also the treatment of unknown transports in policyTransportScopesWithTransport.UnmarshalJSON .
|
||||
return nil
|
||||
}
|
90
vendor/github.com/containers/image/transports/transports.go
generated
vendored
Normal file
90
vendor/github.com/containers/image/transports/transports.go
generated
vendored
Normal file
@ -0,0 +1,90 @@
|
||||
package transports
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sort"
|
||||
"sync"
|
||||
|
||||
"github.com/containers/image/types"
|
||||
)
|
||||
|
||||
// knownTransports is a registry of known ImageTransport instances.
|
||||
type knownTransports struct {
|
||||
transports map[string]types.ImageTransport
|
||||
mu sync.Mutex
|
||||
}
|
||||
|
||||
func (kt *knownTransports) Get(k string) types.ImageTransport {
|
||||
kt.mu.Lock()
|
||||
t := kt.transports[k]
|
||||
kt.mu.Unlock()
|
||||
return t
|
||||
}
|
||||
|
||||
func (kt *knownTransports) Remove(k string) {
|
||||
kt.mu.Lock()
|
||||
delete(kt.transports, k)
|
||||
kt.mu.Unlock()
|
||||
}
|
||||
|
||||
func (kt *knownTransports) Add(t types.ImageTransport) {
|
||||
kt.mu.Lock()
|
||||
defer kt.mu.Unlock()
|
||||
name := t.Name()
|
||||
if t := kt.transports[name]; t != nil {
|
||||
panic(fmt.Sprintf("Duplicate image transport name %s", name))
|
||||
}
|
||||
kt.transports[name] = t
|
||||
}
|
||||
|
||||
var kt *knownTransports
|
||||
|
||||
func init() {
|
||||
kt = &knownTransports{
|
||||
transports: make(map[string]types.ImageTransport),
|
||||
}
|
||||
}
|
||||
|
||||
// Get returns the transport specified by name or nil when unavailable.
|
||||
func Get(name string) types.ImageTransport {
|
||||
return kt.Get(name)
|
||||
}
|
||||
|
||||
// Delete deletes a transport from the registered transports.
|
||||
func Delete(name string) {
|
||||
kt.Remove(name)
|
||||
}
|
||||
|
||||
// Register registers a transport.
|
||||
func Register(t types.ImageTransport) {
|
||||
kt.Add(t)
|
||||
}
|
||||
|
||||
// ImageName converts a types.ImageReference into an URL-like image name, which MUST be such that
|
||||
// ParseImageName(ImageName(reference)) returns an equivalent reference.
|
||||
//
|
||||
// This is the generally recommended way to refer to images in the UI.
|
||||
//
|
||||
// NOTE: The returned string is not promised to be equal to the original input to ParseImageName;
|
||||
// e.g. default attribute values omitted by the user may be filled in in the return value, or vice versa.
|
||||
func ImageName(ref types.ImageReference) string {
|
||||
return ref.Transport().Name() + ":" + ref.StringWithinTransport()
|
||||
}
|
||||
|
||||
// ListNames returns a list of non deprecated transport names.
|
||||
// Deprecated transports can be used, but are not presented to users.
|
||||
func ListNames() []string {
|
||||
kt.mu.Lock()
|
||||
defer kt.mu.Unlock()
|
||||
deprecated := map[string]bool{
|
||||
"atomic": true,
|
||||
}
|
||||
var names []string
|
||||
for _, transport := range kt.transports {
|
||||
if !deprecated[transport.Name()] {
|
||||
names = append(names, transport.Name())
|
||||
}
|
||||
}
|
||||
sort.Strings(names)
|
||||
return names
|
||||
}
|
Reference in New Issue
Block a user