...

Package ociref

import "cuelabs.dev/go/oci/ociregistry/ociref"
Overview
Index

Overview ▾

Package ociref supports parsing cross-registry OCI registry references.

func IsValidHost

func IsValidHost(s string) bool

IsValidHost reports whether s is a valid host (or host:port) part of a reference string.

func IsValidRepository

func IsValidRepository(s string) bool

IsValidHost reports whether s is a valid repository part of a reference string.

func IsValidTag

func IsValidTag(s string) bool

IsValidTag reports whether s is a valid reference tag.

type Reference

Reference represents an entry in an OCI repository.

type Reference struct {
    // Host holds the host name of the registry
    // within which the repository is stored, optionally in
    // the form host:port. This might be empty.
    Host string

    // Repository holds the repository name.
    Repository string

    // Tag holds the TAG part of a :TAG or :TAG@DIGEST reference.
    // When Digest is set as well as Tag, the tag will be verified
    // to exist and have the expected digest.
    Tag string

    // Digest holds the DIGEST part of an @DIGEST reference
    // or of a :TAG@DIGEST reference.
    Digest ociregistry.Digest
}

func Parse

func Parse(refStr string) (Reference, error)

Parse parses a reference string that must include a host name (or host:port pair) component.

It is represented in string form as HOST[:PORT]/NAME[:TAG|@DIGEST] form: the same syntax accepted by "docker pull". Unlike "docker pull" however, there is no default registry: when presented with a bare repository name, Parse will return an error.

func ParseRelative

func ParseRelative(refStr string) (Reference, error)

ParseRelative parses a reference string that may or may not include a host name component.

It is represented in string form as [HOST[:PORT]/]NAME[:TAG|@DIGEST] form: the same syntax accepted by "docker pull". Unlike "docker pull" however, there is no default registry: when presented with a bare repository name, the Host field will be empty.

func (Reference) String

func (ref Reference) String() string

String returns the string form of a reference in the form

[HOST/]NAME[:TAG|@DIGEST]