allocation

package
v0.0.0-...-3a937ec Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2018 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultPodPrefix = "pod-*"
View Source
const (
	ResourceValuesPostfix = "__values"
)
View Source
const (
	SpecRevision = "1.0"
)

Variables

This section is empty.

Functions

func DefaultDbusDiscoveryFunc

func DefaultDbusDiscoveryFunc() (res []string, err error)

func GetZeroDiscoveryFunc

func GetZeroDiscoveryFunc(paths ...string) func() ([]string, error)

func IsBlocked

func IsBlocked(left, right *Pod) (err error)

Returns true if right allocation is blocked by left allocation.

func IsEqual

func IsEqual(left, right *Pod) (ok bool)

Returns true if both allocations are is equal or <nil>

func ToString

func ToString(p *Pod) (res string)

Types

type Asset

type Asset interface {
	UnmarshalSpec(line string, spec Spec, paths SystemPaths) (err error)
	MarshalSpec(w io.Writer) (err error)
}

Asset entity can recover own state

type AssetSlice

type AssetSlice interface {
	GetVersionPrefix(version string) (prefix string)
	GetEmpty(paths SystemPaths) (empty Asset)
	AppendItem(v Asset)
}

Slice of recoverable entities

type Blob

type Blob struct {
	Name        string
	Permissions int    `json:",omitempty"`
	Leave       bool   `json:",omitempty"`
	Source      string `json:"-"`
}

func (*Blob) MarshalSpec

func (b *Blob) MarshalSpec(w io.Writer) (err error)

func (*Blob) UnmarshalSpec

func (b *Blob) UnmarshalSpec(line string, spec Spec, paths SystemPaths) (err error)

Unmarshal blob item from manifest. Line may be in two revisions:

func (*Blob) Write

func (b *Blob) Write() (err error)

type BlobSlice

type BlobSlice []*Blob

func (*BlobSlice) AppendItem

func (s *BlobSlice) AppendItem(v Asset)

func (*BlobSlice) GetEmpty

func (s *BlobSlice) GetEmpty(paths SystemPaths) (empty Asset)

func (*BlobSlice) GetVersionPrefix

func (s *BlobSlice) GetVersionPrefix(v string) (p string)
type Header struct {
	Name      string
	PodMark   uint64
	AgentMark uint64
	Namespace string
}

func (*Header) Mark

func (h *Header) Mark() (res uint64)

func (*Header) MarshalSpec

func (h *Header) MarshalSpec(w io.Writer) (err error)

func (*Header) UnmarshalSpec

func (h *Header) UnmarshalSpec(src string, spec Spec, paths SystemPaths) (err error)

type Pod

type Pod struct {
	Header
	UnitFile
	Units     UnitSlice
	Blobs     BlobSlice
	Resources ResourceSlice
	Providers ProviderSlice
}

Pod represents pod allocated on agent

func (*Pod) FromFilesystem

func (p *Pod) FromFilesystem(path string) (err error)

func (*Pod) FromManifest

func (p *Pod) FromManifest(m *manifest.Pod, env map[string]string) (err error)

func (*Pod) GetPodUnit

func (p *Pod) GetPodUnit() (res *Unit)

type PodSlice

type PodSlice []*Pod

Allocations state

func (*PodSlice) FromFilesystem

func (s *PodSlice) FromFilesystem(systemPaths SystemPaths, discoveryFunc func() ([]string, error)) (err error)

type Provider

type Provider manifest.Provider

func (*Provider) Clone

func (p *Provider) Clone() (res *Provider)

func (*Provider) GetID

func (p *Provider) GetID(parent ...string) string

func (*Provider) MarshalSpec

func (p *Provider) MarshalSpec(w io.Writer) (err error)

func (*Provider) UnmarshalSpec

func (p *Provider) UnmarshalSpec(line string, spec Spec, paths SystemPaths) (err error)

Restore state from header line

type ProviderSlice

type ProviderSlice []*Provider

Allocation providers

func (*ProviderSlice) AppendItem

func (s *ProviderSlice) AppendItem(v Asset)

func (*ProviderSlice) FromManifest

func (s *ProviderSlice) FromManifest(pod manifest.Pod, env manifest.FlatMap) (err error)

func (*ProviderSlice) GetEmpty

func (s *ProviderSlice) GetEmpty(paths SystemPaths) (empty Asset)

func (*ProviderSlice) GetVersionPrefix

func (s *ProviderSlice) GetVersionPrefix(v string) (p string)

type Resource

type Resource struct {
	// Requested resource
	Request manifest.Resource

	// Allocated values stored in "resource.pod-name.<provider-name>.<resource-name>.__values" environment
	Values manifest.FlatMap `json:",omitempty"`
}

Allocated resource

func (*Resource) Clone

func (r *Resource) Clone() (res *Resource)

func (*Resource) FromManifest

func (r *Resource) FromManifest(podName string, req manifest.Resource, env manifest.FlatMap) (err error)

Unmarshal resource allocation from manifest

func (*Resource) MarshalSpec

func (r *Resource) MarshalSpec(w io.Writer) (err error)

Marshal resource line

func (Resource) String

func (r Resource) String() string

func (*Resource) UnmarshalSpec

func (r *Resource) UnmarshalSpec(line string, spec Spec, paths SystemPaths) (err error)

func (*Resource) ValuesKey

func (r *Resource) ValuesKey() (res string)

Returns values bag key without provider

type ResourceSlice

type ResourceSlice []*Resource

Allocation resources

func (*ResourceSlice) AppendItem

func (r *ResourceSlice) AppendItem(v Asset)

func (*ResourceSlice) FromManifest

func (r *ResourceSlice) FromManifest(m manifest.Pod, env manifest.FlatMap) (err error)

func (*ResourceSlice) GetEmpty

func (s *ResourceSlice) GetEmpty(paths SystemPaths) (empty Asset)

func (*ResourceSlice) GetVersionPrefix

func (s *ResourceSlice) GetVersionPrefix(v string) (p string)

type Spec

type Spec struct {
	Revision string
}

func (*Spec) Marshal

func (s *Spec) Marshal(w io.Writer) (err error)

func (*Spec) Unmarshal

func (s *Spec) Unmarshal(src string) (err error)

func (Spec) UnmarshalAssetSlice

func (s Spec) UnmarshalAssetSlice(paths SystemPaths, v AssetSlice, source string) (err error)

type SystemPaths

type SystemPaths struct {
	Local   string
	Runtime string
}

func DefaultSystemPaths

func DefaultSystemPaths() SystemPaths

type Unit

type Unit struct {
	UnitFile
	manifest.Transition `json:",squash"`
}

func (*Unit) MarshalSpec

func (u *Unit) MarshalSpec(w io.Writer) (err error)

func (*Unit) UnmarshalSpec

func (u *Unit) UnmarshalSpec(line string, spec Spec, paths SystemPaths) (err error)

UnmarshalSpec parses one line from manifest

type UnitFile

type UnitFile struct {
	SystemPaths SystemPaths `json:"-"`
	Path        string
	Source      string `json:"-"`
}

func NewUnitFile

func NewUnitFile(unitName string, paths SystemPaths, runtime bool) (f UnitFile)

func (*UnitFile) IsRuntime

func (f *UnitFile) IsRuntime() (res bool)

func (*UnitFile) Read

func (f *UnitFile) Read() (err error)

func (*UnitFile) UnitName

func (f *UnitFile) UnitName() (res string)

func (*UnitFile) Write

func (f *UnitFile) Write() (err error)

type UnitSlice

type UnitSlice []*Unit

func (*UnitSlice) AppendItem

func (s *UnitSlice) AppendItem(v Asset)

func (*UnitSlice) GetEmpty

func (s *UnitSlice) GetEmpty(paths SystemPaths) (empty Asset)

func (*UnitSlice) GetVersionPrefix

func (s *UnitSlice) GetVersionPrefix(v string) (p string)

Jump to

Keyboard shortcuts

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