storage

package
v0.0.0-...-93f22b1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	//ErrRevisionNotExist returned when a revision does not exist
	ErrRevisionNotExist = errors.New("Revision in bucket does not exist")

	//ErrTagNotExist returned when a tag does not exist
	ErrTagNotExist = errors.New("Requested tag in bundle does not exist")

	//ErrNotAllowed The user is not allowed to access this bundle
	ErrNotAllowed = errors.New("The user is not allowed to access this bundle")
)

Functions

This section is empty.

Types

type BundleMeta

type BundleMeta struct {
	//The bundle name
	BundleID string
	//The creator's userID from their JWT token
	OwnerUserID string
}

BundleMeta the owner of the bundle

type GCloudStorageImpl

type GCloudStorageImpl struct {
	Bucket   *storage.BucketHandle
	DsClient *datastore.Client
	Context  context.Context
}

GCloudStorageImpl The google cloud storage implementation

func (*GCloudStorageImpl) CreateTag

func (s *GCloudStorageImpl) CreateTag(bundleMeta *BundleMeta, sha512, tag string) error

CreateTag create a tag for the bundle id

func (*GCloudStorageImpl) DeleteTag

func (s *GCloudStorageImpl) DeleteTag(bundleMeta *BundleMeta, tag string) error

DeleteTag a tag for the bundleId and tag. If the tag does not exist, and error will be reteurned

func (*GCloudStorageImpl) GetBundle

func (s *GCloudStorageImpl) GetBundle(bundleMeta *BundleMeta, sha512 string) (io.ReadCloser, error)

GetBundle the bundle and return it

func (*GCloudStorageImpl) GetBundleOwner

func (s *GCloudStorageImpl) GetBundleOwner(bundleID string) (*BundleMeta, error)

GetBundleOwner get a bundle's owner

func (*GCloudStorageImpl) GetRevisionForTag

func (s *GCloudStorageImpl) GetRevisionForTag(bundleMeta *BundleMeta, tag string) (string, error)

GetRevisionForTag Get the revision of the bundle and tag. If none is specified an error will be returned

func (*GCloudStorageImpl) GetRevisions

func (s *GCloudStorageImpl) GetRevisions(bundleMeta *BundleMeta, cursor string, pageSize int) ([]*Revision, string, error)

GetRevisions get the revisions for the bundle and return them.

func (*GCloudStorageImpl) GetTags

func (s *GCloudStorageImpl) GetTags(bundleMeta *BundleMeta, cursor string, pageSize int) ([]*Tag, string, error)

GetTags get the tags

func (*GCloudStorageImpl) SaveBundle

func (s *GCloudStorageImpl) SaveBundle(bytes io.Reader, bundleMeta *BundleMeta) (string, error)

SaveBundle store the bytes of the bundle id

type Revision

type Revision struct {
	//The bundle name
	BundleID string

	//The SHa512 revision of the bundle
	RevisionSha512 string

	//the timestamp the bundle was created
	Created time.Time
}

Revision when a revision is created

type Storage

type Storage interface {

	//SaveBundle store the bytes of the bundle id.  Returns the new revision and any error
	SaveBundle(bytes io.Reader, owner *BundleMeta) (string, error)

	//GetBundle get the bundle and return it
	GetBundle(bundleMeta *BundleMeta, revision string) (io.ReadCloser, error)

	//GetRevisions get the revisions for the bundle and return them.
	GetRevisions(bundleMeta *BundleMeta, cursor string, pageSize int) ([]*Revision, string, error)

	//CreateTag create a tag for the bundle id. Will return ErrRevisionNotExist if the revision does not exist
	CreateTag(bundleMeta *BundleMeta, revision, tag string) error

	//GetTags get the tags for the bundle. TODO, maybe make this an iterator for the return?
	GetTags(bundleMeta *BundleMeta, cursor string, pageSize int) ([]*Tag, string, error)

	//GetRevisionForTag Get the revision of the bundle and tag.  If none is specified an error will be returned
	GetRevisionForTag(bundleMeta *BundleMeta, tag string) (string, error)

	//DeleteTag a tag for the bundleId and tag.  If the tag does not exist, a ErrTagNotExist will be reteurned
	DeleteTag(bundleMeta *BundleMeta, tag string) error
}

Storage the interface for bundle storage

func CreateGCloudStorage

func CreateGCloudStorage(projectID, bucketName string) (Storage, error)

CreateGCloudStorage create the s3 storage provider and return it. The serviceAccountFile can be empty, in which case defaults are used. see https://cloud.google.com/vision/docs/common/auth for setting creds

type Tag

type Tag struct {
	//The bundle name
	BundleID string

	//RevisionSha512 the sha revision of the tag
	RevisionSha512 string

	//The name of the tag
	Name string

	//the timestamp the tag was created
	Created time.Time
}

Tag a structure to return names and revisions of tags

Jump to

Keyboard shortcuts

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