Documentation ¶
Index ¶
- Variables
- func BsonUTCNow() time.Time
- func DownloadImage(filePath string, libraryRef string, libraryURL string, Force bool, ...) error
- func IDInSlice(a bson.ObjectId, list []bson.ObjectId) bool
- func ImageHash(filePath string) (result string, err error)
- func IsImageHash(refPart string) bool
- func IsLibraryPullRef(libraryRef string) bool
- func IsLibraryPushRef(libraryRef string) bool
- func IsRefPart(refPart string) bool
- func PrettyPrint(v interface{})
- func SearchLibrary(value string, libraryURL string, authToken string) error
- func SliceWithoutID(list []bson.ObjectId, a bson.ObjectId) []bson.ObjectId
- func StringInSlice(a string, list []string) bool
- func UploadImage(filePath string, libraryRef string, libraryURL string, authToken string, ...) error
- type BaseModel
- type Blob
- type Collection
- type CollectionResponse
- type Container
- type ContainerResponse
- type Entity
- type EntityResponse
- type Image
- type ImageResponse
- type ImageTag
- type JSONError
- type JSONResponse
- type ModelManager
- type SearchResponse
- type SearchResults
- type TagMap
- type TagsResponse
Constants ¶
This section is empty.
Variables ¶
var LibraryModels = []string{"Entity", "Collection", "Container", "Image", "Blob"}
LibraryModels lists names of valid models in the database
Functions ¶
func BsonUTCNow ¶
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 ImageHash ¶
ImageHash returns the appropriate hash for a provided image file
e.g. sif.<uuid> or sha256.<sha256>
func IsImageHash ¶
IsImageHash returns true if the provided string is valid as a unique hash for an image
func IsLibraryPullRef ¶
IsLibraryPullRef returns true if the provided string is a valid library reference for a pull operation.
func IsLibraryPushRef ¶
IsLibraryPushRef returns true if the provided string is a valid library reference for a push operation.
func IsRefPart ¶
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 ¶
SearchLibrary will search the library for a given query and display results
func SliceWithoutID ¶
SliceWithoutID returns slice with specified ID removed
func StringInSlice ¶
StringInSlice returns true if string is present in the slice
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 ¶
GetCreated - Convenience method to get creation stamps if working with an interface
func (BaseModel) GetDeleted ¶
GetDeleted - Convenience method to get deletino stamps if working with an interface
func (BaseModel) GetUpdated ¶
GetUpdated - Convenience method to get update stamps 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
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) LibraryURI ¶
LibraryURI - library:// URI to the container
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) LibraryURI ¶
LibraryURI - library:// URI to the entity
type EntityResponse ¶
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
type ImageResponse ¶
ImageResponse - Response from the API for an Image request
type ImageTag ¶
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 ¶
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 TagsResponse ¶
TagsResponse - Response from the API for a tags request