"Fossies" - the Fresh Open Source Software Archive

Member "buildah-1.23.1/vendor/github.com/containers/image/v5/transports/alltransports/alltransports.go" (28 Sep 2021, 1687 Bytes) of package /linux/misc/buildah-1.23.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Go source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 package alltransports
    2 
    3 import (
    4     "strings"
    5 
    6     // register all known transports
    7     // NOTE: Make sure docs/containers-policy.json.5.md is updated when adding or updating
    8     // a transport.
    9     _ "github.com/containers/image/v5/directory"
   10     _ "github.com/containers/image/v5/docker"
   11     _ "github.com/containers/image/v5/docker/archive"
   12     _ "github.com/containers/image/v5/oci/archive"
   13     _ "github.com/containers/image/v5/oci/layout"
   14     _ "github.com/containers/image/v5/openshift"
   15     _ "github.com/containers/image/v5/tarball"
   16     // The ostree transport is registered by ostree*.go
   17     // The storage transport is registered by storage*.go
   18     "github.com/containers/image/v5/transports"
   19     "github.com/containers/image/v5/types"
   20     "github.com/pkg/errors"
   21 )
   22 
   23 // ParseImageName converts a URL-like image name to a types.ImageReference.
   24 func ParseImageName(imgName string) (types.ImageReference, error) {
   25     // Keep this in sync with TransportFromImageName!
   26     parts := strings.SplitN(imgName, ":", 2)
   27     if len(parts) != 2 {
   28         return nil, errors.Errorf(`Invalid image name "%s", expected colon-separated transport:reference`, imgName)
   29     }
   30     transport := transports.Get(parts[0])
   31     if transport == nil {
   32         return nil, errors.Errorf(`Invalid image name "%s", unknown transport "%s"`, imgName, parts[0])
   33     }
   34     return transport.ParseReference(parts[1])
   35 }
   36 
   37 // TransportFromImageName converts an URL-like name to a types.ImageTransport or nil when
   38 // the transport is unknown or when the input is invalid.
   39 func TransportFromImageName(imageName string) types.ImageTransport {
   40     // Keep this in sync with ParseImageName!
   41     parts := strings.SplitN(imageName, ":", 2)
   42     if len(parts) == 2 {
   43         return transports.Get(parts[0])
   44     }
   45     return nil
   46 }