util

package
v3.4.7 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2022 License: Apache-2.0 Imports: 30 Imported by: 28

Documentation

Index

Constants

View Source
const (
	// Kube annotation for podman volume driver.
	VolumeDriverAnnotation = "volume.podman.io/driver"
	// Kube annotation for podman volume type.
	VolumeTypeAnnotation = "volume.podman.io/type"
	// Kube annotation for podman volume device.
	VolumeDeviceAnnotation = "volume.podman.io/device"
	// Kube annotation for podman volume UID.
	VolumeUIDAnnotation = "volume.podman.io/uid"
	// Kube annotation for podman volume GID.
	VolumeGIDAnnotation = "volume.podman.io/gid"
	// Kube annotation for podman volume mount options.
	VolumeMountOptsAnnotation = "volume.podman.io/mount-options"
)
View Source
const DefaultCPUPeriod uint64 = 100000

DefaultCPUPeriod is the default CPU period is 100us, which is the same default as Kubernetes.

Variables

View Source
var (
	// ErrBadMntOption indicates that an invalid mount option was passed.
	ErrBadMntOption = errors.Errorf("invalid mount option")
	// ErrDupeMntOption indicates that a duplicate mount option was passed.
	ErrDupeMntOption = errors.Errorf("duplicate mount option passed")
)

Functions

func ComputeUntilTimestamp added in v3.1.0

func ComputeUntilTimestamp(filterValues []string) (time.Time, error)

ComputeUntilTimestamp extracts until timestamp from filters

func CoresToPeriodAndQuota

func CoresToPeriodAndQuota(cores float64) (uint64, int64)

CoresToPeriodAndQuota converts a fraction of cores to the equivalent Completely Fair Scheduler (CFS) parameters period and quota.

Cores is a fraction of the CFS period that a container may use. Period and Quota are in microseconds.

func CreateCidFile

func CreateCidFile(cidfile string, id string) error

func DefaultContainerConfig

func DefaultContainerConfig() *config.Config

func ExitCode

func ExitCode(err error) int

ExitCode reads the error message when failing to executing container process and then returns 0 if no error, 126 if command does not exist, or 127 for all other errors

func FiltersFromRequest added in v3.1.0

func FiltersFromRequest(r *http.Request) ([]string, error)

filtersFromRequests extracts the "filters" parameter from the specified http.Request. The parameter can either be a `map[string][]string` as done in new versions of Docker and libpod, or a `map[string]map[string]bool` as done in older versions of Docker. We have to do a bit of Yoga to support both - just as Docker does as well.

Please refer to https://github.com/containers/podman/issues/6899 for some background.

func FindDeviceNodes

func FindDeviceNodes() (map[string]string, error)

FindDeviceNodes parses /dev/ into a set of major:minor -> path, where [major:minor] is the device's major and minor numbers formatted as, for example, 2:0 and path is the path to the device node. Symlinks to nodes are ignored.

func GetContainerPidInformationDescriptors

func GetContainerPidInformationDescriptors() ([]string, error)

GetContainerPidInformationDescriptors returns a string slice of all supported format descriptors of GetContainerPidInformation.

func GetKeepIDMapping

func GetKeepIDMapping() (*stypes.IDMappingOptions, int, int, error)

GetKeepIDMapping returns the mappings and the user to use when keep-id is used

func GetRootlessConfigHomeDir

func GetRootlessConfigHomeDir() (string, error)

GetRootlessConfigHomeDir returns the config home directory when running as non root

func GetRootlessPauseProcessPidPath

func GetRootlessPauseProcessPidPath() (string, error)

GetRootlessPauseProcessPidPath returns the path to the file that holds the pid for the pause process. DEPRECATED - switch to GetRootlessPauseProcessPidPathGivenDir

func GetRootlessPauseProcessPidPathGivenDir

func GetRootlessPauseProcessPidPathGivenDir(libpodTmpDir string) (string, error)

GetRootlessPauseProcessPidPathGivenDir returns the path to the file that holds the PID of the pause process, given the location of Libpod's temporary files.

func GetRuntimeDir

