1
// Copyright 2015 Canonical Ltd.
2
// Licensed under the AGPLv3, see LICENCE file for details.
4
package cloudimagemetadata
7
jujutxn "github.com/juju/txn"
9
"github.com/juju/juju/mongo"
12
// MetadataAttributes contains cloud image metadata attributes.
13
type MetadataAttributes struct {
14
// Stream contains reference to a particular stream,
15
// for e.g. "daily" or "released"
18
// Region is the name of cloud region associated with the image.
21
// Version is OS version, for e.g. "12.04".
24
// Series is OS series, for e.g. "trusty".
27
// Arch is the architecture for this cloud image, for e.g. "amd64"
30
// VirtType contains virtualisation type of the cloud image, for e.g. "pv", "hvm". "kvm".
33
// RootStorageType contains type of root storage, for e.g. "ebs", "instance".
34
RootStorageType string
36
// RootStorageSize contains size of root storage in gigabytes (GB).
37
RootStorageSize *uint64
39
// Source describes where this image is coming from: is it public? custom?
43
// Metadata describes a cloud image metadata.
44
type Metadata struct {
47
// Priority is an importance factor for image metadata.
48
// Higher number means higher priority.
49
// This will allow to sort metadata by importance.
52
// ImageId contains image identifier.
56
// Storage provides methods for storing and retrieving cloud image metadata.
57
type Storage interface {
58
// SaveMetadata adds cloud images metadata into state if it's new or
59
// updates metadata if it already exists.
60
SaveMetadata([]Metadata) error
62
// DeleteMetadata deletes cloud image metadata from state.
63
DeleteMetadata(imageId string) error
65
// FindMetadata returns all Metadata that match specified
66
// criteria or a "not found" error if none match.
67
// Empty criteria will return all cloud image metadata.
68
// Returned result is grouped by source type and ordered by date created.
69
FindMetadata(criteria MetadataFilter) (map[string][]Metadata, error)
71
// SupportedArchitectures returns collection of unique architectures
72
// that stored metadata contains.
73
SupportedArchitectures(criteria MetadataFilter) ([]string, error)
76
// DataStore exposes data store operations for use by the cloud image metadata package.
77
type DataStore interface {
79
// RunTransaction runs desired transactions against this data source..
80
RunTransaction(jujutxn.TransactionSource) error
82
// GetCollection retrieves desired collection from this data source.
83
GetCollection(name string) (collection mongo.Collection, closer func())