tupliplib

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2020 License: LGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Space depicts a simple space character.
	Space = " "

	// DockerRegistry is the Docker Hub registry URL.
	DockerRegistry = "https://registry-1.docker.io/"

	// VersionSeparator is the separator that separates the alias form the semantic version.
	VersionSeparator = ":"

	// WildcardDependency is the alias for a wildcard dependency to build a root tag vector
	// (i.e., semantic version without a prefix).
	WildcardDependency = "_"

	// VersionDot is the separator that separates the digits of a semantic version.
	VersionDot = "."

	// DockerTagSeparator is the separator that separates the sub tags in a Docker tag.
	DockerTagSeparator = "-"

	// DockerFromInstruction is the FROM instruction in Dockerfiles.
	DockerFromInstruction = "FROM"

	// DockerArgInstruction is the ARG instruction in Dockerfiles.
	DockerArgInstruction = "ARG"

	// VersionArg is the argument name for the root version.
	VersionArg = "VERSION"

	// VersionInstruction is the Dockerfile's ARG VERSION.
	VersionInstruction = DockerArgInstruction + Space + VersionArg

	// RepositoryArg is the argument name for the root repository.
	RepositoryArg = "REPOSITORY"

	// RepositoryInstruction is the Dockerfile's ARG REPOSITORY.
	RepositoryInstruction = DockerArgInstruction + Space + RepositoryArg

	// DockerScratch is the empty Docker base image alias.
	DockerScratch = "scratch"

	// DockerLatestTag depicts the 'latest' tag.
	DockerLatestTag = "latest"

	// IgnoredAliasPrefix depicts the Docker FROM instructions' alias prefix so that the instruction is ignored.
	IgnoredAliasPrefix = "i__"

	// ScratchInstruction is a simple Docker FROM instruction using scratch only.
	ScratchInstruction = DockerFromInstruction + Space + DockerScratch

	// WildcardInstruction depicts a FROM instruction with a wildcard dependency.
	WildcardInstruction = DockerFromInstruction + Space + WildcardDependency + VersionSeparator

	// VersionChars are the characters that are used in a semantic version.
	VersionChars = "0123456789."

	// ArgEquation depicts the equals character in a Docker ARG instruction.
	ArgEquation = "="

	// DockerAs is the alias in FROM instructions in Dockerfiles.
	DockerAs = Space + "as" + Space

	// VectorSeparator is the default tag vector separator.
	VectorSeparator = " "

	// RepositorySeparator is the character that separates the organization from the name.
	RepositorySeparator = "/"

	// Dockerfile is the default name of a Dockerfile.
	Dockerfile = "Dockerfile"
)

Variables

This section is empty.

Functions

func UseLogger

func UseLogger(newLogger *onelog.Logger)

UseLogger sets a custom Logger for the package.

Types

type SortedSet

type SortedSet []mapset.Set

SortedSet is a a slice of map sets to make them sortable. It will be sorted alphabetically by the string representations of the subsets.

func (SortedSet) Len

func (a SortedSet) Len() int

Len gives the size of the slice.

func (SortedSet) Less

func (a SortedSet) Less(i, j int) bool

Less determines a order for the slice from the string representations of the subsets.

func (SortedSet) Swap

func (a SortedSet) Swap(i, j int)

Swap swaps the two slice elements at the given positions.

type Tuplip

type Tuplip struct {
	// ExcludeMajor excludes the major versions from the considered version variants.
	ExcludeMajor bool `short:"m" help:"excludes the major versions from the considered version variants"`
	// ExcludeMinor excludes the minor versions from the considered version variants.
	ExcludeMinor bool `short:"i" help:"excludes the minor versions from the considered version variants"`
	// ExcludeBase excludes the base alias without version suffix from the considered version variants.
	ExcludeBase bool `short:"b" help:"excludes the base alias without version suffix from the considered version variants"`
	// Filter excludes all tags without the given set of tag vectors from the output set.
	Filter []string `short:"f" help:"excludes all tags without the given set of tag vectors from the output set"`
	// Simulate prevents the execution of any Docker commands.
	Simulate bool `hidden:""`
	// AddLatest adds an additional 'latest' tag to the result set.
	AddLatest bool `short:"l" help:"adds an additional 'latest' root tag to the result set"`
	// ExclusiveLatest makes the `latest` tag vector version an exclusive tag if given.
	// Then, the output will only contain `latest` if the input contains `latest` as root tag vector version.
	ExclusiveLatest bool `short:"e" help:"make the 'latest' root tag vector version an exclusive tag if given"`
}

Tuplip contains the parameters for the Docker tag generation.

func (*Tuplip) FromFile

func (t *Tuplip) FromFile(src string, overrideVersion string) (source *TuplipSource, err error)

FromFile builds a tuplip source from a Dockerfile. If overrideVersion is non-empty, it overrides the VERSION ARG in the given Dockerfile.

func (*Tuplip) FromReader

func (t *Tuplip) FromReader(src io.Reader, sep string) *TuplipSource

FromReader builds a tuplip source from a io.Reader as scanner. The separator is used to split the tag vectors from the same row. It defaults to an empty space.

func (*Tuplip) FromSlice

func (t *Tuplip) FromSlice(src []string) *TuplipSource

FromSlice builds a tuplip source from a slice.

type TuplipSource

type TuplipSource struct {

	// Repository is the Docker Hub repository of the root tag vector in the format `organization/repository`.
	Repository string
	// contains filtered or unexported fields
}

TuplipSource is the intermediary-built Tuplip stream containing only the source parsing steps.

func (*TuplipSource) Build

func (s *TuplipSource) Build(requireSemver bool) (stream *stream.Stream)

Build defines a tuplip stream that builds a complete set of Docker tags. The returned stream has no configured sink. requireSemver enables semantic version checks. Short versions are not allowed then.

func (*TuplipSource) Find

func (s *TuplipSource) Find() (stream *stream.Stream, err error)

Find defines a tuplip stream that finds an appropriate matching Docker tag in the given Docker Hub repository. The returned stream has no configured sink.

func (*TuplipSource) Push

func (s *TuplipSource) Push() (stream *stream.Stream, err error)

Push extends the given stream by a `docker push` execution for all incoming tags.

func (*TuplipSource) Straight

func (s *TuplipSource) Straight() (stream *stream.Stream)

Straight defines a tuplip stream that maps the input tag vectors straightly as output tags.

func (*TuplipSource) Tag

func (s *TuplipSource) Tag(sourceTag string) (stream *stream.Stream, err error)

Tag extends the given stream by a `docker tag` execution for all incoming tags.

Jump to

Keyboard shortcuts

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