datastore

package
v0.0.0-...-53c686c Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2016 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoImage is returned when an image is not found.
	ErrNoImage = errors.New("Image not found")

	// ErrImageSaving is returned when an image is being uploaded.
	ErrImageSaving = errors.New("Image being uploaded")
)

Functions

This section is empty.

Types

type DataStore

type DataStore interface {
	Init(RawDataStore, MetaDataStore) error
	CreateImage(Image) error
	GetAllImages() ([]Image, error)
	GetImage(string) (Image, error)
	UpdateImage(Image) error
	DeleteImage(string) error
	UploadImage(string, io.Reader) error
}

DataStore is the image data storage interface.

type Image

type Image struct {
	ID         string
	State      State
	TenantID   string
	Name       string
	CreateTime time.Time
	Type       Type
}

Image contains the information that ciao will store about the image

func (Image) Visibility

func (i Image) Visibility() image.Visibility

Visibility returns the image visibility

type ImageCache

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

ImageCache is an image metadata cache.

func (*ImageCache) CreateImage

func (c *ImageCache) CreateImage(i Image) error

CreateImage will add an image to the datastore.

func (*ImageCache) DeleteImage

func (c *ImageCache) DeleteImage(ID string) error

DeleteImage will delete an existing image.

func (*ImageCache) GetAllImages

func (c *ImageCache) GetAllImages() ([]Image, error)

GetAllImages gets returns all the known images.

func (*ImageCache) GetImage

func (c *ImageCache) GetImage(ID string) (Image, error)

GetImage returns the image specified by the ID string.

func (*ImageCache) Init

func (c *ImageCache) Init(rawDs RawDataStore, metaDs MetaDataStore) error

Init initializes the datastore struct and must be called before anything.

func (*ImageCache) UpdateImage

func (c *ImageCache) UpdateImage(i Image) error

UpdateImage will modify an existing image.

func (*ImageCache) UploadImage

func (c *ImageCache) UploadImage(ID string, body io.Reader) error

UploadImage will read an image, save it and update the image cache.

type MetaDataStore

type MetaDataStore interface {
	Write(Image) error
	Delete(ID string) error
	GetAll() ([]Image, error)
}

MetaDataStore is the metadata storing interface that's used by image cache implementation.

type Noop

type Noop struct {
}

Noop is a Datastore implementation that does nothing. Use it only for development and testing purposes, data will not be persistent with the Noop Datastore interface.

func (*Noop) Delete

func (n *Noop) Delete(id string) error

Delete is the noop image metadata delete implementation. It drops data.

func (*Noop) GetAll

func (n *Noop) GetAll() ([]Image, error)

GetAll is the noop image metadata get all images implementation. It drops data.

func (*Noop) Write

func (n *Noop) Write(i Image) error

Write is the noop image metadata write implementation. It drops data.

type Posix

type Posix struct {
	MountPoint string
}

Posix implements the DataStore interface for posix filesystems

func (*Posix) Delete

func (p *Posix) Delete(ID string) error

Delete removes an image from the posix filesystem

func (*Posix) Write

func (p *Posix) Write(ID string, body io.Reader) (int64, error)

Write copies an image into the posix filesystem. If the image already exists it will be overridden.

type RawDataStore

type RawDataStore interface {
	Write(ID string, body io.Reader) (int64, error)
	Delete(ID string) error
}

RawDataStore is the raw data storage interface that's used by the image cache implementation.

type State

type State string

State represents the state of the image.

const (
	// Created means that an empty image has been created
	Created State = "created"

	// Saving means the image is being saved
	Saving State = "saving"

	// Active means that the image is created, uploaded and ready to use.
	Active State = "active"
)

func (State) Status

func (state State) Status() image.Status

Status translate an image state to an openstack image status.

type Type

type Type string

Type represents the valid image types.

const (
	// Raw is the raw image format.
	Raw Type = "raw"

	// QCow is the qcow2 format.
	QCow Type = "qcow2"

	// ISO is the iso format.
	ISO Type = "iso"
)

Jump to

Keyboard shortcuts

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