types

package
v1.49.0 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2023 License: Apache-2.0 Imports: 16 Imported by: 55

Documentation

Index

Constants

View Source
const (
	SystemConfigFile = "/usr/share/containers/storage.conf"
)

Variables

View Source
var (
	// ErrContainerUnknown indicates that there was no container with the specified name or ID.
	ErrContainerUnknown = errors.New("container not known")
	// ErrDigestUnknown indicates that we were unable to compute the digest of a specified item.
	ErrDigestUnknown = errors.New("could not compute digest of item")
	// ErrDuplicateID indicates that an ID which is to be assigned to a new item is already being used.
	ErrDuplicateID = errors.New("that ID is already in use")
	// ErrDuplicateImageNames indicates that the read-only store uses the same name for multiple images.
	ErrDuplicateImageNames = errors.New("read-only image store assigns the same name to multiple images")
	// ErrDuplicateLayerNames indicates that the read-only store uses the same name for multiple layers.
	ErrDuplicateLayerNames = errors.New("read-only layer store assigns the same name to multiple layers")
	// ErrDuplicateName indicates that a name which is to be assigned to a new item is already being used.
	ErrDuplicateName = errors.New("that name is already in use")
	// ErrImageUnknown indicates that there was no image with the specified name or ID.
	ErrImageUnknown = errors.New("image not known")
	// ErrImageUsedByContainer is returned when the caller attempts to delete an image that is a container's image.
	ErrImageUsedByContainer = errors.New("image is in use by a container")
	// ErrIncompleteOptions is returned when the caller attempts to initialize a Store without providing required information.
	ErrIncompleteOptions = errors.New("missing necessary StoreOptions")
	// ErrInvalidBigDataName indicates that the name for a big data item is not acceptable; it may be empty.
	ErrInvalidBigDataName = errors.New("not a valid name for a big data item")
	// ErrLayerHasChildren is returned when the caller attempts to delete a layer that has children.
	ErrLayerHasChildren = errors.New("layer has children")
	// ErrLayerNotMounted is returned when the requested information can only be computed for a mounted layer, and the layer is not mounted.
	ErrLayerNotMounted = errors.New("layer is not mounted")
	// ErrLayerUnknown indicates that there was no layer with the specified name or ID.
	ErrLayerUnknown = errors.New("layer not known")
	// ErrLayerUsedByContainer is returned when the caller attempts to delete a layer that is a container's layer.
	ErrLayerUsedByContainer = errors.New("layer is in use by a container")
	// ErrLayerUsedByImage is returned when the caller attempts to delete a layer that is an image's top layer.
	ErrLayerUsedByImage = errors.New("layer is in use by an image")
	// ErrLoadError indicates that there was an initialization error.
	ErrLoadError = errors.New("error loading storage metadata")
	// ErrNotAContainer is returned when the caller attempts to delete a container that isn't a container.
	ErrNotAContainer = errors.New("identifier is not a container")
	// ErrNotALayer is returned when the caller attempts to delete a layer that isn't a layer.
	ErrNotALayer = errors.New("identifier is not a layer")
	// ErrNotAnID is returned when the caller attempts to read or write metadata from an item that doesn't exist.
	ErrNotAnID = errors.New("identifier is not a layer, image, or container")
	// ErrNotAnImage is returned when the caller attempts to delete an image that isn't an image.
	ErrNotAnImage = errors.New("identifier is not an image")
	// ErrParentIsContainer is returned when a caller attempts to create a layer as a child of a container's layer.
	ErrParentIsContainer = errors.New("would-be parent layer is a container")
	// ErrParentUnknown indicates that we didn't record the ID of the parent of the specified layer.
	ErrParentUnknown = errors.New("parent of layer not known")
	// ErrSizeUnknown is returned when the caller asks for the size of a big data item, but the Store couldn't determine the answer.
	ErrSizeUnknown = errors.New("size is not known")
	// ErrStoreIsReadOnly is returned when the caller makes a call to a read-only store that would require modifying its contents.
	ErrStoreIsReadOnly = errors.New("called a write method on a read-only store")
	// ErrNotSupported is returned when the requested functionality is not supported.
	ErrNotSupported = errors.New("not supported")
	// ErrInvalidMappings is returned when the specified mappings are invalid.
	ErrInvalidMappings = errors.New("invalid mappings specified")
	// ErrNoAvailableIDs is returned when there are not enough unused IDS within the user namespace.
	ErrNoAvailableIDs = errors.New("not enough unused IDs in user namespace")

	// ErrLayerUnaccounted describes a layer that is present in the lower-level storage driver,
	// but which is not known to or managed by the higher-level driver-agnostic logic.
	ErrLayerUnaccounted = errors.New("layer in lower level storage driver not accounted for")
	// ErrLayerUnreferenced describes a layer which is not used by any image or container.
	ErrLayerUnreferenced = errors.New("layer not referenced by any images or containers")
	// ErrLayerIncorrectContentDigest describes a layer for which the contents of one or more
	// files which were added in the layer appear to have changed.  It may instead look like an
	// unnamed "file integrity checksum failed" error.
	ErrLayerIncorrectContentDigest = errors.New("layer content incorrect digest")
	// ErrLayerIncorrectContentSize describes a layer for which regenerating the diff that was
	// used to populate the layer produced a diff of a different size.  We check the digest
	// first, so it's highly unlikely you'll ever see this error.
	ErrLayerIncorrectContentSize = errors.New("layer content incorrect size")
	// ErrLayerContentModified describes a layer which contains contents which should not be
	// there, or for which ownership/permissions/dates have been changed.
	ErrLayerContentModified = errors.New("layer content modified")
	// ErrLayerDataMissing describes a layer which is missing a big data item.
	ErrLayerDataMissing = errors.New("layer data item is missing")
	// ErrLayerMissing describes a layer which is the missing parent of a layer.
	ErrLayerMissing = errors.New("layer is missing")
	// ErrImageLayerMissing describes an image which claims to have a layer that we don't know
	// about.
	ErrImageLayerMissing = errors.New("image layer is missing")
	// ErrImageDataMissing describes an image which is missing a big data item.
	ErrImageDataMissing = errors.New("image data item is missing")
	// ErrImageDataIncorrectSize describes an image which has a big data item which looks like
	// its size has changed, likely because it's been modified somehow.
	ErrImageDataIncorrectSize = errors.New("image data item has incorrect size")
	// ErrContainerImageMissing describes a container which claims to be based on an image that
	// we don't know about.
	ErrContainerImageMissing = errors.New("image missing")
	// ErrContainerDataMissing describes a container which is missing a big data item.
	ErrContainerDataMissing = errors.New("container data item is missing")
	// ErrContainerDataIncorrectSize describes a container which has a big data item which looks
	// like its size has changed, likely because it's been modified somehow.
	ErrContainerDataIncorrectSize = errors.New("container data item has incorrect size")
)

