image

package
v3.1.1-rc1+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 28, 2019 License: BSD-3-Clause Imports: 12 Imported by: 0

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 preform some action,
                        such as extracting the filesystem to a dir.

}

Index

Constants

View Source
const (
	// SQUASHFS constant for squashfs format
	SQUASHFS = iota + 1
	// EXT3 constant for ext3 format
	EXT3
	// SANDBOX constant for directory format
	SANDBOX
	// SIF constant for sif format
	SIF
)
View Source
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")
)
View Source
const (
	// RootFs partition name
	RootFs = "rootfs"
)

Variables

This section is empty.

Functions

func CheckExt3Header

func CheckExt3Header(b []byte) (uint64, error)

CheckExt3Header checks if byte content contains a valid ext3 header and returns offset where ext3 partition begin

func CheckSquashfsHeader

func CheckSquashfsHeader(b []byte) (uint64, error)

CheckSquashfsHeader checks if byte content contains a valid squashfs header and returns offset where squashfs partition start

func NewPartitionReader

func NewPartitionReader(image *Image, name string, index int) (io.Reader, error)

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

func NewSectionReader(image *Image, name string, index int) (io.Reader, error)

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

func ResolvePath(path string) (string, error)

ResolvePath returns a resolved absolute path

Types

type Image

type Image struct {
	Path       string    `json:"path"`
	Name       string    `json:"name"`
	Type       int       `json:"type"`
	File       *os.File  `json:"-"`
	Fd         uintptr   `json:"fd"`
	Source     string    `json:"source"`
	Writable   bool      `json:"writable"`
	Partitions []Section `json:"partitions"`
	Sections   []Section `json:"sections"`
}

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 Init

func Init(path string, writable bool) (*Image, error)

Init initializes an image object based on given path

func (*Image) AuthorizedGroup

func (i *Image) AuthorizedGroup(groups []string) (bool, error)

AuthorizedGroup checks if image is owned by group supplied in groups list

func (*Image) AuthorizedOwner

func (i *Image) AuthorizedOwner(owners []string) (bool, error)

AuthorizedOwner checks if image is owned by user supplied in users list

func (*Image) AuthorizedPath

func (i *Image) AuthorizedPath(paths []string) (bool, error)

AuthorizedPath checks if image is in a path supplied in paths

type Section

type Section struct {
	Size   uint64 `json:"size"`
	Offset uint64 `json:"offset"`
	Type   uint32 `json:"type"`
	Name   string `json:"name"`
}

Section identifies and locates a data section in image object.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL