client

package
v3.0.0-alpha.1+incompa... Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2018 License: BSD-3-Clause Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LibraryModels = []string{"Entity", "Collection", "Container", "Image", "Blob"}

LibraryModels lists names of valid models in the database

Functions

func BsonUTCNow

func BsonUTCNow() time.Time

BsonUTCNow returns a time.Time in UTC, with the precision supported by BSON

func DownloadImage

func DownloadImage(filePath string, libraryRef string, libraryURL string, Force bool, authToken string) error

DownloadImage will retrieve an image from the Container Library, saving it into the specified file

func IDInSlice

func IDInSlice(a bson.ObjectId, list []bson.ObjectId) bool

IDInSlice returns true if ID is present in the slice

func ImageHash

func ImageHash(filePath string) (result string, err error)

ImageHash returns the appropriate hash for a provided image file

e.g. sif.<uuid> or sha256.<sha256>

func IsImageHash

func IsImageHash(refPart string) bool

IsImageHash returns true if the provided string is valid as a unique hash for an image

func IsLibraryPullRef

func IsLibraryPullRef(libraryRef string) bool

IsLibraryPullRef returns true if the provided string is a valid library reference for a pull operation.

func IsLibraryPushRef

func IsLibraryPushRef(libraryRef string) bool

IsLibraryPushRef returns true if the provided string is a valid library reference for a push operation.

func IsRefPart

func IsRefPart(refPart string) bool

IsRefPart returns true if the provided string is valid as a component of a library URI (i.e. a valid entity, collection etc. name)

func PrettyPrint

func PrettyPrint(v interface{})

PrettyPrint - Debug helper, print nice json for any interface

func SliceWithoutID

func SliceWithoutID(list []bson.ObjectId, a bson.ObjectId) []bson.ObjectId

SliceWithoutID returns slice with specified ID removed

func StringInSlice

func StringInSlice(a string, list []string) bool

StringInSlice returns true if string is present in the slice

func UploadImage

func UploadImage(filePath string, libraryRef string, libraryURL string, authToken string) error

UploadImage will push a specified image up to the Container Library,

Types

type BaseModel

type BaseModel struct {
	ModelManager `bson:",omitempty" json:",omitempty"`
	Deleted      bool      `bson:"deleted" json:"deleted"`
	CreatedBy    string    `bson:"createdBy" json:"createdBy"`
	CreatedAt    time.Time `bson:"createdAt" json:"createdAt"`
	UpdatedBy    string    `bson:"updatedBy,omitempty" json:"updatedBy,omitempty"`
	UpdatedAt    time.Time `bson:"updatedAt,omitempty" json:"updatedAt,omitempty"`
	DeletedBy    string    `bson:"deletedBy,omitempty" json:"deletedBy,omitempty"`
	DeletedAt    time.Time `bson:"deletedAt,omitempty" json:"deletedAt,omitempty"`
}

BaseModel - has an ID, soft deletion marker, and Audit struct

func (BaseModel) GetCreated

func (m BaseModel) GetCreated() (auditUser string, auditTime time.Time)

GetCreated - Convenience method to get creation stamps if working with an interface

func (BaseModel) GetDeleted

func (m BaseModel) GetDeleted() (auditUser string, auditTime time.Time)

GetDeleted - Convenience method to get deletino stamps if working with an interface

func (BaseModel) GetUpdated

func (m BaseModel) GetUpdated() (auditUser string, auditTime time.Time)

GetUpdated - Convenience method to get update stamps if working with an interface

func (BaseModel) IsDeleted

func (m BaseModel) IsDeleted() bool

IsDeleted - Convenience method to check soft deletion state if working with an interface

type Blob

type Blob struct {
	BaseModel
	ID          bson.ObjectId `bson:"_id" json:"id"`
	Bucket      string        `bson:"bucket" json:"bucket"`
	Key         string        `bson:"key" json:"key"`
	Size        int64         `bson:"size" json:"size"`
	ContentHash string        `bson:"contentHash" json:"contentHash"`
	Status      string        `bson:"status" json:"status"`
}

Blob - Binary data object (e.g. container image file) stored in a Backend Uses object store bucket/key semantics

func (Blob) GetID

func (b Blob) GetID() bson.ObjectId

GetID - Convenience method to get model ID if working with an interface

type Collection

type Collection struct {
	BaseModel
	ID          bson.ObjectId   `bson:"_id" json:"id"`
	Name        string          `bson:"name" json:"name"`
	Description string          `bson:"description" json:"description"`
	Entity      bson.ObjectId   `bson:"entity" json:"entity"`
	Containers  []bson.ObjectId `bson:"containers" json:"containers"`
}

