"Fossies" - the Fresh Open Source Software Archive

Member "buildah-1.27.2/vendor/github.com/containers/image/v5/transports/alltransports/alltransports.go" (20 Sep 2022, 1704 Bytes) of package /linux/misc/buildah-1.27.2.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. See also the last Fossies "Diffs" side-by-side code changes report for "alltransports.go": 1.26.2_vs_1.26.3.

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