util

package
v1.27.4 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: Apache-2.0 Imports: 25 Imported by: 51

Documentation

Index

Constants

View Source
const (
	// DefaultRuntime if containers.conf fails.
	DefaultRuntime = define.DefaultRuntime
)
View Source
const (

	// DefaultTransport is a prefix that we apply to an image name if we
	// can't find one in the local Store, in order to generate a source
	// reference for the image that we can then copy to the local Store.
	DefaultTransport = "docker://"
)

Variables

View Source
var (
	// DefaultCapabilities is the list of capabilities which we grant by
	// default to containers which are running under UID 0.
	DefaultCapabilities = define.DefaultCapabilities

	// DefaultNetworkSysctl is the list of Kernel parameters which we
	// grant by default to containers which are running under UID 0.
	DefaultNetworkSysctl = define.DefaultNetworkSysctl
)
View Source
var (
	// RegistryDefaultPathPrefix contains a per-registry listing of default prefixes
	// to prepend to image names that only contain a single path component.
	RegistryDefaultPathPrefix = map[string]string{
		"index.docker.io": "library",
		"docker.io":       "library",
	}
)

Functions

func AddImageNames

func AddImageNames(store storage.Store, firstRegistry string, systemContext *types.SystemContext, image *storage.Image, addNames []string) error

AddImageNames adds the specified names to the specified image. Please note that the `firstRegistry` argument has been deprecated and has no effect anymore.

func Cause added in v1.27.0

func Cause(err error) (cause error)

Cause returns the most underlying error for the provided one. There is a maximum error depth of 100 to avoid endless loops. An additional error log message will be created if this maximum has reached.

func ExpandNames

func ExpandNames(names []string, systemContext *types.SystemContext, store storage.Store) ([]string, error)

ExpandNames takes unqualified names, parses them as image names, and returns the fully expanded result, including a tag. Names which don't include a registry name will be marked for the most-preferred registry (i.e., the first one in our configuration).

func FindImage

func FindImage(store storage.Store, firstRegistry string, systemContext *types.SystemContext, image string) (types.ImageReference, *storage.Image, error)

FindImage locates the locally-stored image which corresponds to a given name. Please note that the `firstRegistry` argument has been deprecated and has no effect anymore.

func FindLocalRuntime added in v1.14.1

func FindLocalRuntime(runtime string) string

FindLocalRuntime find the local runtime of the system searching through the config file for possible locations.

func GID added in v1.14.3

func GID(st os.FileInfo) int

func GetContainerIDs added in v1.8.4

func GetContainerIDs(uidmap, gidmap []specs.LinuxIDMapping, uid, gid uint32) (uint32, uint32, error)

GetContainerIDs uses ID mappings to compute the container-level IDs that will correspond to a UID/GID pair on the host.

func GetFailureCause

func GetFailureCause(err, defaultError error) error

GetFailureCause checks the type of the error "err" and returns a new error message that reflects the reason of the failure. In case err type is not a familiar one the error "defaultError" is returned.

func GetHostIDs added in v1.7.1

func GetHostIDs(uidmap, gidmap []specs.LinuxIDMapping, uid, gid uint32) (uint32, uint32, error)

GetHostIDs uses ID mappings to compute the host-level IDs that will correspond to a UID/GID pair in the container.

func GetHostRootIDs added in v1.7.1

func GetHostRootIDs(spec *specs.Spec) (uint32, uint32, error)

GetHostRootIDs uses ID mappings in spec to compute the host-level IDs that will correspond to UID/GID 0/0 in the container.

func GetPolicyContext added in v1.7.1

func GetPolicyContext(ctx *types.SystemContext) (*signature.PolicyContext, error)

GetPolicyContext sets up, initializes and returns a new context for the specified policy

func IsCgroup2UnifiedMode added in v1.13.2

func IsCgroup2UnifiedMode() (bool, error)

IsCgroup2UnifiedMode returns whether we are running in cgroup 2 cgroup2 mode.

func LogIfNotRetryable added in v1.7.1

func LogIfNotRetryable(err error, what string) (retry bool)

LogIfNotRetryable logs "what" if err is set and is not an EINTR or EAGAIN syscall.Errno. Returns "true" if we can continue.

func LogIfUnexpectedWhileDraining added in v1.7.1

func LogIfUnexpectedWhileDraining(err error, what string)

LogIfUnexpectedWhileDraining logs "what" if err is set and is not an EINTR or EAGAIN or EIO syscall.Errno.

func MergeEnv added in v1.16.0

func MergeEnv(defaults, overrides []string) []string

MergeEnv merges two lists of environment variables, avoiding duplicates.

func ResolveNameToReferences added in v1.14.1

func ResolveNameToReferences(
	store storage.Store,
	systemContext *types.SystemContext,
	image string,
) (refs []types.ImageReference, err error)

resolveNameToReferences tries to create a list of possible references (including their transports) from the provided image name.

func Runtime added in v1.7.1

func Runtime() string

Runtime is the default command to use to run the container.

func SortMounts added in v1.20.1

func SortMounts(m []specs.Mount) []specs.Mount

func StringInSlice added in v1.7.1

func StringInSlice(s string, slice []string) bool

StringInSlice is deprecated, use github.com/containers/common/pkg/util.StringInSlice

func TruncateString added in v1.11.1

func TruncateString(str string, to int) string

TruncateString trims the given string to the provided maximum amount of characters and shortens it with `...`.

func UID added in v1.14.3

func UID(st os.FileInfo) int

func VerifyTagName added in v1.21.0

func VerifyTagName(imageSpec string) (types.ImageReference, error)

func WriteError added in v1.7.1

func WriteError(w io.Writer, err error, lastError error) error

WriteError writes `lastError` into `w` if not nil and return the next error `err`

Types

type HardlinkChecker added in v1.11.0

type HardlinkChecker struct {
	// contains filtered or unexported fields
}

func (*HardlinkChecker) Add added in v1.11.0

func (h *HardlinkChecker) Add(fi os.FileInfo, name string)

func (*HardlinkChecker) Check added in v1.11.0

func (h *HardlinkChecker) Check(fi os.FileInfo) string

Jump to

Keyboard shortcuts

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