Functions

func DefaultConfigFile

func DefaultConfigFile(rootless bool) (string, error)

func GetRootlessRuntimeDir

func GetRootlessRuntimeDir(rootlessUID int) (string, error)

GetRootlessRuntimeDir returns the runtime directory when running as non root

func ReloadConfigurationFile

func ReloadConfigurationFile(configFile string, storeOptions *StoreOptions) error

ReloadConfigurationFile parses the specified configuration file and overrides the configuration in storeOptions.

func ReloadConfigurationFileIfNeeded

func ReloadConfigurationFileIfNeeded(configFile string, storeOptions *StoreOptions) error

func Save

func Save(conf TomlConfig, rootless bool) error

Save overwrites the tomlConfig in storage.conf with the given conf

func SetDefaultConfigFilePath

func SetDefaultConfigFilePath(path string) error

SetDefaultConfigFilePath sets the default configuration to the specified path

Types

type AutoUserNsOptions

type AutoUserNsOptions struct {
	// Size defines the size for the user namespace.  If it is set to a
	// value bigger than 0, the user namespace will have exactly this size.
	// If it is not set, some heuristics will be used to find its size.
	Size uint32
	// InitialSize defines the minimum size for the user namespace.
	// The created user namespace will have at least this size.
	InitialSize uint32
	// PasswdFile to use if the container uses a volume.
	PasswdFile string
	// GroupFile to use if the container uses a volume.
	GroupFile string
	// AdditionalUIDMappings specified additional UID mappings to include in
	// the generated user namespace.
	AdditionalUIDMappings []idtools.IDMap
	// AdditionalGIDMappings specified additional GID mappings to include in
	// the generated user namespace.
	AdditionalGIDMappings []idtools.IDMap
}

AutoUserNsOptions defines how to automatically create a user namespace.

type IDMappingOptions

type IDMappingOptions struct {
	// UIDMap and GIDMap are used for setting up a layer's root filesystem
	// for use inside of a user namespace where ID mapping is being used.
	// If HostUIDMapping/HostGIDMapping is true, no mapping of the
	// respective type will be used.  Otherwise, if UIDMap and/or GIDMap
	// contain at least one mapping, one or both will be used.  By default,
	// if neither of those conditions apply, if the layer has a parent
	// layer, the parent layer's mapping will be used, and if it does not
	// have a parent layer, the mapping which was passed to the Store
	// object when it was initialized will be used.
	HostUIDMapping bool
	HostGIDMapping bool
	UIDMap         []idtools.IDMap
	GIDMap         []idtools.IDMap
	AutoUserNs     bool
	AutoUserNsOpts AutoUserNsOptions
}

