Documentation ¶
Index ¶
- Constants
- Variables
- func Deploy(events chan<- Event, locator *locator.Locator)
- func Layered(services map[string]*config.Service) ([][]*config.Service, error)
- type Deployment
- func (d *Deployment) Add(key, label string, value any)
- func (d *Deployment) All() map[string][]LabeledValue
- func (d *Deployment) Deploy(ctx context.Context, events chan<- Event, service *config.Service) error
- func (d *Deployment) EnsureContainerIsRunning(ctx context.Context, containerID string) error
- func (d *Deployment) Find(key, label string) (any, error)
- func (d *Deployment) Get(key string) ([]LabeledValue, error)
- func (d *Deployment) ID() string
- func (d *Deployment) MarshalJSON() ([]byte, error)
- func (d *Deployment) RunHooks(ctx context.Context, containerID string, commands []string) error
- func (d *Deployment) Time() time.Time
- func (d *Deployment) UnmarshalJSON(data []byte) error
- type Event
- type LabeledValue
- type Node
Constants ¶
const ( ErrorEvent = "Error" FinishEvent = "Finish" )
const ( StartEvent = "StartEvent" StartLayerDeployment = "StartLayerDeployment" PullImage = "PullImage" CreateContainer = "CreateContainer" RunHook = "RunHook" StartContainer = "StartContainer" FinishDeployment = "FinishDeployment" ConnectDependency = "ConnectDependency" AcquireSubnet = "AcquireSubnet" CreateNetwork = "CreateNetwork" )
const Store = datadir.Store("deployments")
Variables ¶
var ( ErrContainerNotRunning = errors.New("container is not running") ErrContainerTimeout = errors.New("container is not running (timeout)") )
var ErrValueNotFound = errors.New("value not found")
Functions ¶
Types ¶
type Deployment ¶
type Deployment struct { Docker *runtime.Client Locator *locator.Locator Bus chan<- Event Resources sync.Map // contains filtered or unexported fields }
Deployment holds the information needed to deploy a service. When updating fields, make sure to also update deploymentJSON accordingly.
func (*Deployment) Add ¶
func (d *Deployment) Add(key, label string, value any)
Add adds a resource to the manifest under a given tag.
func (*Deployment) All ¶
func (d *Deployment) All() map[string][]LabeledValue
func (*Deployment) Deploy ¶
func (d *Deployment) Deploy(ctx context.Context, events chan<- Event, service *config.Service) error
Deploy deploys a service.
func (*Deployment) EnsureContainerIsRunning ¶
func (d *Deployment) EnsureContainerIsRunning(ctx context.Context, containerID string) error
EnsureContainerIsRunning will wait for the container to start and then return an error if the container is not running after either : - 10 seconds if the container has no health-check - Retries * (Interval + Timeout) if the container has a health-check
todo(pipeline): return logs from failed container
func (*Deployment) Get ¶
func (d *Deployment) Get(key string) ([]LabeledValue, error)
Get returns the resources associated with a given tag.
func (*Deployment) ID ¶
func (d *Deployment) ID() string
func (*Deployment) MarshalJSON ¶
func (d *Deployment) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaler interface. It takes care of converting the resource map to a marshalable map.
func (*Deployment) Time ¶
func (d *Deployment) Time() time.Time
Time returns the time the deployment was created. todo: Add a Time property on the deployment manifest rather than using the deployment id that todo: happens to be the creation time.
func (*Deployment) UnmarshalJSON ¶
func (d *Deployment) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaler interface. It takes care of converting the resources map to a sync.Map. Avoid using ints to the map, as they will be converted to float64s. Use strings instead.
type Event ¶
type Event struct { // Service is the name of the service that the event is about. Service *config.Service // ID is an identifier unique to the kind of the event. ID string // Data is the payload of the event. Data any }
type LabeledValue ¶
type Node ¶
type Node struct { // Parent is a node that depends on this node. Parent *Node // Service is the service that this node represents. Service *config.Service // Edges is a list of nodes that this node depends on. Edges []*Node // Depth is the number of edges from the root node to this node. // The root node has a depth of 0. Depth int }
Node contains information about a service and its position in the dependency graph.