client

package
v3.1.0-rc1+incompatible Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2019 License: BSD-3-Clause Imports: 19 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 SearchLibrary

func SearchLibrary(value string, libraryURL string, authToken string) error

SearchLibrary will search the library for a given query and display results

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, description 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"`
	Size        int64           `bson:"size" json:"size"`
	Private     bool            `bson:"private" json:"private"`
	// CustomData can hold a user-provided string for integration purposes
	// not used by the library itself.
	CustomData string `bson:"customData" json:"customData"`
	// Computed fields that will not be stored - JSON response use only
	EntityName string `bson:"-" json:"entityName,omitempty"`
}

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

func (Collection) LibraryURI

func (c Collection) LibraryURI() string

LibraryURI - library:// URI to the collection

type CollectionResponse

type CollectionResponse struct {
	Data  Collection `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"`
	Size          int64                    `bson:"size" json:"size"`
	DownloadCount int64                    `bson:"downloadCount" json:"downloadCount"`
	// CustomData can hold a user-provided string for integration purposes
	// not used by the library itself.
	CustomData string `bson:"customData" json:"customData"`
	// Computed fields that will not be stored - JSON response use only
	Entity         bson.ObjectId `bson:"-" json:"entity,omitempty"`
	EntityName     string        `bson:"-" json:"entityName,omitempty"`
	CollectionName string        `bson:"-" json:"collectionName,omitempty"`
}

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

func (Container) LibraryURI

func (c Container) LibraryURI() string

LibraryURI - library:// URI to the container

func (Container) TagList

func (c Container) TagList() string

TagList - return a sorted space delimited list of tags

type ContainerResponse

type ContainerResponse struct {
	Data  Container `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"`
	Size        int64           `bson:"size" json:"size"`
	Quota       int64           `bson:"quota" json:"quota"`
	// DefaultPrivate set true will make any new Collections in ths entity
	// private at the time of creation.
	DefaultPrivate bool `bson:"defaultPrivate" json:"defaultPrivate"`
	// CustomData can hold a user-provided string for integration purposes
	// not used by the library itself.
	CustomData string `bson:"customData" json:"customData"`
}

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

func (Entity) LibraryURI

func (e Entity) LibraryURI() string

LibraryURI - library:// URI to the entity

type EntityResponse

type EntityResponse struct {
	Data  Entity    `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"`
	// CustomData can hold a user-provided string for integration purposes
	// not used by the library itself.
	CustomData string `bson:"customData" json:"customData"`
	// Computed fields that will not be stored - JSON response use only
	Entity         bson.ObjectId `bson:"-" json:"entity,omitempty"`
	EntityName     string        `bson:"-" json:"entityName,omitempty"`
	Collection     bson.ObjectId `bson:"-" json:"collection,omitempty"`
	CollectionName string        `bson:"-" json:"collectionName,omitempty"`
	ContainerName  string        `bson:"-" json:"containerName,omitempty"`
}

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

func GetImage

func GetImage(baseURL string, authToken string, imageRef string) (image Image, err error)

GetImage returns the Image object if exists, otherwise returns error

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     `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 error 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 SearchResponse

type SearchResponse struct {
	Data  SearchResults `json:"data"`
	Error JSONError     `json:"error,omitempty"`
}

SearchResponse - Response from the API for a search request

type SearchResults

type SearchResults struct {
	Entities    []Entity     `json:"entity"`
	Collections []Collection `json:"collection"`
	Containers  []Container  `json:"container"`
}

SearchResults - Results structure for searches

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    `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