model

package
v0.0.0-...-4c6cade Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2017 License: Apache-2.0, Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

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

Variables

View Source
var (
	ErrSoftwareImagesStorageInvalidID           = errors.New("Invalid id")
	ErrSoftwareImagesStorageInvalidArtifactName = errors.New("Invalid artifact name")
	ErrSoftwareImagesStorageInvalidName         = errors.New("Invalid name")
	ErrSoftwareImagesStorageInvalidDeviceType   = errors.New("Invalid device type")
	ErrSoftwareImagesStorageInvalidImage        = errors.New("Invalid image")
)

Common errors for interface SoftwareImagesStorage

View Source
var (
	ErrFileStorageFileNotFound = errors.New("File not found")
)

Errors specific to interface

Functions

This section is empty.

Types

type FileStorage

type FileStorage interface {
	Delete(ctx context.Context, objectId string) error
	Exists(ctx context.Context, objectId string) (bool, error)
	LastModified(ctx context.Context, objectId string) (time.Time, error)
	PutRequest(ctx context.Context, objectId string,
		duration time.Duration) (*images.Link, error)
	GetRequest(ctx context.Context, objectId string,
		duration time.Duration, responseContentType string) (*images.Link, error)
	UploadArtifact(ctx context.Context, objectId string,
		artifactSize int64, artifact io.Reader, contentType string) error
}

FileStorage allows to store and manage large files

type ImageUsedIn

type ImageUsedIn interface {
	ImageUsedInActiveDeployment(ctx context.Context, imageId string) (bool, error)
	ImageUsedInDeployment(ctx context.Context, imageId string) (bool, error)
}

Allows to check of image is used in different deployment status groups

type ImagesModel

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

func NewImagesModel

func NewImagesModel(
	fileStorage FileStorage,
	checker ImageUsedIn,
	imagesStorage SoftwareImagesStorage,
) *ImagesModel

func (*ImagesModel) CreateImage

func (i *ImagesModel) CreateImage(ctx context.Context,
	multipartUploadMsg *controller.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 (*ImagesModel) DeleteImage

func (i *ImagesModel) 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 (i *ImagesModel) DownloadLink(ctx context.Context, imageID string,
	expire time.Duration) (*images.Link, error)

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

func (*ImagesModel) EditImage

func (i *ImagesModel) EditImage(ctx context.Context, imageID string,
	constructor *images.SoftwareImageMetaConstructor) (bool, error)

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

func (*ImagesModel) GetImage

func (i *ImagesModel) GetImage(ctx context.Context, id string) (*images.SoftwareImage, error)

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

func (*ImagesModel) ListImages

func (i *ImagesModel) ListImages(ctx context.Context,
	filters map[string]string) ([]*images.SoftwareImage, error)

ListImages according to specified filers.

type SoftwareImagesStorage

type SoftwareImagesStorage interface {
	Exists(ctx context.Context, id string) (bool, error)
	Update(ctx context.Context, image *images.SoftwareImage) (bool, error)
	Insert(ctx context.Context, image *images.SoftwareImage) error
	FindByID(ctx context.Context, id string) (*images.SoftwareImage, error)
	IsArtifactUnique(ctx context.Context, artifactName string,
		deviceTypesCompatible []string) (bool, error)
	Delete(ctx context.Context, id string) error
	FindAll(ctx context.Context) ([]*images.SoftwareImage, error)
}

SoftwareImagesStorage allow to store and manage image.SoftwareImages

Jump to

Keyboard shortcuts

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