types

package
v1.1.8 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2016 License: Apache-2.0, Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package types contains structs representing the various types in the app container specification. It is used by the [schema manifest types](../) to enforce validation.

Index

Constants

View Source
const (
	LinuxCapabilitiesRetainSetName = "os/linux/capabilities-retain-set"
	LinuxCapabilitiesRevokeSetName = "os/linux/capabilities-remove-set"
)
View Source
const (
	ResourceBlockBandwidthName   = "resource/block-bandwidth"
	ResourceBlockIOPSName        = "resource/block-iops"
	ResourceCPUName              = "resource/cpu"
	ResourceMemoryName           = "resource/memory"
	ResourceNetworkBandwidthName = "resource/network-bandwidth"
)

Variables

View Source
var (
	// ValidACIdentifier is a regular expression that defines a valid ACIdentifier
	ValidACIdentifier = regexp.MustCompile("^[a-z0-9]+([-._~/][a-z0-9]+)*$")

	ErrEmptyACIdentifier         = ACIdentifierError("ACIdentifier cannot be empty")
	ErrInvalidEdgeInACIdentifier = ACIdentifierError("ACIdentifier must start and end with only lower case " +
		"alphanumeric characters")
	ErrInvalidCharInACIdentifier = ACIdentifierError("ACIdentifier must contain only lower case " +
		`alphanumeric characters plus "-._~/"`)
)
View Source
var (
	// ValidACName is a regular expression that defines a valid ACName
	ValidACName = regexp.MustCompile("^[a-z0-9]+([-][a-z0-9]+)*$")

	ErrEmptyACName         = ACNameError("ACName cannot be empty")
	ErrInvalidEdgeInACName = ACNameError("ACName must start and end with only lower case " +
		"alphanumeric characters")
	ErrInvalidCharInACName = ACNameError("ACName must contain only lower case " +
		`alphanumeric characters plus "-"`)
)
View Source
var (
	ErrDefaultTrue     = errors.New("default must be false")
	ErrDefaultRequired = errors.New("default must be true")
	ErrRequestNonEmpty = errors.New("request not supported by this resource, must be empty")

	ResourceIsolatorNames = make(map[ACIdentifier]struct{})
)
View Source
var (
	ErrNoZeroSemVer = ACVersionError("SemVer cannot be zero")
	ErrBadSemVer    = ACVersionError("SemVer is bad")
)
View Source
var (
	ErrNoACKind = ACKindError("ACKind must be set")
)
View Source
var (
	ErrNoEmptyUUID = errors.New("UUID cannot be empty")
)
View Source
var LinuxIsolatorNames = make(map[ACIdentifier]struct{})
View Source
var ValidOSArch = map[string][]string{
	"linux":   {"amd64", "i386", "aarch64", "aarch64_be", "armv6l", "armv7l", "armv7b"},
	"freebsd": {"amd64", "i386", "arm"},
	"darwin":  {"x86_64", "i386"},
}

Functions

func AddIsolatorName added in v1.1.0

func AddIsolatorName(n ACIdentifier, ns map[ACIdentifier]struct{})

func AddIsolatorValueConstructor

func AddIsolatorValueConstructor(n ACIdentifier, i IsolatorValueConstructor)

func IsValidOSArch added in v1.1.0

func IsValidOSArch(labels map[ACIdentifier]string, validOSArch map[string][]string) error

IsValidOsArch checks if a OS-architecture combination is valid given a map of valid OS-architectures

func SanitizeACIdentifier added in v1.1.0

func SanitizeACIdentifier(s string) (string, error)

SanitizeACIdentifier replaces every invalid ACIdentifier character in s with an underscore making it a legal ACIdentifier string. If the character is an upper case letter it replaces it with its lower case. It also removes illegal edge characters (hyphens, period, underscore, tilde and slash).

This is a helper function and its algorithm is not part of the spec. It should not be called without the user explicitly asking for a suggestion.

func SanitizeACName

func SanitizeACName(s string) (string, error)

SanitizeACName replaces every invalid ACName character in s with a dash making it a legal ACName string. If the character is an upper case letter it replaces it with its lower case. It also removes illegal edge characters (hyphens).

This is a helper function and its algorithm is not part of the spec. It should not be called without the user explicitly asking for a suggestion.

func ShortHash

func ShortHash(hash string) string

Types

type ACIdentifier added in v1.1.0

type ACIdentifier string

ACIdentifier (an App-Container Identifier) is a format used by keys in image names and image labels of the App Container Standard. An ACIdentifier is restricted to numeric and lowercase URI unreserved characters defined in URI RFC[1]; all alphabetical characters must be lowercase only. Furthermore, the first and last character ("edges") must be alphanumeric, and an ACIdentifier cannot be empty. Programmatically, an ACIdentifier must conform to the regular expression ValidACIdentifier.

[1] http://tools.ietf.org/html/rfc3986#section-2.3

func MustACIdentifier added in v1.1.0

func MustACIdentifier(s string) *ACIdentifier

MustACIdentifier generates a new ACIdentifier from a string, If the given string is not a valid ACIdentifier, it panics.

func NewACIdentifier added in v1.1.0

func NewACIdentifier(s string) (*ACIdentifier, error)

NewACIdentifier generates a new ACIdentifier from a string. If the given string is not a valid ACIdentifier, nil and an error are returned.

func (ACIdentifier) Empty added in v1.1.0

func (n ACIdentifier) Empty() bool

Empty returns a boolean indicating whether this ACIdentifier is empty.

func (ACIdentifier) Equals added in v1.1.0

func (n ACIdentifier) Equals(o ACIdentifier) bool

Equals checks whether a given ACIdentifier is equal to this one.

func (ACIdentifier) MarshalJSON added in v1.1.0

func (n ACIdentifier) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface

func (*ACIdentifier) Set added in v1.1.0

func (n *ACIdentifier) Set(s string) error

Set sets the ACIdentifier to the given value, if it is valid; if not, an error is returned.

func (ACIdentifier) String added in v1.1.0

func (n ACIdentifier) String() string

func (*ACIdentifier) UnmarshalJSON added in v1.1.0

func (n *ACIdentifier) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface

type ACIdentifierError added in v1.1.0

type ACIdentifierError string

An ACIdentifierError is returned when a bad value is used for an ACIdentifier

func (ACIdentifierError) Error added in v1.1.0

func (e ACIdentifierError) Error() string

type ACKind

type ACKind string

ACKind wraps a string to define a field which must be set with one of several ACKind values. If it is unset, or has an invalid value, the field will refuse to marshal/unmarshal.

func (ACKind) MarshalJSON

func (a ACKind) MarshalJSON() ([]byte, error)

func (ACKind) String

func (a ACKind) String() string

func (*ACKind) UnmarshalJSON

func (a *ACKind) UnmarshalJSON(data []byte) error

type ACKindError

type ACKindError string

An ACKindError is returned when the wrong ACKind is set in a manifest

func InvalidACKindError

func InvalidACKindError(kind ACKind) ACKindError

func (ACKindError) Error

func (e ACKindError) Error() string

type ACName

type ACName string

ACName (an App-Container Name) is a format used by keys in different formats of the App Container Standard. An ACName is restricted to numeric and lowercase characters accepted by the DNS RFC[1] plus "-"; all alphabetical characters must be lowercase only. Furthermore, the first and last character ("edges") must be alphanumeric, and an ACName cannot be empty. Programmatically, an ACName must conform to the regular expression ValidACName.

[1] http://tools.ietf.org/html/rfc1123#page-13

func MustACName

func MustACName(s string) *ACName

MustACName generates a new ACName from a string, If the given string is not a valid ACName, it panics.

func NewACName

func NewACName(s string) (*ACName, error)

NewACName generates a new ACName from a string. If the given string is not a valid ACName, nil and an error are returned.

func (ACName) Empty

func (n ACName) Empty() bool

Empty returns a boolean indicating whether this ACName is empty.

func (ACName) Equals

func (n ACName) Equals(o ACName) bool

Equals checks whether a given ACName is equal to this one.

func (ACName) MarshalJSON

func (n ACName) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface

func (*ACName) Set

func (n *ACName) Set(s string) error

Set sets the ACName to the given value, if it is valid; if not, an error is returned.

func (ACName) String

func (n ACName) String() string

func (*ACName) UnmarshalJSON

func (n *ACName) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface

type ACNameError

type ACNameError string

An ACNameError is returned when a bad value is used for an ACName

func (ACNameError) Error

func (e ACNameError) Error() string

type ACVersionError

type ACVersionError string

An ACVersionError is returned when a bad ACVersion is set in a manifest

func (ACVersionError) Error

func (e ACVersionError) Error() string

type Annotation

type Annotation struct {
	Name  ACIdentifier `json:"name"`
	Value string       `json:"value"`
}

type Annotations

type Annotations []Annotation

func (Annotations) Get

func (a Annotations) Get(name string) (val string, ok bool)

Retrieve the value of an annotation by the given name from Annotations, if it exists.

func (Annotations) MarshalJSON

func (a Annotations) MarshalJSON() ([]byte, error)

func (*Annotations) Set

func (a *Annotations) Set(name ACIdentifier, value string)

Set sets the value of an annotation by the given name, overwriting if one already exists.

func (*Annotations) UnmarshalJSON

func (a *Annotations) UnmarshalJSON(data []byte) error

type App

type App struct {
	Exec             Exec           `json:"exec"`
	EventHandlers    []EventHandler `json:"eventHandlers,omitempty"`
	User             string         `json:"user"`
	Group            string         `json:"group"`
	WorkingDirectory string         `json:"workingDirectory,omitempty"`
	Environment      Environment    `json:"environment,omitempty"`
	MountPoints      []MountPoint   `json:"mountPoints,omitempty"`
	Ports            []Port         `json:"ports,omitempty"`
	Isolators        Isolators      `json:"isolators,omitempty"`
}

func (App) MarshalJSON

func (a App) MarshalJSON() ([]byte, error)

func (*App) UnmarshalJSON

func (a *App) UnmarshalJSON(data []byte) error

type Date

type Date time.Time

Date wraps time.Time to marshal/unmarshal to/from JSON strings in strict accordance with RFC3339 TODO(jonboulle): golang's implementation seems slightly buggy here; according to http://tools.ietf.org/html/rfc3339#section-5.6 , applications may choose to separate the date and time with a space instead of a T character (for example, `date --rfc-3339` on GNU coreutils) - but this is considered an error by go's parser. File a bug?

func NewDate

func NewDate(s string) (*Date, error)

func (Date) MarshalJSON

func (d Date) MarshalJSON() ([]byte, error)

func (Date) String

func (d Date) String() string

func (*Date) UnmarshalJSON

func (d *Date) UnmarshalJSON(data []byte) error

type Dependencies

type Dependencies []Dependency

type Dependency

type Dependency struct {
	ImageName ACIdentifier `json:"imageName"`
	ImageID   *Hash        `json:"imageID,omitempty"`
	Labels    Labels       `json:"labels,omitempty"`
	Size      uint         `json:"size,omitempty"`
}

func (Dependency) MarshalJSON

func (d Dependency) MarshalJSON() ([]byte, error)

func (*Dependency) UnmarshalJSON

func (d *Dependency) UnmarshalJSON(data []byte) error

type Environment

type Environment []EnvironmentVariable

func (Environment) Get

func (e Environment) Get(name string) (value string, ok bool)

Retrieve the value of an environment variable by the given name from Environment, if it exists.

func (Environment) MarshalJSON

func (e Environment) MarshalJSON() ([]byte, error)

func (*Environment) Set

func (e *Environment) Set(name string, value string)

Set sets the value of an environment variable by the given name, overwriting if one already exists.

func (*Environment) UnmarshalJSON

func (e *Environment) UnmarshalJSON(data []byte) error

type EnvironmentVariable

type EnvironmentVariable struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

type EventHandler

type EventHandler struct {
	Name string `json:"name"`
	Exec Exec   `json:"exec"`
}

func (EventHandler) MarshalJSON

func (e EventHandler) MarshalJSON() ([]byte, error)

func (*EventHandler) UnmarshalJSON

func (e *EventHandler) UnmarshalJSON(data []byte) error

type Exec

type Exec []string

func (Exec) MarshalJSON

func (e Exec) MarshalJSON() ([]byte, error)

func (*Exec) UnmarshalJSON

func (e *Exec) UnmarshalJSON(data []byte) error

type ExposedPort

type ExposedPort struct {
	Name     ACName `json:"name"`
	HostPort uint   `json:"hostPort"`
}

type Hash

type Hash struct {
	Val string
	// contains filtered or unexported fields
}

Hash encodes a hash specified in a string of the form:

"<type>-<value>"

for example

"sha512-06c733b1838136838e6d2d3e8fa5aea4c7905e92[...]"

Valid types are currently:

  • sha512

func NewHash

func NewHash(s string) (*Hash, error)

func NewHashSHA512

func NewHashSHA512(b []byte) *Hash

func (Hash) Empty

func (h Hash) Empty() bool

func (Hash) MarshalJSON

func (h Hash) MarshalJSON() ([]byte, error)

func (*Hash) Set

func (h *Hash) Set(s string) error

func (Hash) String

func (h Hash) String() string

func (*Hash) UnmarshalJSON

func (h *Hash) UnmarshalJSON(data []byte) error

type Isolator

type Isolator struct {
	Name     ACIdentifier     `json:"name"`
	ValueRaw *json.RawMessage `json:"value"`
	// contains filtered or unexported fields
}

func (*Isolator) UnmarshalJSON

func (i *Isolator) UnmarshalJSON(b []byte) error

