imagename

package
v0.0.0-...-da7d6d0 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2018 License: Apache-2.0 Imports: 7 Imported by: 7

Documentation

Overview

Package imagename provides docker data structure for docker image names It also provides a number of utility functions, related to image name resolving, comparison, and semver functionality.

Index

Constants

View Source
const (
	// Latest is :latest tag value
	Latest = "latest"

	// Wildcards is wildcard value variants
	Wildcards = "x*"
)
View Source
const (
	// StorageRegistry is when docker registry is used as images storage
	StorageRegistry = "registry"

	// StorageS3 is when s3 registry is used as images storage
	StorageS3 = "s3"
)

Variables

This section is empty.

Functions

func ParseRepositoryTag

func ParseRepositoryTag(repos string) (string, string)

ParseRepositoryTag gets a repos name and returns the right reposName + tag|digest The tag can be confusing because of a port in a repository name.

Ex: localhost.localdomain:5000/samalba/hipache:latest
Digest ex: localhost:5000/foo/bar@sha256:bc8813ea7b3603864987522f02a76101c17ad122e1c46d790efc0fca78ca7bfb

NOTE: borrowed from Docker under Apache 2.0, Copyright 2013-2015 Docker, Inc.

func WarnIfOldS3ImageName

func WarnIfOldS3ImageName(imageName string) (bool, string)

WarnIfOldS3ImageName Check whether old image format is used. Also return warning message if yes

Types

type Artifact

type Artifact struct {
	Name        *ImageName `yaml:"Name"`
	Pushed      bool       `yaml:"Pushed"`
	Tag         string     `yaml:"Tag"`
	Digest      string     `yaml:"Digest"`
	ImageID     string     `yaml:"ImageID"`
	Addressable string     `yaml:"Addressable"`
	BuildTime   time.Time  `yaml:"BuildTime"`
}

Artifact represents the artifact that is the result of image build It holds information about the pushed image and may be saved as a file

func (*Artifact) GetFileName

func (a *Artifact) GetFileName() string

GetFileName constructs the base file name out of the image info

func (*Artifact) SetDigest

func (a *Artifact) SetDigest(digest string)

SetDigest sets the digest and forms the Addressable property

type Artifacts

type Artifacts struct {
	RockerArtifacts []Artifact `yaml:"RockerArtifacts"`
}

Artifacts is a collection of Artifact entities

func (*Artifacts) Len

func (a *Artifacts) Len() int

Len returns the length of image tags

func (*Artifacts) Less

func (a *Artifacts) Less(i, j int) bool

Less returns true if item by index[i] is created after of item[j]

func (*Artifacts) Swap

func (a *Artifacts) Swap(i, j int)

Swap swaps items by indices [i] and [j]

type ImageName

type ImageName struct {
	Registry string
	Name     string
	Tag      string
	Storage  string
	Version  *semver.Range

	IsOldS3Name bool
}

ImageName is the data structure with describes docker image name

func New

func New(image string, tag string) *ImageName

New parses a given 'image' and 'tag' strings and returns ImageName

func NewFromString

func NewFromString(image string) *ImageName

NewFromString parses a given string and returns ImageName

func (ImageName) All

func (img ImageName) All() bool

All returns true if tag of the current image refers to any version Example: golang:* == true golang == true golang:latest == false

func (ImageName) Contains

func (img ImageName) Contains(b *ImageName) bool

Contains returns true if the current image tag wildcard satisfies a given image version

func (ImageName) GetECRRegion

func (img ImageName) GetECRRegion() string

GetECRRegion returns the regoin of the AWS ECR registry

func (ImageName) GetTag

func (img ImageName) GetTag() string

GetTag returns the tag of the current image name

func (ImageName) HasTag

func (img ImageName) HasTag() bool

HasTag returns true if tags is specified for the image name

func (ImageName) HasVersion

func (img ImageName) HasVersion() bool

HasVersion returns true if tag of the current image refers to a semver format Example: golang:1.5.1 == true golang:1.5.* == false golang:stable == false golang:latest == false

func (ImageName) HasVersionRange

func (img ImageName) HasVersionRange() bool

HasVersionRange returns true if tag of the current image refers to a semver format and is fuzzy Example: golang:1.5.1 == true golang:1.5.* == true golang:* == true golang:stable == false golang:latest == false golang == false

func (ImageName) IsECR

func (img ImageName) IsECR() bool

IsECR returns true if the registry is AWS ECR

func (ImageName) IsSameKind

func (img ImageName) IsSameKind(b ImageName) bool

IsSameKind returns true if current image and the given one are same but may have different versions (tags)

func (ImageName) IsStrict

func (img ImageName) IsStrict() bool

IsStrict returns true if tag of the current image is specified and contains no fuzzy rules Example: golang:latest == true golang:stable == true golang:1.5.1 == true golang:1.5.* == false golang == false

func (ImageName) MarshalJSON

func (img ImageName) MarshalJSON() ([]byte, error)

MarshalJSON serializes ImageName to JSON string

func (ImageName) MarshalYAML

func (img ImageName) MarshalYAML() (interface{}, error)

MarshalYAML serializes ImageName to YAML string

func (ImageName) NameWithRegistry

func (img ImageName) NameWithRegistry() string

NameWithRegistry returns the [registry/]name of the current image name

func (*ImageName) ResolveVersion

func (img *ImageName) ResolveVersion(list []*ImageName, strictS3Match bool) (result *ImageName)

ResolveVersion finds an applicable tag for current image among the list of available tags

func (*ImageName) SetTag

func (img *ImageName) SetTag(tag string)

SetTag sets the new tag for the imagename

func (ImageName) String

func (img ImageName) String() string

String returns the string representation of the current image name

func (ImageName) TagAsVersion

func (img ImageName) TagAsVersion() (ver *semver.Version)

TagAsVersion return semver.Version of the current image tag in case it's in semver format

func (ImageName) TagIsDigest

func (img ImageName) TagIsDigest() bool

TagIsDigest returns true if the tag is content addressable sha256 e.g. golang@sha256:ead434cd278824865d6e3b67e5d4579ded02eb2e8367fc165efa21138b225f11

func (ImageName) TagIsSha

func (img ImageName) TagIsSha() bool

TagIsSha returns true if the tag is content addressable sha256 but can also be a tag e.g. golang@sha256:ead434cd278824865d6e3b67e5d4579ded02eb2e8367fc165efa21138b225f11 or golang:sha256-ead434cd278824865d6e3b67e5d4579ded02eb2e8367fc165efa21138b225f11

func (*ImageName) UnmarshalJSON

func (img *ImageName) UnmarshalJSON(data []byte) error

UnmarshalJSON parses JSON string and returns ImageName

func (*ImageName) UnmarshalYAML

func (img *ImageName) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML parses YAML string and returns ImageName

type Tag

type Tag struct {
	ID      string
	Name    ImageName
	Created int64
}

Tag is a structure used for cleaning images

type Tags

type Tags struct {
	Items []*Tag
}

Tags is a structure used for cleaning images Sorts out old tags by creation date

func (*Tags) GetOld

func (tags *Tags) GetOld(keep int) []ImageName

GetOld returns the list of items older then [keep] newest items sorted by Created date

func (*Tags) Len

func (tags *Tags) Len() int

Len returns the length of image tags

func (*Tags) Less

func (tags *Tags) Less(i, j int) bool

Less returns true if item by index[i] is created after of item[j]

func (*Tags) Swap

func (tags *Tags) Swap(i, j int)

Swap swaps items by indices [i] and [j]

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL