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
- Variables
- func AddIsolatorValueConstructor(n ACName, i IsolatorValueConstructor)
- func SanitizeACName(s string) (string, error)
- func ShortHash(hash string) string
- type ACKind
- type ACKindError
- type ACName
- type ACNameError
- type ACVersionError
- type Annotation
- type Annotations
- type App
- type Date
- type Dependencies
- type Dependency
- type Environment
- type EnvironmentVariable
- type EventHandler
- type Exec
- type ExposedPort
- type Hash
- type Isolator
- type IsolatorValue
- func NewLinuxCapabilitiesRetainSet() IsolatorValue
- func NewLinuxCapabilitiesRevokeSet() IsolatorValue
- func NewResourceBlockBandwidth() IsolatorValue
- func NewResourceBlockIOPS() IsolatorValue
- func NewResourceCPU() IsolatorValue
- func NewResourceMemory() IsolatorValue
- func NewResourceNetworkBandwidth() IsolatorValue
- type IsolatorValueConstructor
- type Isolators
- type Label
- type Labels
- type LinuxCapabilitiesRetainSet
- type LinuxCapabilitiesRevokeSet
- type LinuxCapabilitiesSet
- type LinuxCapability
- type MountPoint
- type Port
- type Resource
- type ResourceBase
- type ResourceBlockBandwidth
- type ResourceBlockIOPS
- type ResourceCPU
- type ResourceMemory
- type ResourceNetworkBandwidth
- type SemVer
- type URL
- type UUID
- type Volume
Constants ¶
const ( LinuxCapabilitiesRetainSetName = "os/linux/capabilities-retain-set" LinuxCapabilitiesRevokeSetName = "os/linux/capabilities-remove-set" )
const ( ResourceBlockBandwidthName = "resource/block-bandwidth" ResourceBlockIOPSName = "resource/block-iops" ResourceCPUName = "resource/cpu" ResourceMemoryName = "resource/memory" ResourceNetworkBandwidthName = "resource/network-bandwidth" )
Variables ¶
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") ErrInvalidEdge = ACNameError("ACName must start and end with only lower case " + "alphanumeric characters") ErrInvalidChar = ACNameError("ACName must contain only lower case " + `alphanumeric characters plus ".", "-", "/"`) )
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") )
var ( ErrNoZeroSemVer = ACVersionError("SemVer cannot be zero") ErrBadSemVer = ACVersionError("SemVer is bad") )
var (
ErrNoACKind = ACKindError("ACKind must be set")
)
var (
ErrNoEmptyUUID = errors.New("UUID cannot be empty")
)
var ValidOSArch = map[string][]string{
"linux": {"amd64", "i386", "aarch64", "armv7l", "armv7b"},
"freebsd": {"amd64", "i386", "arm"},
"darwin": {"x86_64", "i386"},
}
Functions ¶
func AddIsolatorValueConstructor ¶ added in v0.4.0
func AddIsolatorValueConstructor(n ACName, i IsolatorValueConstructor)
func SanitizeACName ¶ added in v0.4.0
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, periods and slashes).
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.
Types ¶
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 (*ACKind) UnmarshalJSON ¶
type ACKindError ¶
type ACKindError string
An ACKindError is returned when the wrong ACKind is set in a manifest
func InvalidACKindError ¶ added in v0.4.0
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 characters accepted by the DNS RFC[1] and "/"; 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 ¶ added in v0.5.2
MustACName generates a new ACName from a string, If the given string is not a valid ACName, it panics.
func NewACName ¶
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) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface
func (*ACName) Set ¶ added in v0.2.0
Set sets the ACName to the given value, if it is valid; if not, an error is returned.
func (*ACName) UnmarshalJSON ¶
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 ¶ added in v0.2.0
type Annotations ¶
type Annotations []Annotation
func (Annotations) Get ¶ added in v0.2.0
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 ¶ added in v0.2.0
func (a *Annotations) Set(name ACName, 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 (*App) UnmarshalJSON ¶
type Date ¶
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 (Date) MarshalJSON ¶
func (*Date) UnmarshalJSON ¶
type Dependencies ¶
type Dependencies []Dependency
type Dependency ¶
type Dependency struct { App ACName `json:"app"` ImageID *Hash `json:"imageID,omitempty"` Labels Labels `json:"labels,omitempty"` }
func (Dependency) MarshalJSON ¶
func (d Dependency) MarshalJSON() ([]byte, error)
func (*Dependency) UnmarshalJSON ¶
func (d *Dependency) UnmarshalJSON(data []byte) error
type Environment ¶ added in v0.3.0
type Environment []EnvironmentVariable
func (Environment) Get ¶ added in v0.3.0
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 ¶ added in v0.3.0
func (e Environment) MarshalJSON() ([]byte, error)
func (*Environment) Set ¶ added in v0.3.0
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 ¶ added in v0.3.0
func (e *Environment) UnmarshalJSON(data []byte) error
type EnvironmentVariable ¶ added in v0.3.0
type EventHandler ¶
func (EventHandler) MarshalJSON ¶
func (e EventHandler) MarshalJSON() ([]byte, error)
func (*EventHandler) UnmarshalJSON ¶
func (e *EventHandler) UnmarshalJSON(data []byte) error
type Exec ¶ added in v0.2.0
type Exec []string
func (Exec) MarshalJSON ¶ added in v0.2.0
func (*Exec) UnmarshalJSON ¶ added in v0.2.0
type ExposedPort ¶ added in v0.5.0
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 NewHashSHA512 ¶ added in v0.2.0
func (Hash) MarshalJSON ¶
func (*Hash) UnmarshalJSON ¶
type Isolator ¶
type Isolator struct { Name ACName `json:"name"` ValueRaw *json.RawMessage `json:"value"` // contains filtered or unexported fields }
func (*Isolator) UnmarshalJSON ¶ added in v0.4.0
func (*Isolator) Value ¶ added in v0.4.0
func (i *Isolator) Value() IsolatorValue
type IsolatorValue ¶ added in v0.4.0
func NewLinuxCapabilitiesRetainSet ¶ added in v0.4.0
func NewLinuxCapabilitiesRetainSet() IsolatorValue
func NewLinuxCapabilitiesRevokeSet ¶ added in v0.4.0
func NewLinuxCapabilitiesRevokeSet() IsolatorValue
func NewResourceBlockBandwidth ¶ added in v0.4.0
func NewResourceBlockBandwidth() IsolatorValue
func NewResourceBlockIOPS ¶ added in v0.4.0
func NewResourceBlockIOPS() IsolatorValue
func NewResourceCPU ¶ added in v0.4.0
func NewResourceCPU() IsolatorValue
func NewResourceMemory ¶ added in v0.4.0
func NewResourceMemory() IsolatorValue
func NewResourceNetworkBandwidth ¶ added in v0.4.0
func NewResourceNetworkBandwidth() IsolatorValue
type IsolatorValueConstructor ¶ added in v0.4.0
type IsolatorValueConstructor func() IsolatorValue
type Isolators ¶ added in v0.4.0
type Isolators []Isolator
func (*Isolators) GetByName ¶ added in v0.4.0
GetByName returns the last isolator in the list by the given name.
func (*Isolators) Unrecognized ¶ added in v0.4.1
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 Labels ¶
type Labels []Label
func LabelsFromMap ¶ added in v0.5.1
LabelsFromMap creates Labels from a map[ACName]string
func (Labels) Get ¶ added in v0.2.0
Get retrieves the value of the label by the given name from Labels, if it exists
func (Labels) MarshalJSON ¶
func (*Labels) UnmarshalJSON ¶
type LinuxCapabilitiesRetainSet ¶ added in v0.4.0
type LinuxCapabilitiesRetainSet struct {
// contains filtered or unexported fields
}
func (LinuxCapabilitiesRetainSet) AssertValid ¶ added in v0.4.0
func (l LinuxCapabilitiesRetainSet) AssertValid() error
func (LinuxCapabilitiesRetainSet) Set ¶ added in v0.4.0
func (l LinuxCapabilitiesRetainSet) Set() []LinuxCapability
func (*LinuxCapabilitiesRetainSet) UnmarshalJSON ¶ added in v0.4.0
type LinuxCapabilitiesRevokeSet ¶ added in v0.4.0
type LinuxCapabilitiesRevokeSet struct {
// contains filtered or unexported fields
}
func (LinuxCapabilitiesRevokeSet) AssertValid ¶ added in v0.4.0
func (l LinuxCapabilitiesRevokeSet) AssertValid() error
func (LinuxCapabilitiesRevokeSet) Set ¶ added in v0.4.0
func (l LinuxCapabilitiesRevokeSet) Set() []LinuxCapability
func (*LinuxCapabilitiesRevokeSet) UnmarshalJSON ¶ added in v0.4.0
type LinuxCapabilitiesSet ¶ added in v0.4.0
type LinuxCapabilitiesSet interface { Set() []LinuxCapability AssertValid() error }
type LinuxCapability ¶ added in v0.4.0
type LinuxCapability string
type MountPoint ¶
type MountPoint struct { Name ACName `json:"name"` Path string `json:"path"` ReadOnly bool `json:"readOnly,omitempty"` }
func MountPointFromString ¶ added in v0.5.2
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 (Port) MarshalJSON ¶ added in v0.5.2
func (*Port) UnmarshalJSON ¶ added in v0.5.2
type ResourceBase ¶ added in v0.4.0
type ResourceBase struct {
// contains filtered or unexported fields
}
func (ResourceBase) AssertValid ¶ added in v0.4.0
func (r ResourceBase) AssertValid() error
func (ResourceBase) Default ¶ added in v0.4.0
func (r ResourceBase) Default() bool
func (ResourceBase) Limit ¶ added in v0.4.0
func (r ResourceBase) Limit() *resource.Quantity
func (ResourceBase) Request ¶ added in v0.4.0
func (r ResourceBase) Request() *resource.Quantity
func (*ResourceBase) UnmarshalJSON ¶ added in v0.4.0
func (r *ResourceBase) UnmarshalJSON(b []byte) error
type ResourceBlockBandwidth ¶ added in v0.4.0
type ResourceBlockBandwidth struct {
ResourceBase
}
func (ResourceBlockBandwidth) AssertValid ¶ added in v0.4.0
func (r ResourceBlockBandwidth) AssertValid() error
type ResourceBlockIOPS ¶ added in v0.4.0
type ResourceBlockIOPS struct {
ResourceBase
}
func (ResourceBlockIOPS) AssertValid ¶ added in v0.4.0
func (r ResourceBlockIOPS) AssertValid() error
type ResourceCPU ¶ added in v0.4.0
type ResourceCPU struct {
ResourceBase
}
func (ResourceCPU) AssertValid ¶ added in v0.4.0
func (r ResourceCPU) AssertValid() error
type ResourceMemory ¶ added in v0.4.0
type ResourceMemory struct {
ResourceBase
}
func (ResourceMemory) AssertValid ¶ added in v0.4.0
func (r ResourceMemory) AssertValid() error
type ResourceNetworkBandwidth ¶ added in v0.4.0
type ResourceNetworkBandwidth struct {
ResourceBase
}
func (ResourceNetworkBandwidth) AssertValid ¶ added in v0.4.0
func (r ResourceNetworkBandwidth) AssertValid() error
type SemVer ¶
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 ¶
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) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface
func (*SemVer) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface
type URL ¶
URL wraps url.URL to marshal/unmarshal to/from JSON strings and enforce that the scheme is HTTP/HTTPS only
func (URL) MarshalJSON ¶
func (*URL) UnmarshalJSON ¶
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 ¶
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) MarshalJSON ¶
func (*UUID) UnmarshalJSON ¶
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 ¶ added in v0.3.0
VolumeFromString takes a command line volume parameter and returns a volume
Example volume parameters:
database,kind=host,source=/tmp,readOnly=true