utils

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PodCgroupName = "pod"
)

Variables

This section is empty.

Functions

func CopyDetachable

func CopyDetachable(dst io.Writer, src io.Reader, keys []byte) (int64, error)

CopyDetachable is similar to io.Copy but support a detach key sequence to break out.

func EnsureSaneLogPath

func EnsureSaneLogPath(logPath string) error

EnsureSaneLogPath is a hack to fix https://issues.k8s.io/44043 which causes logPath to be a broken symlink to some magical Docker path. Ideally we wouldn't have to deal with this, but until that issue is fixed we have to remove the path if it's a broken symlink.

func GenerateGroup

func GenerateGroup(gid uint32, rootfs, rundir string) (string, error)

GenerateGroup generates a container specific group file, iff gid is not defined in the containers /etc/group

func GenerateID

func GenerateID() (string, error)

GenerateID generates a random unique id.

func GeneratePasswd

func GeneratePasswd(username string, uid, gid uint32, homedir, rootfs, rundir string) (string, error)

GeneratePasswd generates a container specific passwd file, iff uid is not defined in the containers /etc/passwd

func GetDiskUsageStats

func GetDiskUsageStats(path string) (dirSize, inodeCount uint64, _ error)

GetDiskUsageStats accepts a path to a directory or file and returns the number of bytes and inodes used by the path

func GetGroup

func GetGroup(containerMount, groupIDorName string) (*user.Group, error)

GetGroup searches for a group in the container's /etc/group file using the provided container mount path and group identifier (either name or ID). It returns a matching user.Group structure if found. If no matching group is located, it returns ErrNoGroupEntries.

func GetLabelOptions

func GetLabelOptions(selinuxOptions *types.SELinuxOption) []string

func GetUser

func GetUser(containerMount, userIDorName string) (*user.User, error)

GetUser takes a containermount path and user name or ID and returns a matching User structure from /etc/passwd. If it cannot locate a user with the provided information, an ErrNoPasswdEntries is returned. When the provided user name was an ID, a User structure with Uid set is returned along with ErrNoPasswdEntries.

func GetUserInfo

func GetUserInfo(rootfs, userName string) (uid, gid uint32, additionalGids []uint32, _ error)

GetUserInfo returns UID, GID and additional groups for specified user by looking them up in /etc/passwd and /etc/group

func HandleResizing

func HandleResizing(resize <-chan remotecommand.TerminalSize, resizeFunc func(size remotecommand.TerminalSize))

HandleResizing spawns a goroutine that processes the resize channel, calling resizeFunc for each TerminalSize received from the channel. The resize channel must be closed elsewhere to stop the goroutine.

func Int32Ptr

func Int32Ptr(i int32) *int32

Int32Ptr is a utility function to assign to integer pointer variables

func IsDirectory

func IsDirectory(path string) error

IsDirectory tests whether the given path exists and is a directory. It follows symlinks.

func RunUnderSystemdScope

func RunUnderSystemdScope(mgr *dbusmgr.DbusConnManager, pid int, slice, unitName string, properties ...systemdDbus.Property) (err error)

RunUnderSystemdScope adds the specified pid to a systemd scope

func StatusToExitCode

func StatusToExitCode(status int) int

StatusToExitCode converts wait status code to an exit code

func Sync

func Sync(path string) error

Sync ensures a path is synced to disk

func SyncParent

func SyncParent(path string) error

SyncParent ensures a path's parent directory is synced to disk

func Syncfs

func Syncfs(path string) error

Syncfs ensures the file system at path is synced to disk

func WriteGoroutineStacksToFile

func WriteGoroutineStacksToFile(path string) error

WriteGoroutineStacksToFile write goroutine stacks to the specified file.

Types

type DetachError

type DetachError struct{}

DetachError is special error which returned in case of container detach.

func (DetachError) Error

func (DetachError) Error() string

Directories

Path Synopsis
Package errdefs defines the common errors used throughout containerd packages.
Package errdefs defines the common errors used throughout containerd packages.

Jump to

Keyboard shortcuts

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