app

package
v0.0.0-...-b206e69 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2019 License: Apache-2.0, Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ArtifactContentType = "application/vnd.mender-artifact"

	DefaultUpdateDownloadLinkExpire = 24 * time.Hour
)

Variables

View Source
var (
	// images
	ErrImageMetaNotFound                = errors.New("Image metadata is not found")
	ErrModelMultipartUploadMsgMalformed = errors.New("Multipart upload message malformed")
	ErrModelMissingInputMetadata        = errors.New("Missing input metadata")
	ErrModelMissingInputArtifact        = errors.New("Missing input artifact")
	ErrModelInvalidMetadata             = errors.New("Metadata invalid")
	ErrModelArtifactNotUnique           = errors.New("Artifact not unique")
	ErrModelArtifactFileTooLarge        = errors.New("Artifact file too large")
	ErrModelImageInActiveDeployment     = errors.New("Image is used in active deployment and cannot be removed")
	ErrModelImageUsedInAnyDeployment    = errors.New("Image has already been used in deployment")
	ErrModelParsingArtifactFailed       = errors.New("Cannot parse artifact file")

	// deployments
	ErrModelMissingInput       = errors.New("Missing input deployment data")
	ErrModelInvalidDeviceID    = errors.New("Invalid device ID")
	ErrModelDeploymentNotFound = errors.New("Deployment not found")
	ErrModelInternal           = errors.New("Internal error")
	ErrStorageInvalidLog       = errors.New("Invalid deployment log")
	ErrStorageNotFound         = errors.New("Not found")
	ErrDeploymentAborted       = errors.New("Deployment aborted")
	ErrDeviceDecommissioned    = errors.New("Device decommissioned")
	ErrNoArtifact              = errors.New("No artifact for the deployment")
)

Errors expected from App interface

Functions

This section is empty.

Types

type App

type App interface {
	// limits
	GetLimit(ctx context.Context, name string) (*model.Limit, error)
	ProvisionTenant(ctx context.Context, tenant_id string) error

	// images
	ListImages(ctx context.Context,
		filters map[string]string) ([]*model.SoftwareImage, error)
	DownloadLink(ctx context.Context, imageID string,
		expire time.Duration) (*model.Link, error)
	GetImage(ctx context.Context, id string) (*model.SoftwareImage, error)
	DeleteImage(ctx context.Context, imageID string) error
	CreateImage(ctx context.Context,
		multipartUploadMsg *model.MultipartUploadMsg) (string, error)
	EditImage(ctx context.Context, id string,
		constructorData *model.SoftwareImageMetaConstructor) (bool, error)

	// deployments
	CreateDeployment(ctx context.Context,
		constructor *model.DeploymentConstructor) (string, error)
	GetDeployment(ctx context.Context, deploymentID string) (*model.Deployment, error)
	IsDeploymentFinished(ctx context.Context, deploymentID string) (bool, error)
	AbortDeployment(ctx context.Context, deploymentID string) error
	GetDeploymentStats(ctx context.Context, deploymentID string) (model.Stats, error)
	GetDeploymentForDeviceWithCurrent(ctx context.Context, deviceID string,
		current model.InstalledDeviceDeployment) (*model.DeploymentInstructions, error)
	HasDeploymentForDevice(ctx context.Context, deploymentID string,
		deviceID string) (bool, error)
	UpdateDeviceDeploymentStatus(ctx context.Context, deploymentID string,
		deviceID string, status model.DeviceDeploymentStatus) error
	GetDeviceStatusesForDeployment(ctx context.Context,
		deploymentID string) ([]model.DeviceDeployment, error)
	LookupDeployment(ctx context.Context,
		query model.Query) ([]*model.Deployment, error)
	SaveDeviceDeploymentLog(ctx context.Context, deviceID string,
		deploymentID string, logs []model.LogMessage) error
	GetDeviceDeploymentLog(ctx context.Context,
		deviceID, deploymentID string) (*model.DeploymentLog, error)
	DecommissionDevice(ctx context.Context, deviceID string) error
}

type Deployments

type Deployments struct {
	// contains filtered or unexported fields
}

func NewDeployments

func NewDeployments(storage store.DataStore, fileStorage model.FileStorage, imageContentType string) *Deployments

func (*Deployments) AbortDeployment

func (d *Deployments) AbortDeployment(ctx context.Context, deploymentID string) error

AbortDeployment aborts deployment for devices and updates deployment stats

func (*Deployments) CreateDeployment

func (d *Deployments) CreateDeployment(ctx context.Context,
	constructor *model.DeploymentConstructor) (string, error)

CreateDeployment precomputes new deplyomet and schedules it for devices. TODO: check if specified devices are bootstrapped (when have a way to do this)

func (*Deployments) CreateImage

func (d *Deployments) CreateImage(ctx context.Context,
	multipartUploadMsg *model.MultipartUploadMsg) (string, error)

CreateImage parses artifact and uploads artifact file to the file storage - in parallel, and creates image structure in the system. Returns image ID and nil on success.

func (*Deployments) DecommissionDevice

func (d *Deployments) DecommissionDevice(ctx context.Context, deviceId string) error

func (*Deployments) DeleteImage

func (d *Deployments) DeleteImage(ctx context.Context, imageID string) error

DeleteImage removes metadata and image file Noop for not exisitng images Allowed to remove image only if image is not scheduled or in progress for an updates - then image file is needed In case of already finished updates only image file is not needed, metadata is attached directly to device deployment therefore we still have some information about image that have been used (but not the file)

func (d *Deployments) DownloadLink(ctx context.Context, imageID string,
	expire time.Duration) (*model.Link, error)

DownloadLink presigned GET link to download image file. Returns error if image have not been uploaded.

func (*Deployments) EditImage

func (d *Deployments) EditImage(ctx context.Context, imageID string,
	constructor *model.SoftwareImageMetaConstructor) (bool, error)

EditObject allows editing only if image have not been used yet in any deployment.

func (*Deployments) GetDeployment

func (d *Deployments) GetDeployment(ctx context.Context,
	deploymentID string) (*model.Deployment, error)

GetDeployment fetches deployment by ID

func (*Deployments) GetDeploymentForDeviceWithCurrent

func (d *Deployments) GetDeploymentForDeviceWithCurrent(ctx context.Context, deviceID string,
	installed model.InstalledDeviceDeployment) (*model.DeploymentInstructions, error)

GetDeploymentForDeviceWithCurrent returns deployment for the device

func (*Deployments) GetDeploymentStats

func (d *Deployments) GetDeploymentStats(ctx context.Context,
	deploymentID string) (model.Stats, error)

func (*Deployments) GetDeviceDeploymentLog

func (d *Deployments) GetDeviceDeploymentLog(ctx context.Context,
	deviceID, deploymentID string) (*model.DeploymentLog, error)

func (*Deployments) GetDeviceStatusesForDeployment

func (d *Deployments) GetDeviceStatusesForDeployment(ctx context.Context,
	deploymentID string) ([]model.DeviceDeployment, error)

GetDeviceStatusesForDeployment retrieve device deployment statuses for a given deployment.

func (*Deployments) GetImage

func (d *Deployments) GetImage(ctx context.Context, id string) (*model.SoftwareImage, error)

GetImage allows to fetch image obeject with specified id Nil if not found

func (*Deployments) GetLimit

func (d *Deployments) GetLimit(ctx context.Context, name string) (*model.Limit, error)

func (*Deployments) HasDeploymentForDevice

func (d *Deployments) HasDeploymentForDevice(ctx context.Context,
	deploymentID string, deviceID string) (bool, error)

func (*Deployments) ImageUsedInActiveDeployment

func (d *Deployments) ImageUsedInActiveDeployment(ctx context.Context,
	imageID string) (bool, error)

ImageUsedInActiveDeployment checks if specified image is in use by deployments Image is considered to be in use if it's participating in at lest one non success/error deployment.

func (*Deployments) ImageUsedInDeployment

func (d *Deployments) ImageUsedInDeployment(ctx context.Context, imageID string) (bool, error)

ImageUsedInDeployment checks if specified image is in use by deployments Image is considered to be in use if it's participating in any deployment.

func (*Deployments) IsDeploymentFinished

func (d *Deployments) IsDeploymentFinished(ctx context.Context, deploymentID string) (bool, error)

IsDeploymentFinished checks if there is unfinished deployment with given ID

func (*Deployments) ListImages

func (d *Deployments) ListImages(ctx context.Context,
	filters map[string]string) ([]*model.SoftwareImage, error)

ListImages according to specified filers.

func (*Deployments) LookupDeployment

func (d *Deployments) LookupDeployment(ctx context.Context,
	query model.Query) ([]*model.Deployment, error)

func (*Deployments) ProvisionTenant

func (d *Deployments) ProvisionTenant(ctx context.Context, tenant_id string) error

func (*Deployments) SaveDeviceDeploymentLog

func (d *Deployments) SaveDeviceDeploymentLog(ctx context.Context, deviceID string,
	deploymentID string, logs []model.LogMessage) error

SaveDeviceDeploymentLog will save the deployment log for device of ID `deviceID`. Returns nil if log was saved successfully.

func (*Deployments) UpdateDeviceDeploymentStatus

func (d *Deployments) UpdateDeviceDeploymentStatus(ctx context.Context, deploymentID string,
	deviceID string, ddStatus model.DeviceDeploymentStatus) error

UpdateDeviceDeploymentStatus will update the deployment status for device of ID `deviceID`. Returns nil if update was successful.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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