Documentation ¶
Overview ¶
The imagemetadata package supports locating, parsing, and filtering Ubuntu image metadata in simplestreams format. See http://launchpad.net/simplestreams and in particular the doc/README file in that project for more information about the file formats.
Index ¶
- Constants
- Variables
- func GetMetadataSources(env environs.ConfigGetter) ([]simplestreams.DataSource, error)
- func ImageMetadataURL(source, stream string) (string, error)
- func MarshalImageMetadataIndexJSON(metadata []*ImageMetadata, cloudSpec []simplestreams.CloudSpec, ...) (out []byte, err error)
- func MarshalImageMetadataJSON(metadata []*ImageMetadata, cloudSpec []simplestreams.CloudSpec, ...) (index, products []byte, err error)
- func MarshalImageMetadataProductsJSON(metadata []*ImageMetadata, updated time.Time) (out []byte, err error)
- func MergeAndWriteMetadata(series string, metadata []*ImageMetadata, cloudSpec *simplestreams.CloudSpec, ...) error
- func Sort(metadata []*ImageMetadata)
- func UploadImageMetadata(stor storage.Storage, sourceDir string) error
- func ValidateImageMetadata(params *simplestreams.MetadataLookupParams) ([]string, *simplestreams.ResolveInfo, error)
- type ImageConstraint
- type ImageMetadata
- type MetadataFile
- type SupportsCustomSources
Constants ¶
const ( ProductMetadataPath = "streams/v1/com.ubuntu.cloud:released:imagemetadata.json" ImageContentId = "com.ubuntu.cloud:custom" )
const ( // The location where Ubuntu cloud image metadata is published for // public consumption. UbuntuCloudImagesURL = "http://cloud-images.ubuntu.com" // The path where released image metadata is found. ReleasedImagesPath = "releases" )
const (
ImageIds = "image-ids"
)
const (
// Used to specify the released image metadata.
ReleasedStream = "released"
)
Variables ¶
var DefaultBaseURL = UbuntuCloudImagesURL
This needs to be a var so we can override it for testing and in bootstrap.
Functions ¶
func GetMetadataSources ¶
func GetMetadataSources(env environs.ConfigGetter) ([]simplestreams.DataSource, error)
GetMetadataSources returns the sources to use when looking for simplestreams image id metadata for the given stream. If env implements SupportsCustomSources, the sources returned from that method will also be considered.
func ImageMetadataURL ¶
ImageMetadataURL returns a valid image metadata URL constructed from source. source may be a directory, or a URL like file://foo or http://foo.
func MarshalImageMetadataIndexJSON ¶
func MarshalImageMetadataIndexJSON(metadata []*ImageMetadata, cloudSpec []simplestreams.CloudSpec, updated time.Time) (out []byte, err error)
MarshalImageMetadataIndexJSON marshals image metadata to index JSON.
updated is the time at which the JSON file was updated.
func MarshalImageMetadataJSON ¶
func MarshalImageMetadataJSON(metadata []*ImageMetadata, cloudSpec []simplestreams.CloudSpec, updated time.Time) (index, products []byte, err error)
MarshalImageMetadataJSON marshals image metadata to index and products JSON.
updated is the time at which the JSON file was updated.
func MarshalImageMetadataProductsJSON ¶
func MarshalImageMetadataProductsJSON(metadata []*ImageMetadata, updated time.Time) (out []byte, err error)
MarshalImageMetadataProductsJSON marshals image metadata to products JSON.
updated is the time at which the JSON file was updated.
func MergeAndWriteMetadata ¶
func MergeAndWriteMetadata(series string, metadata []*ImageMetadata, cloudSpec *simplestreams.CloudSpec, metadataStore storage.Storage) error
MergeAndWriteMetadata reads the existing metadata from storage (if any), and merges it with supplied metadata, writing the resulting metadata is written to storage.
func Sort ¶
func Sort(metadata []*ImageMetadata)
Sort sorts a slice of ImageMetadata in ascending order of their id in order to ensure the results of Fetch are ordered deterministically.
func UploadImageMetadata ¶
UploadImageMetadata uploads image metadata files from sourceDir to stor.
func ValidateImageMetadata ¶
func ValidateImageMetadata(params *simplestreams.MetadataLookupParams) ([]string, *simplestreams.ResolveInfo, error)
ValidateImageMetadata attempts to load image metadata for the specified cloud attributes and stream and returns any image ids found, or an error if the metadata could not be loaded.
Types ¶
type ImageConstraint ¶
type ImageConstraint struct {
simplestreams.LookupParams
}
ImageConstraint defines criteria used to find an image metadata record.
func NewImageConstraint ¶
func NewImageConstraint(params simplestreams.LookupParams) *ImageConstraint
func (*ImageConstraint) Ids ¶
func (ic *ImageConstraint) Ids() ([]string, error)
Generates a string array representing product ids formed similarly to an ISCSI qualified name (IQN).
type ImageMetadata ¶
type ImageMetadata struct { Id string `json:"id"` Storage string `json:"root_store,omitempty"` VirtType string `json:"virt,omitempty"` Arch string `json:"arch,omitempty"` Version string `json:"version,omitempty"` RegionAlias string `json:"crsn,omitempty"` RegionName string `json:"region,omitempty"` Endpoint string `json:"endpoint,omitempty"` Stream string `json:"-"` }
ImageMetadata holds information about a particular cloud image.
func Fetch ¶
func Fetch( sources []simplestreams.DataSource, indexPath string, cons *ImageConstraint, onlySigned bool) ([]*ImageMetadata, *simplestreams.ResolveInfo, error)
Fetch returns a list of images for the specified cloud matching the constraint. The base URL locations are as specified - the first location which has a file is the one used. Signed data is preferred, but if there is no signed data available and onlySigned is false, then unsigned data is used.
func GetLatestImageIdMetadata ¶
func GetLatestImageIdMetadata(data []byte, source simplestreams.DataSource, cons *ImageConstraint) ([]*ImageMetadata, error)
GetLatestImageIdMetadata is provided so it can be call by tests outside the imagemetadata package.
func (*ImageMetadata) String ¶
func (im *ImageMetadata) String() string
type MetadataFile ¶
type SupportsCustomSources ¶
type SupportsCustomSources interface {
GetImageSources() ([]simplestreams.DataSource, error)
}
SupportsCustomSources represents an environment that can host image metadata at provider specific sources.