deployments

package
v0.0.0-...-0557d4e Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2018 License: Apache-2.0, Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DeviceDeploymentStatusDownloading    = "downloading"
	DeviceDeploymentStatusInstalling     = "installing"
	DeviceDeploymentStatusRebooting      = "rebooting"
	DeviceDeploymentStatusPending        = "pending"
	DeviceDeploymentStatusSuccess        = "success"
	DeviceDeploymentStatusFailure        = "failure"
	DeviceDeploymentStatusNoArtifact     = "noartifact"
	DeviceDeploymentStatusAlreadyInst    = "already-installed"
	DeviceDeploymentStatusAborted        = "aborted"
	DeviceDeploymentStatusDecommissioned = "decommissioned"
)

Deployment statuses

Variables

View Source
var (
	ErrInvalidDeploymentLog = errors.New("invalid deployment log")
	ErrInvalidLogMessage    = errors.New("invalid log message")
)
View Source
var (
	ErrInvalidDeviceID = errors.New("Invalid device ID")
)

Errors

Functions

func ActiveDeploymentStatuses

func ActiveDeploymentStatuses() []string

ActiveDeploymentStatuses lists statuses that represent deployment in active state (not finished).

func IsDeviceDeploymentStatusFinished

func IsDeviceDeploymentStatusFinished(status string) bool

Types

type ArtifactDeploymentInstructions

type ArtifactDeploymentInstructions struct {
	ArtifactName          string      `json:"artifact_name"`
	Source                images.Link `json:"source"`
	DeviceTypesCompatible []string    `json:"device_types_compatible"`
}

type Deployment

type Deployment struct {
	// User provided field set
	*DeploymentConstructor `valid:"required"`

	// Auto set on create, required
	Created *time.Time `json:"created" valid:"required"`

	// Finished deplyment time
	Finished *time.Time `json:"finished,omitempty" valid:"optional"`

	// Deployment id, required
	Id *string `json:"id" bson:"_id" valid:"uuidv4,required"`

	// List of artifact id's targeted for deployments, optional
	Artifacts []string `json:"artifacts,omitempty" bson:"artifacts"`

	// Aggregated device status counters.
	// Initialized with the "pending" counter set to total device count for deployment.
	// Individual counter incremented/decremented according to device status updates.
	Stats map[string]int `json:"-"`

	// Total number of devices targeted
	DeviceCount int `json:"device_count" bson:"-"`
}

func NewDeployment

func NewDeployment() *Deployment

NewDeployment creates new deployment object, sets create data by default.

func NewDeploymentFromConstructor

func NewDeploymentFromConstructor(constructor *DeploymentConstructor) *Deployment

NewDeploymentFromConstructor creates new Deployments object based on constructor data

func (*Deployment) GetStatus

func (d *Deployment) GetStatus() string

func (*Deployment) IsAborted

func (d *Deployment) IsAborted() bool

func (*Deployment) IsFinished

func (d *Deployment) IsFinished() bool

func (*Deployment) IsInProgress

func (d *Deployment) IsInProgress() bool

func (*Deployment) IsPending

func (d *Deployment) IsPending() bool

func (*Deployment) MarshalJSON

func (d *Deployment) MarshalJSON() ([]byte, error)

To be able to hide devices field, from API output provice custom marshaler

func (*Deployment) Validate

func (d *Deployment) Validate() error

Validate checkes structure according to valid tags

type DeploymentConstructor

type DeploymentConstructor struct {
	// Deployment name, required
	Name *string `json:"name,omitempty" valid:"length(1|4096),required"`

	// Artifact name to be installed required, associated with image
	ArtifactName *string `json:"artifact_name,omitempty" valid:"length(1|4096),required"`

	// List of device id's targeted for deployments, required
	Devices []string `json:"devices,omitempty" valid:"required" bson:"-"`
}

DeploymentConstructor represent input data needed for creating new Deployment (they differ in fields)

func NewDeploymentConstructor

