containerutils

package
v0.59.0-devel Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2024 License: Apache-2.0 Imports: 3 Imported by: 1

Documentation

Overview

Package containerutils holds multiple utils functions around Container IDs and their patterns

Package containerutils holds multiple utils functions around Container IDs and their patterns

Package containerutils groups multiple container utils function that can be used by the secl package

Index

Constants

View Source
const (
	// ContainerRuntimeDocker is used to specify that a container is managed by Docker
	ContainerRuntimeDocker = "docker"
	// ContainerRuntimeCRI is used to specify that a container is managed by containerd
	ContainerRuntimeCRI = "containerd"
	// ContainerRuntimeCRIO is used to specify that a container is managed by CRI-O
	ContainerRuntimeCRIO = "cri-o"
	// ContainerRuntimePodman is used to specify that a container is managed by Podman
	ContainerRuntimePodman = "podman"
)

Variables

View Source
var ContainerIDPatternStr = ""

ContainerIDPatternStr defines the regexp used to match container IDs ([0-9a-fA-F]{64}) is standard container id used pretty much everywhere, length: 64 ([0-9a-fA-F]{32}-\d+) is container id used by AWS ECS, length: 43 ([0-9a-fA-F]{8}(-[0-9a-fA-F]{4}){4}) is container id used by Garden, length: 28

View Source
var RuntimePrefixes = map[string]CGroupManager{
	"docker/":         CGroupManagerDocker,
	"docker-":         CGroupManagerDocker,
	"cri-containerd-": CGroupManagerCRI,
	"crio-":           CGroupManagerCRIO,
	"libpod-":         CGroupManagerPodman,
}

RuntimePrefixes holds the cgroup prefixed used by the different runtimes

Functions

func FindContainerID

func FindContainerID(s string) (string, uint64)

FindContainerID extracts the first sub string that matches the pattern of a container ID along with the container flags induced from the container runtime prefix

func GetCGroupContext

func GetCGroupContext(containerID ContainerID, cgroupFlags CGroupFlags) (CGroupID, ContainerID)

GetCGroupContext returns the cgroup ID and the sanitized container ID from a container id/flags tuple

Types

type CGroupFlags

type CGroupFlags uint64

CGroupFlags represents the flags of a cgroup

func GetCGroupManager

func GetCGroupManager(cgroup string) (string, CGroupFlags)

GetCGroupManager extracts the cgroup manager from a cgroup name

func GetContainerFromCgroup

func GetContainerFromCgroup(cgroup string) (string, CGroupFlags)

GetContainerFromCgroup extracts the container ID from a cgroup name

type CGroupID

type CGroupID string

CGroupID represents a cgroup ID

func GetCgroupFromContainer

func GetCgroupFromContainer(id ContainerID, flags CGroupFlags) CGroupID

GetCgroupFromContainer infers the container runtime from a cgroup name

type CGroupManager

type CGroupManager uint64

CGroupManager holds the manager of the cgroup lifecycle

const (
	CGroupManagerDocker  CGroupManager = iota + 1 // docker
	CGroupManagerCRIO                             // cri-o
	CGroupManagerPodman                           // podman
	CGroupManagerCRI                              // containerd
	CGroupManagerSystemd                          // systemd
)

CGroup managers

func (CGroupManager) String

func (i CGroupManager) String() string

type ContainerID

type ContainerID string

ContainerID represents a container ID

Jump to

Keyboard shortcuts

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