Documentation ¶
Overview ¶
Package image provides underlying data types for Singularity image formats. Additionally, all image types will satisfy the ImageFormat{} interface. This interface will expose all things necessary to use a Singularity image, whether through OCI or directly.
type ImageFormat interface { Root() *spec.Root - Root() returns the OCI compliant root of the Image. This function may perform some action, such as extracting the filesystem to a dir. }
Index ¶
- Constants
- Variables
- func CheckExt3Header(b []byte) (uint64, error)
- func CheckSquashfsHeader(b []byte) (uint64, error)
- func GetSquashfsComp(b []byte) (string, error)
- func IsOCISIF(filename string) (bool, error)
- func IsReadOnlyFilesytem(err error) bool
- func NewPartitionReader(image *Image, name string, index int) (io.Reader, error)
- func NewSectionReader(image *Image, name string, index int) (io.Reader, error)
- func ResolvePath(path string) (string, error)
- type Image
- func (i *Image) AuthorizedGroup(groups []string) (bool, error)
- func (i *Image) AuthorizedOwner(owners []string) (bool, error)
- func (i *Image) AuthorizedPath(paths []string) (bool, error)
- func (i *Image) GetAllPartitions() ([]Section, error)
- func (i *Image) GetDataPartitions() ([]Section, error)
- func (i *Image) GetOverlayPartitions() ([]Section, error)
- func (i *Image) GetRootFsPartition() (*Section, error)
- func (i *Image) GetRootFsPartitions() ([]Section, error)
- func (i *Image) HasEncryptedRootFs() (encrypted bool, err error)
- type Section
- type Usage
Constants ¶
const ( // SQUASHFS constant for squashfs format SQUASHFS = iota + 0x1000 // EXT3 constant for ext3 format EXT3 // SANDBOX constant for directory format SANDBOX // SIF constant for sif format (native image, not OCI-SIF) SIF // ENCRYPTSQUASHFS constant for encrypted squashfs format ENCRYPTSQUASHFS // RAW constant for raw format RAW // OCISIF constant for OCI-SIF images OCISIF )
const ( // RootFsUsage defines flag for image/partition // usable as root filesystem. RootFsUsage = Usage(1 << iota) // OverlayUsage defines flag for image/partition // usable as overlay. OverlayUsage // DataUsage defines flag for image/partition // usable as data. DataUsage )
const ( // ErrNoSection corresponds to an image section not found. ErrNoSection = readerError("no section found") // ErrNoPartition corresponds to an image partition not found. ErrNoPartition = readerError("no partition found") )
const ( // SIFDescOCIConfigJSON is the name of the SIF descriptor holding the OCI configuration. SIFDescOCIConfigJSON = "oci-config.json" // SIFDescInspectMetadataJSON is the name of the SIF descriptor holding the container metadata. SIFDescInspectMetadataJSON = "inspect-metadata.json" )
const (
// RootFs partition name
RootFs = "!__rootfs__!"
)
Variables ¶
var ErrUnknownFormat = errors.New("image format not recognized")
ErrUnknownFormat represents an unknown image format error.
Functions ¶
func CheckExt3Header ¶
CheckExt3Header checks if byte content contains a valid ext3 header and returns offset where ext3 partition begin
func CheckSquashfsHeader ¶
CheckSquashfsHeader checks if byte content contains a valid squashfs header and returns offset where squashfs partition starts
func GetSquashfsComp ¶
GetSquashfsComp checks if byte content contains a valid squashfs header and returns type of compression used
func IsOCISIF ¶ added in v4.1.0
IsOCISIF receives a path to an image file and returns a boolean indicating whether the file is an OCI-SIF image.
func IsReadOnlyFilesytem ¶
IsReadOnlyFilesytem returns if the corresponding error is a read-only filesystem error or not.
func NewPartitionReader ¶
NewPartitionReader searches and returns a reader for an image partition identified by name or by index, if index is less than 0 only partition with provided name will be returned if a matching entry is found
func NewSectionReader ¶
NewSectionReader searches and returns a reader for an image section identified by name or by index, if index is less than 0 only section with provided name will be returned if a matching entry is found.
func ResolvePath ¶
ResolvePath returns a resolved absolute path.
Types ¶
type Image ¶
type Image struct { Partitions []Section `json:"partitions"` Sections []Section `json:"sections"` Path string `json:"path"` Name string `json:"name"` Source string `json:"source"` Type int `json:"type"` File *os.File `json:"-"` Fd uintptr `json:"fd"` Writable bool `json:"writable"` Usage Usage `json:"usage"` }
Image describes an image object, an image is composed of one or more partitions (eg: container root filesystem, overlay), image format like SIF contains descriptors pointing to chunk of data, chunks position and size are stored as image sections.
func (*Image) AuthorizedGroup ¶
AuthorizedGroup checks whether the image is owned by any group from the supplied groups list.
func (*Image) AuthorizedOwner ¶
AuthorizedOwner checks whether the image is owned by any user from the supplied users list.
func (*Image) AuthorizedPath ¶
AuthorizedPath checks if image is in a path supplied in paths
func (*Image) GetAllPartitions ¶
GetAllPartitions returns all partitions found in the image.
func (*Image) GetDataPartitions ¶
GetDataPartitions returns data partitions found in the image.
func (*Image) GetOverlayPartitions ¶
GetOverlayPartitions returns overlay partitions found in the image.
func (*Image) GetRootFsPartition ¶
GetRootFsPartition returns the first root filesystem partition found in the image.
func (*Image) GetRootFsPartitions ¶
GetRootFsPartitions returns root filesystem partitions found in the image.
func (*Image) HasEncryptedRootFs ¶
HasEncryptedRootFs returns true if the image contains an encrypted rootfs partition.
type Section ¶
type Section struct { Name string `json:"name"` Size uint64 `json:"size"` Offset uint64 `json:"offset"` ID uint32 `json:"id"` Type uint32 `json:"type"` AllowedUsage Usage `json:"allowed_usage"` // Architecture is only known for system partitions in SIF files. Architecture string `json:"architecture,omitempty"` }
Section identifies and locates a data section in image object.