addons

package
v0.8.5-rc.1 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2020 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// NameTotalLengthMax is the maximum total number of characters in a repository name.
	NameTotalLengthMax = 255
)

Variables

View Source
var (
	// ErrReferenceInvalidFormat represents an error while trying to parse a string as a reference.
	ErrReferenceInvalidFormat = errors.New("invalid reference format")

	// ErrTagInvalidFormat represents an error while trying to parse a string as a tag.
	ErrTagInvalidFormat = errors.New("invalid tag format")

	// ErrDigestInvalidFormat represents an error while trying to parse a string as a tag.
	ErrDigestInvalidFormat = errors.New("invalid digest format")

	// ErrNameContainsUppercase is returned for invalid repository names that contain uppercase characters.
	ErrNameContainsUppercase = errors.New("repository name must be lowercase")

	// ErrNameEmpty is returned for empty, invalid repository names.
	ErrNameEmpty = errors.New("repository name must have at least one component")

	// ErrNameTooLong is returned when a repository name is longer than NameTotalLengthMax.
	ErrNameTooLong = fmt.Errorf("repository name must not be more than %v characters", NameTotalLengthMax)

	// ErrNameNotCanonical is returned when a name is not canonical.
	ErrNameNotCanonical = errors.New("repository name must be canonical")
)
View Source
var (

	// DomainRegexp defines the structure of potential domain components
	// that may be part of image names. This is purposely a subset of what is
	// allowed by DNS to ensure backwards compatibility with Docker image
	// names.
	DomainRegexp = expression(
		domainComponentRegexp,
		optional(repeated(literal(`.`), domainComponentRegexp)),
		optional(literal(`:`), match(`[0-9]+`)))

	// TagRegexp matches valid tag names. From docker/docker:graph/tags.go.
	TagRegexp = match(`[\w][\w.-]{0,127}`)

	// DigestRegexp matches valid digests.
	DigestRegexp = match(`[A-Za-z][A-Za-z0-9]*(?:[-_+.][A-Za-z][A-Za-z0-9]*)*[:][[:xdigit:]]{32,}`)

	// NameRegexp is the format for the name component of references. The
	// regexp has capturing groups for the domain and name part omitting
	// the separating forward slash from either.
	NameRegexp = expression(
		optional(capture(DomainRegexp), literal(`/`)),
		optional(capture(nameComponentRegexp), literal(`/`)),
		capture(nameComponentRegexp, optional(repeated(literal(`/`), nameComponentRegexp)))) // "Name"/rest of the path

	// ReferenceRegexp is the full supported format of a reference. The regexp
	// is anchored and has capturing groups for name, tag, and digest
	// components.
	ReferenceRegexp = anchored(NameRegexp,
		optional(literal(":"), capture(TagRegexp)),
		optional(literal("@"), capture(DigestRegexp)))

	// IdentifierRegexp is the format for string identifier used as a
	// content addressable identifier using sha256. These identifiers
	// are like digests without the algorithm, since sha256 is used.
	IdentifierRegexp = match(`([a-f0-9]{64})`)

	// ShortIdentifierRegexp is the format used to represent a prefix
	// of an identifier. A prefix may be used to match a sha256 identifier
	// within a list of trusted identifiers.
	ShortIdentifierRegexp = match(`([a-f0-9]{6,64})`)
)

Functions

func UpdateImage

func UpdateImage(image, repository string) (string, error)

UpdateImage updates the provided container image's fully-qualified name with the provided repository.

Types

type Addon

type Addon struct {
	Kind        addonKind
	Category    string
	Name        string
	Description string
	Params      []Param

	ShortName string // The directory name in addons/
	// Entrypoint is either:
	//  - the jsonnet file to execute to build manifests for jsonnet addons.
	//  - a multi-document YAML file for YAML addons.
	EntryPoint string
	// Jsonnet file to execute to list images. The result is an array of image
	// strings. eg.
	// [
	//   "quay.io/coreos/addon-resizer:1.0",
	//   "quay.io/prometheus/alertmanager:v0.15.3",
	//   "quay.io/coreos/configmap-reload:v0.0.1",
	//   "grafana/grafana:5.2.4"
	// ]
	ListImagesEntryPoint string
	OutputMode           output // How to evaluate the jsonnet script. Default to Single.
}

Addon is a piece of software that can be installed on a Kubernetes cluster.

func Get

func Get(shortName string) (Addon, error)

Get returns the Addon with the corresponding shortName.

func List

func List() []Addon

List returns the list of known addons.

func (*Addon) Build

func (a *Addon) Build(config BuildOptions) ([]string, error)

Build builds the addon manifests and write them to disk. It returns the list of written files.

func (*Addon) HasParam

func (a *Addon) HasParam(name string) bool

HasParam returns true if the addon has name as input parameter.

func (*Addon) ListImages

func (a *Addon) ListImages() ([]registry.Image, error)

ListImages lists all container images required for this addon to run.

func (*Addon) Param

func (a *Addon) Param(name string) *Param

Param returns the named Param.

func (*Addon) ValidateOptions

func (a *Addon) ValidateOptions(config *BuildOptions) error

ValidateOptions validates that the given BuildOptions are valid for this addon.

type BuildOptions

type BuildOptions struct {
	// Base path against which relative paths should be resolved (used for File
	// parameters).
	BasePath string
	// Output directory is the where the addon manifests should be written to. If
	// not given, the current working directory will be used.
	OutputDirectory string
	Params          map[string]string
	// ImageRepository indicates container images should be sourced from this
	// registry instead of their default one(s).
	ImageRepository string
	YAML            bool
}

BuildOptions holds some options for Build.

type Param

type Param struct {
	// Name of the parameter
	Name string
	// Target is the TLA name in the jsonnet file. Defaults to Name.
	Target       string
	Kind         ParamKind
	Required     bool
	DefaultValue string
	Description  string
}

Param is a input parameter for addon configuration.

type ParamError

type ParamError struct {
	Param   string
	Message string
}

ParamError describes an error on the input parameters.

func (*ParamError) Error

func (e *ParamError) Error() string

type ParamKind

type ParamKind string

ParamKind specifies the input parameter type.

const (
	// ParamKindString is a simple string parameter.
	ParamKindString ParamKind = ""
	// ParamKindFile is base64-encoded file content.
	ParamKindFile ParamKind = "file"
)

Directories

Path Synopsis
Package addons defines components to be installed on Kubernetes clusters.
Package addons defines components to be installed on Kubernetes clusters.

Jump to

Keyboard shortcuts

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