Documentation ¶
Index ¶
- Constants
- Variables
- func CreateAliases(distro string, release string, variant string) []string
- func GetProducts(rootDir string, streamRelPath string, options ...Option) (map[string]Product, error)
- func ReadChecksumFile(path string) (map[string]string, error)
- type Item
- type ItemExt
- type ItemType
- type Option
- type Product
- type ProductCatalog
- type StreamIndex
- type StreamIndexEntry
- type Version
Constants ¶
const ( // FileChecksumSHA256 is the name of the checksum file containing SHA256 hashes. FileChecksumSHA256 = "SHA256SUMS" // FileImageConfig is the name of the file that contains additional information // about the version. FileImageConfig = "image.yaml" )
Static list of file names.
const ( // ItemTypeMetadata represents the LXD metadata file. ItemTypeMetadata = "lxd.tar.xz" // ItemTypeSquashfs represents container's root file system (squashfs). ItemTypeSquashfs = "squashfs" // ItemTypeSquashfsDelta represents container's root file system delta (VCDiff). ItemTypeSquashfsDelta = "squashfs.vcdiff" // ItemTypeDiskKVM represents VM's root file system (qcow2). ItemTypeDiskKVM = "disk-kvm.img" // ItemTypeDiskKVMDelta represents VM's root file system delta (VCDiff). ItemTypeDiskKVMDelta = "disk-kvm.img.vcdiff" // ItemTypeRootTarXz represents root file system as a tarball. ItemTypeRootTarXz = "root.tar.xz" )
const ( // ItemExtMetadata is a file extension of LXD metadata file. ItemExtMetadata = ".tar.xz" // ItemExtSquashfs is a file extension of container's root file system. ItemExtSquashfs = ".squashfs" // ItemExtSquashfsDelta is a file extension of container's root file system delta (VCDiff). ItemExtSquashfsDelta = ".vcdiff" // ItemExtDiskKVM is a file extension of VM's root file system. ItemExtDiskKVM = ".qcow2" // ItemExtDiskKVMDelta is a file extension of VM's root file system delta (VCDiff). ItemExtDiskKVMDelta = ".qcow2.vcdiff" )
Variables ¶
var ( // ErrVersionIncomplete indicates that version is missing some files. // For a version to be complete, a metadata and at least one root // filesystem (qcow2/squashfs) must be present. ErrVersionIncomplete = errors.New("Product version is incomplete") // ErrVersionInvalidImageConfig indicates version's image config is invalid. ErrVersionInvalidImageConfig = errors.New("Product version has invalid image config") // ErrProductInvalidPath indicates that product's path is invalid because // either the directory on the given path does not exist, or it's path // does not match the expected format. ErrProductInvalidPath = errors.New("Invalid product path") )
Functions ¶
func CreateAliases ¶
CreateAliases creates aliases from the given distro, release, and variant. It appends them to the aliases slice and returns the updated slice.
Types ¶
type Item ¶
type Item struct { // Type of the file. A known ItemType is used if possible, otherwise, // this field is equal to the file's name. Ftype string `json:"ftype"` // Path of the file relative to the root directory (the directory where // the simplestream content is hosted from). Path string `json:"path"` // Size of file. Size int64 `json:"size"` // SHA256 hash of the file. SHA256 string `json:"sha256,omitempty"` // CombinedSHA256DiskKvmImg stores the combined SHA256 hash of the metadata // and VM file system (qcow2) files. This field is set only for the metadata // item when both files exist in the same product version. CombinedSHA256DiskKvmImg string `json:"combined_disk-kvm-img_sha256,omitempty"` // CombinedSHA256DiskKvmImg stores the combined SHA256 hash of the metadata // and container file system (squashfs) files. This field is set only for // the metadata item when both files exist in the same product version. CombinedSHA256SquashFs string `json:"combined_squashfs_sha256,omitempty"` // CombinedSHA256RootXz stores the combined SHA256 hash of the metadata and // root file system tarball files. This field is set only for the metadata // item when both files exist in the same product version. CombinedSHA256RootXz string `json:"combined_rootxz_sha256,omitempty"` // DeltaBase indicates the version from which the delta (.vcdiff) file was // calculated from. This field is set only for the delta items. DeltaBase string `json:"delta_base,omitempty"` }
Item represents a file within a product version.
type Option ¶
type Option func(*options)
Option to modify the fetching behavior.
func WithHashes ¶
WithHashes ensures that item hashes are calculated.
func WithIncompleteVersions ¶
WithIncompleteVersions ensures incomplete versions are included when retrieving a version or products.
type Product ¶
type Product struct { // List of aliases using which the product (image) can be referenced. Aliases string `json:"aliases"` // Architecture the image was built for. For example amd64. Architecture string `json:"arch"` // Name of the image distribution. Distro string `json:"distro"` // Pretty name of the operating system. OS string `json:"os"` // Name of the image release. Release string `json:"release"` // Release title or in other words pretty display name. ReleaseTitle string `json:"release_title"` // Name of the image variant. Variant string `json:"variant"` // Map of image versions, where the map key represents the version name. Versions map[string]Version `json:"versions,omitempty"` // Map of the requirements that need to be satisfied in order for the // image to work. Map key represents the configuration key and map // value the expected configuration value. Requirements map[string]string `json:"requirements"` }
Product represents a single image with all its available versions.
func GetProduct ¶
GetProduct reads the product on the given path including all of its versions. Product's relative path must match the predetermined format, otherwise, an error is returned.
type ProductCatalog ¶
type ProductCatalog struct { // ContentID (e.g. images). ContentID string `json:"content_id"` // Format of the product catalog (e.g. products:1.0). Format string `json:"format"` // Data type of the product catalog (e.g. image-downloads). DataType string `json:"datatype"` // Map of products, where the map key represents a product ID. Products map[string]Product `json:"products"` }
ProductCatalog contains all products.
func NewCatalog ¶
func NewCatalog(streamName string, products map[string]Product) *ProductCatalog
NewCatalog creates a new product catalog.
type StreamIndex ¶
type StreamIndex struct { Format string `json:"format"` Index map[string]StreamIndexEntry `json:"index"` }
func (*StreamIndex) AddEntry ¶
func (i *StreamIndex) AddEntry(streamName string, catalogPath string, catalog ProductCatalog)
AddEntry adds catalog and a list of its products to the index.
type StreamIndexEntry ¶
type Version ¶
type Version struct { // Checksums of files within the version. Checksums map[string]string `json:"-"` // ImageConfig contains additional information about the product version. ImageConfig shared.DefinitionSimplestream `json:"-"` // Map of items found within the version, where the map key // represents file name. Items map[string]Item `json:"items,omitempty"` // contains filtered or unexported fields }
Version represents a list of items available for the given image version.
func GetVersion ¶
GetVersion retrieves metadata for a single version, by reading directory files and converting those that should be incuded in the product catalog into items. For the relevant items, the file hashes are calculated, if calcHashes is set to true.