func (*Isolator) Value

func (i *Isolator) Value() IsolatorValue

type IsolatorValue

type IsolatorValue interface {
	UnmarshalJSON(b []byte) error
	AssertValid() error
}

func NewLinuxCapabilitiesRetainSet

func NewLinuxCapabilitiesRetainSet() IsolatorValue

func NewLinuxCapabilitiesRevokeSet

func NewLinuxCapabilitiesRevokeSet() IsolatorValue

func NewResourceBlockBandwidth

func NewResourceBlockBandwidth() IsolatorValue

func NewResourceBlockIOPS

func NewResourceBlockIOPS() IsolatorValue

func NewResourceCPU

func NewResourceCPU() IsolatorValue

func NewResourceMemory

func NewResourceMemory() IsolatorValue

func NewResourceNetworkBandwidth

func NewResourceNetworkBandwidth() IsolatorValue

type IsolatorValueConstructor

type IsolatorValueConstructor func() IsolatorValue

type Isolators

type Isolators []Isolator

func (*Isolators) GetByName

func (is *Isolators) GetByName(name ACIdentifier) *Isolator

GetByName returns the last isolator in the list by the given name.

func (*Isolators) Unrecognized

func (is *Isolators) Unrecognized() Isolators

Unrecognized returns a set of isolators that are not recognized. An isolator is not recognized if it has not had an associated constructor registered with AddIsolatorValueConstructor.

type Label

type Label struct {
	Name  ACIdentifier `json:"name"`
	Value string       `json:"value"`
}

type Labels

type Labels []Label

func LabelsFromMap

func LabelsFromMap(labelsMap map[ACIdentifier]string) (Labels, error)

LabelsFromMap creates Labels from a map[ACIdentifier]string

func (Labels) Get

func (l Labels) Get(name string) (val string, ok bool)

Get retrieves the value of the label by the given name from Labels, if it exists

func (Labels) MarshalJSON

func (l Labels) MarshalJSON() ([]byte, error)

func (Labels) ToMap

func (l Labels) ToMap() map[ACIdentifier]string

ToMap creates a map[ACIdentifier]string.

func (*Labels) UnmarshalJSON

func (l *Labels) UnmarshalJSON(data []byte) error

type LinuxCapabilitiesRetainSet

type LinuxCapabilitiesRetainSet struct {
	// contains filtered or unexported fields
}

func (LinuxCapabilitiesRetainSet) AssertValid

func (l LinuxCapabilitiesRetainSet) AssertValid() error

func (LinuxCapabilitiesRetainSet) Set

func (l LinuxCapabilitiesRetainSet) Set() []LinuxCapability

func (*LinuxCapabilitiesRetainSet) UnmarshalJSON

func (l *LinuxCapabilitiesRetainSet) UnmarshalJSON(b []byte) error

type LinuxCapabilitiesRevokeSet

type LinuxCapabilitiesRevokeSet struct {
	// contains filtered or unexported fields
}

func (LinuxCapabilitiesRevokeSet) AssertValid

func (l LinuxCapabilitiesRevokeSet) AssertValid() error

func (LinuxCapabilitiesRevokeSet) Set

func (l LinuxCapabilitiesRevokeSet) Set() []LinuxCapability

func (*LinuxCapabilitiesRevokeSet) UnmarshalJSON

func (l *LinuxCapabilitiesRevokeSet) UnmarshalJSON(b []byte) error

type LinuxCapabilitiesSet

type LinuxCapabilitiesSet interface {
	Set() []LinuxCapability
	AssertValid() error
}

type LinuxCapability

type LinuxCapability string

type MountPoint

type MountPoint struct {
	Name     ACName `json:"name"`
	Path     string `json:"path"`
	ReadOnly bool   `json:"readOnly,omitempty"`
}

func MountPointFromString

func MountPointFromString(mp string) (*MountPoint, error)

MountPointFromString takes a command line mountpoint parameter and returns a mountpoint

It is useful for actool patch-manifest --mounts

Example mountpoint parameters:

database,path=/tmp,readOnly=true

type Port

type Port struct {
	Name            ACName `json:"name"`
	Protocol        string `json:"protocol"`
	Port            uint   `json:"port"`
	Count           uint   `json:"count"`
	SocketActivated bool   `json:"socketActivated"`
}

func PortFromString added in v1.1.0

func PortFromString(pt string) (*Port, error)

PortFromString takes a command line port parameter and returns a port

It is useful for actool patch-manifest --ports

Example port parameters:

     health-check,protocol=udp,port=8000
	query,protocol=tcp,port=8080,count=1,socketActivated=true

func (Port) MarshalJSON added in v1.1.0