func NewDeploymentConstructor() *DeploymentConstructor

func (*DeploymentConstructor) Validate

func (c *DeploymentConstructor) Validate() error

Validate checkes structure according to valid tags TODO: Add custom validator to check devices array content (such us UUID formatting)

type DeploymentInstructions

type DeploymentInstructions struct {
	ID       string                         `json:"id"`
	Artifact ArtifactDeploymentInstructions `json:"artifact"`
}

type DeploymentLog

type DeploymentLog struct {
	// skip these 2 field when (un)marshalling to/from JSON
	DeviceID     string `json:"-" valid:"required"`
	DeploymentID string `json:"-" valid:"uuidv4,required"`

	Messages []LogMessage `json:"messages" valid:"required"`
}

func (*DeploymentLog) UnmarshalJSON

func (d *DeploymentLog) UnmarshalJSON(raw []byte) error

func (DeploymentLog) Validate

func (d DeploymentLog) Validate() error

type DeviceDeployment

type DeviceDeployment struct {
	// Internal field of initial creation of deployment
	Created *time.Time `json:"created" valid:"required"`

	// Update finish time
	Finished *time.Time `json:"finished,omitempty" valid:"-"`

	// Status
	Status *string `json:"status" valid:"required"`

	// Device id
	DeviceId *string `json:"id" valid:"required"`

	// Deployment id
	DeploymentId *string `json:"-" valid:"uuidv4,required"`

	// ID
	Id *string `json:"-" bson:"_id" valid:"uuidv4,required"`

	// Assigned software image
	Image *images.SoftwareImage `json:"-" valid:"-"`

	// Target device type
	DeviceType *string `json:"device_type,omitempty" valid:"-"`

	// Presence of deployment log
	IsLogAvailable bool `json:"log" valid:"-" bson:"log"`

	// Device reported substate
	SubState *string `json:"substate,omitempty" valid:"-" bson:"substate"`
}

func NewDeviceDeployment

func NewDeviceDeployment(deviceId, deploymentId string) *DeviceDeployment

func (*DeviceDeployment) Validate

func (d *DeviceDeployment) Validate() error

type DeviceDeploymentStatus

type DeviceDeploymentStatus struct {
	// status reported by device
	Status string `valid:"required"`
	// substate reported by device
	SubState *string
	// finish time
	FinishTime *time.Time
}

DeviceDeploymentStatus is a helper type for reporting status changes through the layers

type InstalledDeviceDeployment

type InstalledDeviceDeployment struct {
	Artifact   string `valid:"required"`
	DeviceType string `valid:"required"`
}

InstalledDeviceDeployment describes a deployment currently installed on the device, usually reported by a device

func (*InstalledDeviceDeployment) Validate

func (i *InstalledDeviceDeployment) Validate() error

type LogMessage

type LogMessage struct {
	Timestamp *time.Time `json:"timestamp" valid:"required"`
	Level     string     `json:"level" valid:"required"`
	Message   string     `json:"message" valid:"required"`
}

func (LogMessage) String

func (l LogMessage) String() string

func (*LogMessage) UnmarshalJSON

func (l *LogMessage) UnmarshalJSON(raw []byte) error

func (LogMessage) Validate

func (l LogMessage) Validate() error

type Query

type Query struct {
	// match deployments by text by looking at deployment name and artifact name
	SearchText string

	// deployment status
	Status StatusQuery
	Limit  int
	Skip   int
	// only return deployments between timestamp range
	CreatedAfter  *time.Time
	CreatedBefore *time.Time
}

Deployment lookup query

type Stats

type Stats map[string]int

Deployment statistics wrapper, each value carries a count of deployments aggregated by state.

func NewDeviceDeploymentStats

func NewDeviceDeploymentStats() Stats

type StatusQuery

type StatusQuery int
const (
	StatusQueryAny StatusQuery = iota
	StatusQueryPending
	StatusQueryInProgress
	StatusQueryFinished
	StatusQueryAborted
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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