container

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package container tracks the current containers from the docker runtime.

Index

Constants

View Source
const (
	StateNameDockerContainer = "docker_container"

	StateKeyDockerContainerData           = "data"
	StateKeyDockerContainerEncoding       = "encoding"
	StateValueDockerContainerEncodingJSON = "json"

	PodNameLabel      = "io.kubernetes.pod.name"
	PodNamespaceLabel = "io.kubernetes.pod.namespace"
)
View Source
const Name = "docker-container"

Variables

This section is empty.

Functions

func CreateGet

func CreateGet(cfg Config) query.GetFunc

func IsDockerRunning

func IsDockerRunning() bool

If not run, fails with: "Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?"

func IsErrDockerClientVersionNewerThanDaemon

func IsErrDockerClientVersionNewerThanDaemon(err error) bool

IsErrDockerClientVersionNewerThanDaemon returns true if the docker client version is newer than the daemon version. e.g., "Error response from daemon: client version 1.44 is too new. Maximum supported API version is 1.43"

func ListContainers

func ListContainers(ctx context.Context) ([]docker_types.Container, error)

If not run, fails with: "Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?"

func New

Types

type Config

type Config struct {
	Query query_config.Config `json:"query"`

	// In case the docker daemon is not running, we ignore such errors as
	// 'Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?'.
	IgnoreConnectionErrors bool `json:"ignore_connection_errors"`
}

func ParseConfig

func ParseConfig(b any, db *sql.DB) (*Config, error)

func (Config) Validate

func (cfg Config) Validate() error

type DockerContainer

type DockerContainer struct {
	ID           string `json:"id,omitempty"`
	Name         string `json:"name,omitempty"`
	Image        string `json:"image,omitempty"`
	CreatedAt    int64  `json:"created_at,omitempty"`
	State        string `json:"state,omitempty"`
	PodName      string `json:"pod_name,omitempty"`
	PodNamespace string `json:"pod_namespace,omitempty"`
}

func ConvertToDockerContainer

func ConvertToDockerContainer(resp docker_types.Container) DockerContainer

func ParseStateDockerContainer

func ParseStateDockerContainer(m map[string]string) ([]DockerContainer, error)

func (DockerContainer) JSON

func (s DockerContainer) JSON() ([]byte, error)

type Output

type Output struct {
	Containers []DockerContainer `json:"containers,omitempty"`

	// Sets true if the docker client calls due to the version incompatibility issue.
	// e.g.,
	// "Error response from daemon: client version 1.44 is too new. Maximum supported API version is 1.43"
	IsErrDockerClientVersionNewerThanDaemon bool   `json:"is_err_docker_client_version_newer_than_daemon,omitempty"`
	DockerClientError                       string `json:"docker_client_error,omitempty"`

	DockerPidFound bool `json:"docker_pid_found,omitempty"`

	// In case the docker daemon is not running
	// 'Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?'.
	ConnectionError string `json:"connection_error,omitempty"`
	Message         string `json:"message,omitempty"`
}

func ParseOutputJSON

func ParseOutputJSON(data []byte) (*Output, error)

func ParseStatesToOutput

func ParseStatesToOutput(states ...components.State) (*Output, error)

func (*Output) JSON

func (o *Output) JSON() ([]byte, error)

func (*Output) States

func (o *Output) States(cfg Config) ([]components.State, error)

Jump to

Keyboard shortcuts

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