func (p Port) MarshalJSON() ([]byte, error)

func (*Port) UnmarshalJSON added in v1.1.0

func (p *Port) UnmarshalJSON(data []byte) error

type Resource

type Resource interface {
	Limit() *resource.Quantity
	Request() *resource.Quantity
	Default() bool
}

type ResourceBase

type ResourceBase struct {
	// contains filtered or unexported fields
}

func (ResourceBase) AssertValid

func (r ResourceBase) AssertValid() error

func (ResourceBase) Default

func (r ResourceBase) Default() bool

func (ResourceBase) Limit

func (r ResourceBase) Limit() *resource.Quantity

func (ResourceBase) Request

func (r ResourceBase) Request() *resource.Quantity

func (*ResourceBase) UnmarshalJSON

func (r *ResourceBase) UnmarshalJSON(b []byte) error

type ResourceBlockBandwidth

type ResourceBlockBandwidth struct {
	ResourceBase
}

func (ResourceBlockBandwidth) AssertValid

func (r ResourceBlockBandwidth) AssertValid() error

type ResourceBlockIOPS

type ResourceBlockIOPS struct {
	ResourceBase
}

func (ResourceBlockIOPS) AssertValid

func (r ResourceBlockIOPS) AssertValid() error

type ResourceCPU

type ResourceCPU struct {
	ResourceBase
}

func (ResourceCPU) AssertValid

func (r ResourceCPU) AssertValid() error

type ResourceMemory

type ResourceMemory struct {
	ResourceBase
}

func (ResourceMemory) AssertValid

func (r ResourceMemory) AssertValid() error

type ResourceNetworkBandwidth

type ResourceNetworkBandwidth struct {
	ResourceBase
}

func (ResourceNetworkBandwidth) AssertValid

func (r ResourceNetworkBandwidth) AssertValid() error

type SemVer

type SemVer semver.Version

SemVer implements the Unmarshaler interface to define a field that must be a semantic version string TODO(jonboulle): extend upstream instead of wrapping?

func NewSemVer

func NewSemVer(s string) (*SemVer, error)

NewSemVer generates a new SemVer from a string. If the given string does not represent a valid SemVer, nil and an error are returned.

func (SemVer) Empty

func (sv SemVer) Empty() bool

func (SemVer) MarshalJSON

func (sv SemVer) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface

func (SemVer) String

func (sv SemVer) String() string

func (*SemVer) UnmarshalJSON

func (sv *SemVer) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface

type URL

type URL url.URL

URL wraps url.URL to marshal/unmarshal to/from JSON strings and enforce that the scheme is HTTP/HTTPS only

func NewURL

func NewURL(s string) (*URL, error)

func (URL) MarshalJSON

func (u URL) MarshalJSON() ([]byte, error)

func (URL) String

func (u URL) String() string

func (*URL) UnmarshalJSON

func (u *URL) UnmarshalJSON(data []byte) error

type UUID

type UUID [16]byte

UUID encodes an RFC4122-compliant UUID, marshaled to/from a string TODO(jonboulle): vendor a package for this? TODO(jonboulle): consider more flexibility in input string formats. Right now, we only accept:

"6733C088-A507-4694-AABF-EDBE4FC5266F"
"6733C088A5074694AABFEDBE4FC5266F"

func NewUUID

func NewUUID(s string) (*UUID, error)

NewUUID generates a new UUID from the given string. If the string does not represent a valid UUID, nil and an error are returned.

func (UUID) Empty

func (u UUID) Empty() bool

func (UUID) MarshalJSON

func (u UUID) MarshalJSON() ([]byte, error)

func (*UUID) Set

func (u *UUID) Set(s string) error

func (UUID) String

func (u UUID) String() string

func (*UUID) UnmarshalJSON

func (u *UUID) UnmarshalJSON(data []byte) error

type Volume

type Volume struct {
	Name ACName `json:"name"`
	Kind string `json:"kind"`

	// currently used only by "host"
	// TODO(jonboulle): factor out?
	Source   string `json:"source,omitempty"`
	ReadOnly *bool  `json:"readOnly,omitempty"`
}

Volume encapsulates a volume which should be mounted into the filesystem of all apps in a PodManifest

func VolumeFromString

func VolumeFromString(vp string) (*Volume, error)

VolumeFromString takes a command line volume parameter and returns a volume

Example volume parameters:

database,kind=host,source=/tmp,readOnly=true

func (Volume) MarshalJSON

func (v Volume) MarshalJSON() ([]byte, error)

func (Volume) String

func (v Volume) String() string

func (*Volume) UnmarshalJSON

func (v *Volume) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

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