Collection - Second level in the library, holds a collection of containers

func (Collection) GetID

func (c Collection) GetID() bson.ObjectId

GetID - Convenience method to get model ID if working with an interface

type CollectionResponse

type CollectionResponse struct {
	Data  Collection `bson:"data" json:"data"`
	Error JSONError  `json:"error,omitempty"`
}

CollectionResponse - Response from the API for an Collection request

type Container

type Container struct {
	BaseModel
	ID          bson.ObjectId            `bson:"_id" json:"id"`
	Name        string                   `bson:"name" json:"name"`
	Description string                   `bson:"description" json:"description"`
	Collection  bson.ObjectId            `bson:"collection" json:"collection"`
	Images      []bson.ObjectId          `bson:"images" json:"images"`
	ImageTags   map[string]bson.ObjectId `bson:"imageTags" json:"imageTags"`
}

Container - Third level of library. Inside a collection, holds images for a particular container

func (Container) GetID

func (c Container) GetID() bson.ObjectId

GetID - Convenience method to get model ID if working with an interface

type ContainerResponse

type ContainerResponse struct {
	Data  Container `bson:"data" json:"data"`
	Error JSONError `json:"error,omitempty"`
}

ContainerResponse - Response from the API for an Container request

type Entity

type Entity struct {
	BaseModel
	ID          bson.ObjectId   `bson:"_id" json:"id"`
	Name        string          `bson:"name" json:"name"`
	Description string          `bson:"description" json:"description"`
	Collections []bson.ObjectId `bson:"collections" json:"collections"`
}

Entity - Top level entry in the library, contains collections of images for a user or group

func (Entity) GetID

func (e Entity) GetID() bson.ObjectId

GetID - Convenience method to get model ID if working with an interface

type EntityResponse

type EntityResponse struct {
	Data  Entity    `bson:"data" json:"data"`
	Error JSONError `json:"error,omitempty"`
}

EntityResponse - Response from the API for an Entity request

type Image

type Image struct {
	BaseModel
	ID          bson.ObjectId `bson:"_id" json:"id"`
	Hash        string        `bson:"hash" json:"hash"`
	Description string        `bson:"description" json:"description"`
	Container   bson.ObjectId `bson:"container" json:"container"`
	Blob        bson.ObjectId `bson:"blob,omitempty" json:"blob,omitempty"`
	Size        int64         `bson:"size" json:"size"`
	Uploaded    bool          `bson:"uploaded" json:"uploaded"`
}

Image - Represents a Singularity image held by the library for a particular Container

func (Image) GetID

func (img Image) GetID() bson.ObjectId

GetID - Convenience method to get model ID if working with an interface

type ImageResponse

type ImageResponse struct {
	Data  Image     `bson:"data" json:"data"`
	Error JSONError `json:"error,omitempty"`
}

ImageResponse - Response from the API for an Image request

type ImageTag

type ImageTag struct {
	Tag     string
	ImageID bson.ObjectId
}

ImageTag - A single mapping from a string to bson ID. Not stored in the DB but used by API calls setting tags

type JSONError

type JSONError struct {
	Code    int    `json:"code,omitempty"`
	Status  string `json:"status,omitempty"`
	Message string `json:"message,omitempty"`
}

JSONError - Struct for standard error returns over REST API

type JSONResponse

type JSONResponse struct {
	Data  interface{} `json:"data"`
	Error JSONError   `json:"error,omitempty"`
}

JSONResponse - Top level container of a REST API response

func ParseErrorBody

func ParseErrorBody(r io.Reader) (jRes JSONResponse, err error)

ParseErrorBody - Parse an API format rror out of the body

func ParseErrorResponse

func ParseErrorResponse(res *http.Response) (jRes JSONResponse)

ParseErrorResponse - Create a JSONResponse out of a raw HTTP response

type ModelManager

type ModelManager interface {
	GetID() bson.ObjectId
}

ModelManager - Generic interface for models which must have a bson ObjectID

type TagMap

type TagMap map[string]bson.ObjectId

TagMap - A map of tags to imageIDs for a container

type TagsResponse

type TagsResponse struct {
	Data  TagMap    `bson:"data" json:"data"`
	Error JSONError `json:"error,omitempty"`
}

TagsResponse - Response from the API for a tags request

Jump to

Keyboard shortcuts

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