controller

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: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// 15 minutes
	DefaultDownloadLinkExpire = 15 * time.Minute

	DefaultMaxMetaSize = 1024 * 1024 * 10
)

API input validation constants

Variables

View Source
var (
	ErrIDNotUUIDv4                    = errors.New("ID is not UUIDv4")
	ErrArtifactUsedInActiveDeployment = errors.New("Artifact is used in active deployment")
	ErrInvalidExpireParam             = errors.New("Invalid expire parameter")
)
View Source
var (
	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")
	ErrModelArtifactUploadFailed        = errors.New("Failed to upload the artifact")
	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")
)

Errors expected from interface

Functions

This section is empty.

Types

type ImagesModel

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

type MultipartUploadMsg

type MultipartUploadMsg struct {
	// user metadata constructor
	MetaConstructor *images.SoftwareImageMetaConstructor
	// size of the artifact file
	ArtifactSize int64
	// reader pointing to the beginning of the artifact data
	ArtifactReader io.Reader
}

MultipartUploadMsg is a structure with fields extracted from the mulitpart/form-data form send in the artifact upload request

type RESTView

type RESTView interface {
	RenderSuccessPost(w rest.ResponseWriter, r *rest.Request, id string)
	RenderSuccessGet(w rest.ResponseWriter, object interface{})
	RenderError(w rest.ResponseWriter, r *rest.Request, err error, status int, l *log.Logger)
	RenderInternalError(w rest.ResponseWriter, r *rest.Request, err error, l *log.Logger)
	RenderErrorNotFound(w rest.ResponseWriter, r *rest.Request, l *log.Logger)
	RenderSuccessDelete(w rest.ResponseWriter)
	RenderSuccessPut(w rest.ResponseWriter)
}

type SoftwareImagesController

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

func NewSoftwareImagesController

func NewSoftwareImagesController(model ImagesModel, view RESTView) *SoftwareImagesController

func (*SoftwareImagesController) DeleteImage

func (s *SoftwareImagesController) DownloadLink(w rest.ResponseWriter, r *rest.Request)

func (*SoftwareImagesController) EditImage

func (*SoftwareImagesController) GetImage

func (*SoftwareImagesController) ListImages

func (*SoftwareImagesController) NewImage

Multipart Image/Meta upload handler. Request should be of type "multipart/form-data". First part should contain Metadata file. This file should be of type "application/json". Second part should contain artifact file.

func (*SoftwareImagesController) ParseMultipart

func (s *SoftwareImagesController) ParseMultipart(mr *multipart.Reader, maxMetaSize int64) (*MultipartUploadMsg, error)

ParseMultipart parses multipart/form-data message.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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