util

package
v0.1.0-M1 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2022 License: EPL-2.0 Imports: 15 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculateParallelLimit

func CalculateParallelLimit(n int, limit int) int

CalculateParallelLimit calculates the limit for starting parallel jobs

func CalculateUptime

func CalculateUptime(container *types.Container) time.Duration

CalculateUptime calculates the uptime of a container instance

func Copy

func Copy(sourcePath string, destPath string, bufferSize int) error

Copy copies the resources from a given source path to the given destination path

func CopyContainer

func CopyContainer(source *types.Container) types.Container

CopyContainer creates a new container instance from the provided parameter

func FileNotExistEmptyOrDir

func FileNotExistEmptyOrDir(filename string) error

FileNotExistEmptyOrDir validates whether the provided filename refers to an existing non-empty file

func FillDefaults

func FillDefaults(container *types.Container) bool

FillDefaults sets all default configurations which are not required as an input but are required for processing the container's configuration

func FillMemorySwap

func FillMemorySwap(container *types.Container)

FillMemorySwap sets the swap memory of a container. Memory swap should be filled only once during creation.

func GetDirChildrenNames

func GetDirChildrenNames(dirPath string) ([]string, error)

GetDirChildrenNames returns all child directories of the provided one

func GetImageHost

func GetImageHost(imageRef string) string

GetImageHost retrieves the host name of the container imager registry for the provided image

func IsContainerCreated

func IsContainerCreated(c *types.Container) bool

IsContainerCreated returns if container is in the created state or not

func IsContainerDead

func IsContainerDead(c *types.Container) bool

IsContainerDead returns whether the container is in Dead state

func IsContainerNetworkBridge

func IsContainerNetworkBridge(container *types.Container) bool

IsContainerNetworkBridge returns true if the network mode is bridge

func IsContainerNetworkHost

func IsContainerNetworkHost(container *types.Container) bool

IsContainerNetworkHost returns true if the network mode is host

func IsContainerRunningOrPaused

func IsContainerRunningOrPaused(c *types.Container) bool

IsContainerRunningOrPaused returns true if the container is running or paused

func IsDirectory

func IsDirectory(path string) (bool, error)

IsDirectory returns true if the given path is a directory

func IsFile

func IsFile(path string) (bool, error)

IsFile returns true if the given path is a file

func IsRestartPolicyAlways

func IsRestartPolicyAlways(policy *types.RestartPolicy) bool

IsRestartPolicyAlways checks if the restart policy type is set to always

func IsRestartPolicyNone

func IsRestartPolicyNone(policy *types.RestartPolicy) bool

IsRestartPolicyNone checks if the restart policy type is set to no

func IsRestartPolicyOnFailure

func IsRestartPolicyOnFailure(policy *types.RestartPolicy) bool

IsRestartPolicyOnFailure checks if the restart policy is set to on-failure

func IsRestartPolicyUnlessStopped

func IsRestartPolicyUnlessStopped(policy *types.RestartPolicy) bool

IsRestartPolicyUnlessStopped checks if the restart policy is set to unless-stopped

func MkDir

func MkDir(dirname string) error

MkDir creates a directory with the provided name

func MkDirs

func MkDirs(dirNames ...string) error

MkDirs creates directories for the given directory names

func RemoveChildren

func RemoveChildren(dirPath string) ([]string, error)

RemoveChildren removes all children of a given directory

Returns [], nil if everything went OK Returns nil, error if the error happened before or during the retrieval of the children. For example the path did not exist was locked or something else similar. If an error occurs on some or all of the children it will return a []string, error where the list contains the children that where not deleted

func SetContainerStatusCreated

func SetContainerStatusCreated(c *types.Container)

SetContainerStatusCreated sets the container state to created updating all required fields and flags

func SetContainerStatusDead

func SetContainerStatusDead(c *types.Container)

SetContainerStatusDead sets the container state to dead updating all required fields and flags

func SetContainerStatusExited

func SetContainerStatusExited(c *types.Container, exitCode int64, errMsg string, oomKilled bool)

SetContainerStatusExited sets the container state to exited updating all required fields and flags

func SetContainerStatusPaused

func SetContainerStatusPaused(c *types.Container)

SetContainerStatusPaused sets the container state to paused updating all required fields and flags

func SetContainerStatusRunning

func SetContainerStatusRunning(c *types.Container, pid int64)

SetContainerStatusRunning sets the container state to running updating all required fields and flags

func SetContainerStatusStopped

func SetContainerStatusStopped(c *types.Container, exitCode int64, errMsg string)

SetContainerStatusStopped sets the container state to stopped updating all required fields and flags

func SetContainerStatusUnpaused

func SetContainerStatusUnpaused(c *types.Container)

SetContainerStatusUnpaused is added for completion as the container's state is actually running

func SizeRecalculate

func SizeRecalculate(sizeStr string, eval func(float64) float64) (string, error)

SizeRecalculate takes size string representation and returns a new recalculated size string representation

func SizeToBytes

func SizeToBytes(sizeStr string) (int64, error)

SizeToBytes converts size string representation to a number

func ToSignal

func ToSignal(signal string) syscall.Signal

ToSignal parses a string to syscall.Signal. Signals are accepted as both number and name: SIGKILL or 9. Returns the syscall.Signal for the provided number or name. Returns 0 if a signal with the provided name is not found.

func ValidateContainer

func ValidateContainer(container *types.Container) error

ValidateContainer validats all container properties

func ValidateDeviceMapping

func ValidateDeviceMapping(devMapping types.DeviceMapping) error

ValidateDeviceMapping validates the mapping between the path on the host and the path in the container and checks if the cgroup permissions are set

func ValidateDeviceMappings

func ValidateDeviceMappings(devMappings []types.DeviceMapping) error

ValidateDeviceMappings validates all device mappings

func ValidateHostConfig

func ValidateHostConfig(hostConfig *types.HostConfig) error

ValidateHostConfig validates the container host configuration

func ValidateImage

func ValidateImage(img types.Image) error

ValidateImage validates the container image

func ValidateLogConfig

func ValidateLogConfig(logCfg *types.LogConfiguration) error

ValidateLogConfig validates the log configuration

func ValidateMountPoint

func ValidateMountPoint(mp types.MountPoint) error

ValidateMountPoint validates the cointainer mount configuration

func ValidateMounts

func ValidateMounts(mounts []types.MountPoint) error

ValidateMounts validates all the cointainer mount points

func ValidateName

func ValidateName(name string) error

ValidateName validates the container name

func ValidateNetworking

func ValidateNetworking(hostConfig *types.HostConfig) error

ValidateNetworking validates the container networking

func ValidateResources

func ValidateResources(resources *types.Resources) error

ValidateResources validates the container resources limitations

func ValidateRestartPolicy

func ValidateRestartPolicy(rsPolicy *types.RestartPolicy) error

ValidateRestartPolicy validates the container restart policy

func ValidateStopOpts

func ValidateStopOpts(opts *types.StopOpts) error

ValidateStopOpts validates stop options. Returns error if timeout is negative or signal is invalid.

Types

type LocksCache

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

LocksCache provides cache management for identifiable *sync.RWMutex instances.

func NewLocksCache

func NewLocksCache() LocksCache

NewLocksCache creates a new LockCache

func (*LocksCache) GetLock

func (cache *LocksCache) GetLock(key string) *sync.RWMutex

GetLock returns the lock by provided key

func (*LocksCache) RemoveLock

func (cache *LocksCache) RemoveLock(key string)

RemoveLock removes the lock by provided key

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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