IDMappingOptions are used for specifying how ID mapping should be set up for a layer or container.

func ParseIDMapping

func ParseIDMapping(UIDMapSlice, GIDMapSlice []string, subUIDMap, subGIDMap string) (*IDMappingOptions, error)

ParseIDMapping takes idmappings and subuid and subgid maps and returns a storage mapping

type StoreOptions

type StoreOptions struct {
	// RunRoot is the filesystem path under which we can store run-time
	// information, such as the locations of active mount points, that we
	// want to lose if the host is rebooted.
	RunRoot string `json:"runroot,omitempty"`
	// GraphRoot is the filesystem path under which we will store the
	// contents of layers, images, and containers.
	GraphRoot string `json:"root,omitempty"`
	// Image Store is the location of image store which is seperated from the
	// container store. Usually this is not recommended unless users wants
	// seperate store for image and containers.
	ImageStore string `json:"imagestore,omitempty"`
	// RootlessStoragePath is the storage path for rootless users
	// default $HOME/.local/share/containers/storage
	RootlessStoragePath string `toml:"rootless_storage_path"`
	// If the driver is not specified, the best suited driver will be picked
	// either from GraphDriverPriority, if specified, or from the platform
	// dependent priority list (in that order).
	GraphDriverName string `json:"driver,omitempty"`
	// GraphDriverPriority is a list of storage drivers that will be tried
	// to initialize the Store for a given RunRoot and GraphRoot unless a
	// GraphDriverName is set.
	// This list can be used to define a custom order in which the drivers
	// will be tried.
	GraphDriverPriority []string `json:"driver-priority,omitempty"`
	// GraphDriverOptions are driver-specific options.
	GraphDriverOptions []string `json:"driver-options,omitempty"`
	// UIDMap and GIDMap are used for setting up a container's root filesystem
	// for use inside of a user namespace where UID mapping is being used.
	UIDMap []idtools.IDMap `json:"uidmap,omitempty"`
	GIDMap []idtools.IDMap `json:"gidmap,omitempty"`
	// RootAutoNsUser is the user used to pick a subrange when automatically setting
	// a user namespace for the root user.
	RootAutoNsUser string `json:"root_auto_ns_user,omitempty"`
	// AutoNsMinSize is the minimum size for an automatic user namespace.
	AutoNsMinSize uint32 `json:"auto_userns_min_size,omitempty"`
	// AutoNsMaxSize is the maximum size for an automatic user namespace.
	AutoNsMaxSize uint32 `json:"auto_userns_max_size,omitempty"`
	// PullOptions specifies options to be handed to pull managers
	// This API is experimental and can be changed without bumping the major version number.
	PullOptions map[string]string `toml:"pull_options"`
	// DisableVolatile doesn't allow volatile mounts when it is set.
	DisableVolatile bool `json:"disable-volatile,omitempty"`
	// If transient, don't persist containers over boot (stores db in runroot)
	TransientStore bool `json:"transient_store,omitempty"`
}

StoreOptions is used for passing initialization options to GetStore(), for initializing a Store object and the underlying storage that it controls.

func DefaultStoreOptions

func DefaultStoreOptions(rootless bool, rootlessUID int) (StoreOptions, error)

DefaultStoreOptions returns the default storage ops for containers

func DefaultStoreOptionsAutoDetectUID

func DefaultStoreOptionsAutoDetectUID() (StoreOptions, error)

DefaultStoreOptionsAutoDetectUID returns the default storage ops for containers

func Options

func Options() (StoreOptions, error)

func UpdateStoreOptions

func UpdateStoreOptions(rootless bool, rootlessUID int) (StoreOptions, error)

UpdateOptions should be called iff container engine received a SIGHUP, otherwise use DefaultStoreOptions

type TomlConfig

type TomlConfig struct {
	Storage struct {
		Driver              string            `toml:"driver,omitempty"`
		DriverPriority      []string          `toml:"driver_priority,omitempty"`
		RunRoot             string            `toml:"runroot,omitempty"`
		ImageStore          string            `toml:"imagestore,omitempty"`
		GraphRoot           string            `toml:"graphroot,omitempty"`
		RootlessStoragePath string            `toml:"rootless_storage_path,omitempty"`
		TransientStore      bool              `toml:"transient_store,omitempty"`
		Options             cfg.OptionsConfig `toml:"options,omitempty"`
	} `toml:"storage"`
}

TOML-friendly explicit tables used for conversions.

func StorageConfig

func StorageConfig(rootless bool) (*TomlConfig, error)

StorageConfig is used to retrieve the storage.conf toml in order to overwrite it

Jump to

Keyboard shortcuts

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