container

package
v0.0.1-alpha9 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: 15 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 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"`
	Endpoint string              `json:"endpoint"`
}

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"`
}

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() ([]components.State, error)

Jump to

Keyboard shortcuts

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