func GetRuntimeDir() (string, error)

GetRuntimeDir returns the runtime directory

func HomeDir

func HomeDir() (string, error)

HomeDir returns the home directory for the current user.

func IDtoolsToRuntimeSpec added in v3.1.0

func IDtoolsToRuntimeSpec(idMaps []idtools.IDMap) (convertedIDMap []specs.LinuxIDMapping)

IDtoolsToRuntimeSpec converts idtools ID mapping to the one of the runtime spec.

func MatchLabelFilters added in v3.1.0

func MatchLabelFilters(filterValues []string, labels map[string]string) bool

MatchLabelFilters matches labels and returns true if they are valid

func OpenExclusiveFile

func OpenExclusiveFile(path string) (*os.File, error)

OpenExclusiveFile opens a file for writing and ensure it doesn't already exist

func ParseIDMapping

func ParseIDMapping(mode namespaces.UsernsMode, uidMapSlice, gidMapSlice []string, subUIDMap, subGIDMap string) (*stypes.IDMappingOptions, error)

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

func ParseInputTime

func ParseInputTime(inputTime string, since bool) (time.Time, error)

ParseInputTime takes the users input and to determine if it is valid and returns a time format and error. The input is compared to known time formats or a duration which implies no-duration

func ParseRegistryCreds

func ParseRegistryCreds(creds string) (*types.DockerAuthConfig, error)

ParseRegistryCreds takes a credentials string in the form USERNAME:PASSWORD and returns a DockerAuthConfig

func ParseSignal

func ParseSignal(rawSignal string) (syscall.Signal, error)

ParseSignal parses and validates a signal name or number.

func PeriodAndQuotaToCores

func PeriodAndQuotaToCores(period uint64, quota int64) float64

PeriodAndQuotaToCores takes the CFS parameters period and quota and returns a fraction that represents the limit to the number of cores that can be utilized over the scheduling period.

Cores is a fraction of the CFS period that a container may use. Period and Quota are in microseconds.

func PrepareFilters added in v3.1.0

func PrepareFilters(r *http.Request) (*map[string][]string, error)

PrepareFilters prepares a *map[string][]string of filters to be later searched in lipod and compat API to get desired filters

func ProcessOptions

func ProcessOptions(options []string, isTmpfs bool, sourcePath string) ([]string, error)

ProcessOptions parses the options for a bind or tmpfs mount and ensures that they are sensible and follow convention. The isTmpfs variable controls whether extra, tmpfs-specific options will be allowed. The sourcePath variable, if not empty, contains a bind mount source.

func SetSocketPath added in v3.2.0

func SetSocketPath(path string)

func SocketPath added in v3.2.0

func SocketPath() (string, error)

func StringInSlice

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

StringInSlice determines if a string is in a string slice, returns bool

func StringMatchRegexSlice

func StringMatchRegexSlice(s string, re []string) bool

StringMatchRegexSlice determines if a given string matches one of the given regexes, returns bool

func Tmpdir

func Tmpdir() string

func ValidateSysctls

func ValidateSysctls(strSlice []string) (map[string]string, error)

ValidateSysctls validates a list of sysctl and returns it.

func WriteStorageConfigFile

func WriteStorageConfigFile(storageOpts *stypes.StoreOptions, storageConf string) error

WriteStorageConfigFile writes the configuration to a file

Types

type ImageConfig

type ImageConfig struct {
	v1.ImageConfig
	OnBuild []string
}

ImageConfig is a wrapper around the OCIv1 Image Configuration struct exported by containers/image, but containing additional fields that are not supported by OCIv1 (but are by Docker v2) - notably OnBuild.

func GetImageConfig

func GetImageConfig(changes []string) (ImageConfig, error)

GetImageConfig produces a v1.ImageConfig from the --change flag that is accepted by several Podman commands. It accepts a (limited subset) of Dockerfile instructions.

Directories

Path Synopsis
Package camelcase is a micro package to split the words of a camelcase type string into a slice of words.
Package camelcase is a micro package to split the words of a camelcase type string into a slice of words.

Jump to

Keyboard shortcuts

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