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 ¶
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 ¶
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
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 ¶
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