Documentation
¶
Index ¶
- Constants
- Variables
- func AllMimeTypes() []string
- func GetConfigMediaType(actualType string, format Format) string
- func GetLayerMediaType(actualType string, format Format) string
- func IsConfigType(mediaType string) bool
- type Artifact
- type ConfigOpts
- type DirTarget
- type Disk
- type DiskType
- type FileSource
- type FilesTarget
- func (f *FilesTarget) Close() error
- func (f *FilesTarget) Ingester() IngesterCloser
- func (f *FilesTarget) MultiWriter() bool
- func (f *FilesTarget) Writer(ctx context.Context, opts ...ctrcontent.WriterOpt) (ctrcontent.Writer, error)
- func (f *FilesTarget) Writers(ctx context.Context, opts ...ctrcontent.WriterOpt) (func(name string) (ctrcontent.Writer, error), error)
- type Format
- type HashSource
- type IngesterCloser
- type LegacyOpt
- type MemorySource
- type Puller
- type Pusher
- type Source
- type Target
Constants ¶
const ( AnnotationMediaType = "org.lfedge.eci.mediaType" AnnotationRole = "org.lfedge.eci.role" AnnotationRootPath = "org.lfedge.eci.artifact.root" AnnotationInitrdPath = "org.lfedge.eci.artifact.initrd" AnnotationKernelPath = "org.lfedge.eci.artifact.kernel" AnnotationDiskIndexPathPattern = "org.lfedge.eci.artifact.disk-%d" AnnotationOther = "org.lfedge.eci.other" )
const ( MimeTypeECIConfig = "application/vnd.lfedge.eci.config.v1+json" MimeTypeECIKernel = "application/vnd.lfedge.eci.kernel.layer.v1+kernel" MimeTypeECIInitrd = "application/vnd.lfedge.eci.initrd.layer.v1+cpio" MimeTypeECIDiskRaw = "application/vnd.lfedge.disk.layer.v1+raw" MimeTypeECIDiskVhd = "application/vnd.lfedge.disk.layer.v1+vhd" MimeTypeECIDiskVmdk = "application/vnd.lfedge.disk.layer.v1+vmdk" MimeTypeECIDiskISO = "application/vnd.lfedge.disk.layer.v1+iso" MimeTypeECIDiskQcow = "application/vnd.lfedge.disk.layer.v1+qcow" MimeTypeECIDiskQcow2 = "application/vnd.lfedge.disk.layer.v1+qcow2" MimeTypeECIDiskOva = "application/vnd.lfedge.disk.layer.v1+ova" MimeTypeECIDiskVhdx = "application/vnd.lfedge.disk.layer.v1+vhdx" MimeTypeECIOther = "application/vnd.lfedge.eci.layer.v1" MimeTypeOCIImageConfig = ocispec.MediaTypeImageConfig MimeTypeOCIImageLayer = ocispec.MediaTypeImageLayer MimeTypeOCIImageLayerGzip = ocispec.MediaTypeImageLayerGzip MimeTypeOCIImageManifest = ocispec.MediaTypeImageManifest MimeTypeOCIImageIndex = ocispec.MediaTypeImageIndex MimeTypeDockerImageConfig = images.MediaTypeDockerSchema2Config MimeTypeDockerImageManifest = images.MediaTypeDockerSchema2Manifest MimeTypeDockerImageIndex = images.MediaTypeDockerSchema2ManifestList MimeTypeDockerLayerTarGzip = images.MediaTypeDockerSchema2LayerGzip MimeTypeDockerLayerTar = images.MediaTypeDockerSchema2Layer )
const ( DefaultAuthor = "lf-edge/edge-containers" DefaultOS = runtime.GOOS DefaultArch = runtime.GOARCH )
const ( RoleKernel = "kernel" RoleInitrd = "initrd" RoleRootDisk = "disk-root" RoleAdditionalDisk = "disk-additional" )
Variables ¶
var MimeToType = map[string]DiskType{ MimeTypeECIDiskRaw: Raw, MimeTypeECIDiskVhd: Vhd, MimeTypeECIDiskVmdk: Vmdk, MimeTypeECIDiskISO: ISO, MimeTypeECIDiskQcow: Qcow, MimeTypeECIDiskQcow2: Qcow2, MimeTypeECIDiskOva: Ova, MimeTypeECIDiskVhdx: Vhdx, }
var NameToType = map[string]DiskType{ "raw": Raw, "vmdk": Vmdk, "vhd": Vhd, "iso": ISO, "qcow": Qcow, "qcow2": Qcow2, "ova": Ova, "vhdx": Vhdx, }
var TypeToMime = map[DiskType]string{ Raw: MimeTypeECIDiskRaw, Vhd: MimeTypeECIDiskVhd, Vmdk: MimeTypeECIDiskVmdk, ISO: MimeTypeECIDiskISO, Qcow: MimeTypeECIDiskQcow, Qcow2: MimeTypeECIDiskQcow2, Ova: MimeTypeECIDiskOva, Vhdx: MimeTypeECIDiskVhdx, }
Functions ¶
func AllMimeTypes ¶
func AllMimeTypes() []string
func GetConfigMediaType ¶
func GetLayerMediaType ¶
func IsConfigType ¶
Types ¶
type Artifact ¶
type Artifact struct { // Kernel path to the kernel file Kernel Source // Initrd path to the initrd file Initrd Source // Config path to the config Config Source // Root path to the root disk and its type Root *Disk // Disks paths and types for additional disks Disks []*Disk // Other other items that did not have appropriate annotations Other []Source }
type ConfigOpts ¶
type DirTarget ¶
type DirTarget struct {
Dir string
}
DirTarget save the entire contents to a single directory.
func (DirTarget) Ingester ¶
func (d DirTarget) Ingester() IngesterCloser
Ingester get the IngesterCloser
func (DirTarget) MultiWriter ¶
MultiWriter does this support multiwriter
type FileSource ¶
type FileSource struct { // Path path to the file source Path string }
FileSource implements a Source for a file
func (*FileSource) GetContent ¶
func (f *FileSource) GetContent() []byte
func (*FileSource) GetDigest ¶
func (f *FileSource) GetDigest() string
func (*FileSource) GetName ¶
func (f *FileSource) GetName() string
func (*FileSource) GetPath ¶
func (f *FileSource) GetPath() string
func (*FileSource) GetSize ¶
func (f *FileSource) GetSize() int64
type FilesTarget ¶
type FilesTarget struct { // Kernel writer where to write the kernel Kernel io.Writer // Initrd writer where to write the initrd Initrd io.Writer // Config writer where to write the config Config io.Writer // Root writer where to write the root disk Root io.Writer // Disks writers where to write each additional disk Disks []io.Writer // Other writer where to write the other elements Other []io.Writer // BlockSize how big a blocksize to use when reading/writing. Defaults to whatever io.Copy uses BlockSize int // AcceptHash if set to true, accept the hash in the descriptor as is, i.e. do not recalculate it AcceptHash bool // contains filtered or unexported fields }
FilesTarget provides targets for each file type. If a type is nil, its content is ignored
func (*FilesTarget) Close ¶
func (f *FilesTarget) Close() error
Close close anything that might be open
func (*FilesTarget) Ingester ¶
func (f *FilesTarget) Ingester() IngesterCloser
Ingester get the IngesterCloser
func (*FilesTarget) MultiWriter ¶
func (f *FilesTarget) MultiWriter() bool
MultiWriter does this support multiwriter
func (*FilesTarget) Writer ¶
func (f *FilesTarget) Writer(ctx context.Context, opts ...ctrcontent.WriterOpt) (ctrcontent.Writer, error)
Writer get a writer
func (*FilesTarget) Writers ¶
func (f *FilesTarget) Writers(ctx context.Context, opts ...ctrcontent.WriterOpt) (func(name string) (ctrcontent.Writer, error), error)
Writers get writers by filename
type HashSource ¶
type HashSource struct { // Hash the sha256 hash Hash string // Name of file to save Name string // Size size of the target Size int64 }
HashSource implements a source that has the hash directly, to enable creating a raw manifest
func (*HashSource) GetContent ¶
func (h *HashSource) GetContent() []byte
func (*HashSource) GetDigest ¶
func (h *HashSource) GetDigest() string
func (*HashSource) GetName ¶
func (h *HashSource) GetName() string
func (*HashSource) GetPath ¶
func (h *HashSource) GetPath() string
func (*HashSource) GetSize ¶
func (h *HashSource) GetSize() int64
type IngesterCloser ¶
type IngesterCloser interface { ctrcontent.Ingester io.Closer }
IngesterCloser an ingester that also has a Close(). May return nil
type LegacyOpt ¶
type LegacyOpt func(*legacyInfo)
func WithTimestamp ¶
WithTimestamp sets the timestamp to use for each file's tar header, else uses current time
func WithTmpDir ¶
WithTmpDir sets the temporary directory to use for tar/gzip the files. It is up to the caller to clean it up when done.
type MemorySource ¶
MemorySource implements a Source for raw data
func (*MemorySource) GetContent ¶
func (m *MemorySource) GetContent() []byte
func (*MemorySource) GetDigest ¶
func (m *MemorySource) GetDigest() string
func (*MemorySource) GetName ¶
func (m *MemorySource) GetName() string
func (*MemorySource) GetPath ¶
func (m *MemorySource) GetPath() string
func (*MemorySource) GetSize ¶
func (m *MemorySource) GetSize() int64
type Puller ¶
type Puller struct { // Image reference to image, e.g. docker.io/foo/bar:tagabc Image string // Impl the OCI artifacts puller. Normally should be left blank, will be filled in to use oras. Override only for special cases like testing. Impl func(ctx context.Context, resolver remotes.Resolver, ref string, ingester ctrcontent.Ingester, opts ...oras.PullOpt) (ocispec.Descriptor, []ocispec.Descriptor, error) }
func (*Puller) Config ¶
func (p *Puller) Config(verbose bool, writer io.Writer, resolver ecresolver.ResolverCloser) (*ocispec.Descriptor, *ocispec.Image, error)
Config pull the config for the artifact from the appropriate registry and return it as an object
The resolver provides the channel to connect to the target type. resolver.Registry just uses the default registry, while resolver.Directory uses a local directory, etc.
func (*Puller) Pull ¶
func (p *Puller) Pull(target Target, blocksize int, verbose bool, writer io.Writer, resolver ecresolver.ResolverCloser) (*ocispec.Descriptor, *Artifact, error)
Pull pull the artifact from the appropriate registry and save it to a local directory. Arguments are the dir where to write it, an io.Writer for logging output, and a target.
The resolver provides the channel to connect to the target type. resolver.Registry just uses the default registry, while resolver.Directory uses a local directory, etc.
type Pusher ¶
type Pusher struct { // Artifact artifact to push Artifact *Artifact // Image reference to image, e.g. docker.io/foo/bar:tagabc Image string // Timestamp set any files to have this timestamp, instead of the default of the file time Timestamp *time.Time // Impl the OCI artifacts pusher. Normally should be left blank, will be filled in to use oras. Override only for special cases like testing. Impl func(ctx context.Context, resolver remotes.Resolver, ref string, provider ctrcontent.Provider, descriptors []ocispec.Descriptor, opts ...oras.PushOpt) (ocispec.Descriptor, error) }
func (Pusher) Push ¶
func (p Pusher) Push(format Format, verbose bool, writer io.Writer, configOpts ConfigOpts, resolver ecresolver.ResolverCloser) (string, error)
Push push the artifact to the appropriate registry. Arguments are the format to write, an io.Writer for sending debug output, ConfigOpts to configure how the image should be configured, and a target.
The target determines the target type. target.Registry just uses the default registry, while target.Directory uses a local directory.
type Source ¶
type Source interface { // GetPath get path to a file, returns "" if no file GetPath() string // GetContent get the actual content if in memory, returns nil if in a file GetContent() []byte // GetName returns the target filename GetName() string // GetDigest returns the digest if provided directly; will not calculate for other sources. // Format is "sha256:<hash>" GetDigest() string // GetSize returns the size if provided directly; will not calculate for other sources. GetSize() int64 }
Source a source for an artifact component
type Target ¶
type Target interface { Ingester() IngesterCloser MultiWriter() bool }
Target a target where to send the contents of the artifact. May also handle processing config.