image

package
v0.0.0-...-73a212e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 30, 2018 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidImageID   = errors.New("invalid image ID")
	ErrBlankImageID     = errors.Wrap(ErrInvalidImageID, "blank image name")
	ErrMalformedImageID = errors.Wrap(ErrInvalidImageID, `expected image name as either <image>:<tag> or just <image>`)
)

Functions

func NewerByCreated

func NewerByCreated(lhs, rhs *Info) bool

NewerByCreated returns true if lhs image should be sorted before rhs with regard to their creation date descending.

func NewerBySemver

func NewerBySemver(lhs, rhs *Info) bool

NewerBySemver returns true if lhs image should be sorted before rhs with regard to their semver order descending.

func Sort

func Sort(infos []Info, newer func(a, b *Info) bool)

Sort orders the given image infos according to `newer` func.

Types

type CanonicalName

type CanonicalName struct {
	Name
}

CanonicalName is an image name with none of the fields left to be implied by convention.

type CanonicalRef

type CanonicalRef struct {
	Ref
}

CanonicalRef is an image ref with none of the fields left to be implied by convention.

type Info

type Info struct {
	// the reference to this image; probably a tagged image name
	ID Ref `json:",omitempty"`
	// the digest we got when fetching the metadata, which will be
	// different each time a manifest is uploaded for the reference
	Digest string `json:",omitempty"`
	// an identifier for the *image* this reference points to; this
	// will be the same for references that point at the same image
	// (but does not necessarily equal Docker's image ID)
	ImageID string `json:",omitempty"`
	// the time at which the image pointed at was created
	CreatedAt time.Time `json:",omitempty"`
}

Info has the metadata we are able to determine about an image ref, from its registry.

func (Info) MarshalJSON

func (im Info) MarshalJSON() ([]byte, error)

MarshalJSON returns the Info value in JSON (as bytes). It is implemented so that we can omit the `CreatedAt` value when it's zero, which would otherwise be tricky for e.g., JavaScript to detect.

func (*Info) UnmarshalJSON

func (im *Info) UnmarshalJSON(b []byte) error

UnmarshalJSON populates an Info from JSON (as bytes). It's the companion to MarshalJSON above.

type Name

type Name struct {
	Domain, Image string
}

Name represents an unversioned (i.e., untagged) image a.k.a., an image repo. These sometimes include a domain, e.g., quay.io, and always include a path with at least one element. By convention, images at DockerHub may have the domain omitted; and, if they only have single path element, the prefix `library` is implied.

Examples (stringified):

  • alpine
  • library/alpine
  • quay.io/weaveworks/flux
  • localhost:5000/arbitrary/path/to/repo

func (Name) CanonicalName

func (i Name) CanonicalName() CanonicalName

CanonicalName returns the canonicalised registry host and image parts of the ID.

func (Name) Registry

func (i Name) Registry() string

Registry returns the domain name of the Docker image registry, to use to fetch the image or image metadata.

func (Name) Repository

func (i Name) Repository() string

Repository returns the canonicalised path part of an Name.

func (Name) String

func (i Name) String() string

func (Name) ToRef

func (i Name) ToRef(tag string) Ref

type Ref

type Ref struct {
	Name
	Tag string
}

Ref represents a versioned (i.e., tagged) image. The tag is allowed to be empty, though it is in general undefined what that means. As such, `Ref` also includes all `Name` values.

Examples (stringified):

  • alpine:3.5
  • library/alpine:3.5
  • quay.io/weaveworks/flux:1.1.0
  • localhost:5000/arbitrary/path/to/repo:revision-sha1

func ParseRef

func ParseRef(s string) (Ref, error)

ParseRef parses a string representation of an image id into an Ref value. The grammar is shown here: https://github.com/docker/distribution/blob/master/reference/reference.go (but we do not care about all the productions.)

func (Ref) CanonicalRef

func (i Ref) CanonicalRef() CanonicalRef

CanonicalRef returns the canonicalised reference including the tag if present.

func (Ref) Components

func (i Ref) Components() (domain, repo, tag string)

func (Ref) MarshalJSON

func (i Ref) MarshalJSON() ([]byte, error)

ImageID is serialized/deserialized as a string

func (Ref) String

func (i Ref) String() string

String returns the Ref as a string (i.e., unparsed) without canonicalising it.

func (*Ref) UnmarshalJSON

func (i *Ref) UnmarshalJSON(data []byte) (err error)

ImageID is serialized/deserialized as a string

func (Ref) WithNewTag

func (i Ref) WithNewTag(t string) Ref

WithNewTag makes a new copy of an ImageID with a new tag

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