Documentation ¶
Index ¶
- Constants
- Variables
- func ActiveDeploymentStatuses() []string
- func IsDeviceDeploymentStatusFinished(status string) bool
- type ArtifactDeploymentInstructions
- type Deployment
- type DeploymentConstructor
- type DeploymentInstructions
- type DeploymentLog
- type DeviceDeployment
- type InstalledDeviceDeployment
- type LogMessage
- type Query
- type Stats
- type StatusQuery
Constants ¶
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 ¶
var ( ErrInvalidDeploymentLog = errors.New("invalid deployment log") ErrInvalidLogMessage = errors.New("invalid log message") )
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).
Types ¶
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"` // 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:"-"` }
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"` }
func NewDeviceDeployment ¶
func NewDeviceDeployment(deviceId, deploymentId string) *DeviceDeployment
func (*DeviceDeployment) Validate ¶
func (d *DeviceDeployment) Validate() error
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 }
Deployment lookup query
type Stats ¶
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 )