juju: github.com/wallyworld/juju/environs/imagemetadata Index | Files | Directories

package imagemetadata

import "github.com/wallyworld/juju/environs/imagemetadata"

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.


Package Files

generate.go marshal.go simplestreams.go urls.go validation.go


const (
    ProductMetadataPath = "streams/v1/com.ubuntu.cloud-released-imagemetadata.json"
    ImageContentId      = "com.ubuntu.cloud:custom"
const (
    // ImageIds is the simplestreams image content type.
    ImageIds = "image-ids"

    // StreamsVersionV1 is used to construct the path for accessing streams data.
    StreamsVersionV1 = "v1"

    // IndexFileVersion is used to construct the streams index file.
    IndexFileVersion = 1
const (
    // The location where Ubuntu generic 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 (
    // Used to specify the released image metadata.
    ReleasedStream = "released"


var (
    DefaultUbuntuBaseURL = UbuntuCloudImagesURL

This needs to be a var so we can override it for testing and in bootstrap.

var SimplestreamsImagesPublicKey = "" /* 3212 byte string literal not displayed */

simplestreamsImagesPublicKey is the public key required to authenticate the simple streams data on http://cloud-images.ubuntu.com. Declared as a var so it can be overidden for testing. See http://bazaar.launchpad.net/~smoser/simplestreams/trunk/view/head:/examples/keys/cloud-images.pub

func ImageMetadataURL Uses

func ImageMetadataURL(source, stream string) (string, error)

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 IndexStoragePath Uses

func IndexStoragePath() string

IndexStoragePath returns the storage path for the image metadata index file.

func MarshalImageMetadataIndexJSON Uses

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 Uses

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 Uses

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 Uses

func MergeAndWriteMetadata(ser 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 OfficialDataSources Uses

func OfficialDataSources(stream string) ([]simplestreams.DataSource, error)

OfficialDataSources returns the simplestreams datasources where official image metadata can be found.

func ProductMetadataStoragePath Uses

func ProductMetadataStoragePath() string

ProductMetadataStoragePath returns the storage path for the image metadata products file.

func Sort Uses

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 ValidateImageMetadata Uses

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.

type ImageConstraint Uses

type ImageConstraint struct {

ImageConstraint defines criteria used to find an image metadata record.

func NewImageConstraint Uses

func NewImageConstraint(params simplestreams.LookupParams) *ImageConstraint

func (*ImageConstraint) IndexIds Uses

func (ic *ImageConstraint) IndexIds() []string

IndexIds generates a string array representing product ids formed similarly to an ISCSI qualified name (IQN).

func (*ImageConstraint) ProductIds Uses

func (ic *ImageConstraint) ProductIds() ([]string, error)

ProductIds generates a string array representing product ids formed similarly to an ISCSI qualified name (IQN).

type ImageMetadata Uses

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 Uses

func Fetch(
    sources []simplestreams.DataSource, cons *ImageConstraint,
) ([]*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 Uses

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 Uses

func (im *ImageMetadata) String() string

type MetadataFile Uses

type MetadataFile struct {
    Path string
    Data []byte



Package imagemetadata imports 14 packages (graph). Updated 2020-05-16. Refresh now. Tools for package owners.