container_parser

package module
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CPUStats

type CPUStats struct {
	TotalUsage      float64 `json:"total_usage"`
	SystemUsage     float64 `json:"system_usage"`
	OnlineCPUs      int     `json:"online_cpus"`
	UsagePercent    float64 `json:"usage_percent"`
	ThrottledTime   uint64  `json:"throttled_time"`
	ThrottledPeriod uint64  `json:"throttled_period"`
}

CPUStats представляет статистику использования CPU

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewContainerParser

func NewContainerParser() (*Client, error)

NewContainerParser создает новый Docker клиент

func (*Client) CreateVolume

func (c *Client) CreateVolume(req VolumeCreateRequest) (*Volume, error)

CreateVolume создает новый том

func (*Client) GetContainer

func (c *Client) GetContainer(id string) (*Container, error)

GetContainer возвращает детальную информацию о контейнере

func (*Client) GetContainerLogs

func (c *Client) GetContainerLogs(id string, tail string, follow bool) (io.ReadCloser, error)

GetContainerLogs возвращает логи контейнера

func (*Client) GetContainerStats

func (c *Client) GetContainerStats(id string) (*ContainerStats, error)

GetContainerStats возвращает статистику использования ресурсов контейнера

func (*Client) GetImageHistory added in v0.4.0

func (c *Client) GetImageHistory(name string) (*ImageInspectHistory, error)

GetImageHistory возвращает инспектированные данные о контейнере

func (*Client) GetSystemInfo

func (c *Client) GetSystemInfo() (*SystemInfo, error)

GetSystemInfo возвращает информацию о системе Docker

func (*Client) GetVolume

func (c *Client) GetVolume(name string) (*VolumeDetail, error)

GetVolume возвращает детальную информацию о томе

func (*Client) GetVolumeContents

func (c *Client) GetVolumeContents(volumeName string, path string) (*VolumeContents, error)

GetVolumeContents возвращает содержимое тома Сначала пытается использовать существующий контейнер, если том уже смонтирован Если контейнеров нет, создает временный контейнер

func (*Client) ListContainers

func (c *Client) ListContainers(all bool) ([]ContainerSummary, error)

ListContainers возвращает список всех контейнеров

func (*Client) ListVolumes

func (c *Client) ListVolumes() ([]VolumeSummary, error)

ListVolumes возвращает список всех томов

func (*Client) PruneVolumes

func (c *Client) PruneVolumes() (*VolumePruneReport, error)

PruneVolumes удаляет неиспользуемые тома

func (*Client) RemoveContainer

func (c *Client) RemoveContainer(id string, force bool, removeVolumes bool) error

RemoveContainer удаляет контейнер

func (*Client) RemoveVolume

func (c *Client) RemoveVolume(name string, force bool) error

RemoveVolume удаляет том

func (*Client) RestartContainer

func (c *Client) RestartContainer(id string, timeout *int) error

RestartContainer перезапускает контейнер

func (*Client) ScanVolumeHierarchy

func (c *Client) ScanVolumeHierarchy(volumeName, path string) (*VolumeCache, error)

ScanVolumeHierarchy выполняет асинхронное сканирование иерархии тома

func (*Client) StartContainer

func (c *Client) StartContainer(id string) error

StartContainer запускает контейнер

func (*Client) StopContainer

func (c *Client) StopContainer(id string, timeout *int) error

StopContainer останавливает контейнер

type Container

type Container struct {
	ID              string            `json:"id"`
	Name            string            `json:"name"`
	Image           string            `json:"image"`
	Status          string            `json:"status"`
	State           string            `json:"state"`
	Created         time.Time         `json:"created"`
	StartedAt       time.Time         `json:"started_at"`
	FinishedAt      time.Time         `json:"finished_at"`
	Labels          map[string]string `json:"labels"`
	Ports           []Port            `json:"ports"`
	NetworkSettings NetworkSettings   `json:"network_settings"`
	Mounts          []Mount           `json:"mounts"`
	Command         string            `json:"command"`
}

Container представляет информацию о Docker контейнере

type ContainerStats

type ContainerStats struct {
	ContainerID  string    `json:"container_id"`
	Timestamp    time.Time `json:"timestamp"`
	CPUUsage     CPUStats  `json:"cpu_usage"`
	MemoryUsage  MemStats  `json:"memory_usage"`
	NetworkStats NetStats  `json:"network_stats"`
	DiskIOStats  DiskStats `json:"disk_io_stats"`
	PIDs         int       `json:"pids"`
	Uptime       string    `json:"uptime"`
}

ContainerStats представляет статистику использования ресурсов контейнера

type ContainerSummary

type ContainerSummary struct {
	ID             string            `json:"id"`
	Name           string            `json:"name"`
	Image          string            `json:"image"`
	Status         string            `json:"status"`
	State          string            `json:"state"`
	Created        time.Time         `json:"created"`
	Uptime         string            `json:"uptime"`
	CPUPercent     float64           `json:"cpu_percent"`
	MemPercent     float64           `json:"mem_percent"`
	NetworkRx      string            `json:"network_rx"`
	NetworkTx      string            `json:"network_tx"`
	IsCompose      bool              `json:"is_compose"`
	ComposeProject string            `json:"compose_project,omitempty"`
	ComposeService string            `json:"compose_service,omitempty"`
	Labels         map[string]string `json:"labels,omitempty"`
	IPAddress      string            `json:"ip_address,omitempty"`
	Networks       map[string]string `json:"networks,omitempty"`
	Gateway        string            `json:"gateway,omitempty"`
}

ContainerSummary представляет краткую информацию о контейнере для списка

type DiskStats

type DiskStats struct {
	ReadBytes  uint64 `json:"read_bytes"`
	WriteBytes uint64 `json:"write_bytes"`
	ReadOps    uint64 `json:"read_ops"`
	WriteOps   uint64 `json:"write_ops"`
}

DiskStats представляет статистику дискового ввода/вывода

type ImageInspectHistory added in v0.4.0

type ImageInspectHistory struct {
	History []image.HistoryResponseItem
	Inspect image.InspectResponse
}

type MemStats

type MemStats struct {
	Usage    uint64  `json:"usage"`
	Limit    uint64  `json:"limit"`
	MaxUsage uint64  `json:"max_usage"`
	Percent  float64 `json:"percent"`
	Cache    uint64  `json:"cache"`
	RSS      uint64  `json:"rss"`
}

MemStats представляет статистику использования памяти

type Mount

type Mount struct {
	Type        string `json:"type"`
	Source      string `json:"source"`
	Destination string `json:"destination"`
	Mode        string `json:"mode"`
	RW          bool   `json:"rw"`
	Propagation string `json:"propagation"`
}

Mount представляет информацию о монтировании

type NetStats

type NetStats struct {
	RxBytes   uint64 `json:"rx_bytes"`
	RxPackets uint64 `json:"rx_packets"`
	RxErrors  uint64 `json:"rx_errors"`
	RxDropped uint64 `json:"rx_dropped"`
	TxBytes   uint64 `json:"tx_bytes"`
	TxPackets uint64 `json:"tx_packets"`
	TxErrors  uint64 `json:"tx_errors"`
	TxDropped uint64 `json:"tx_dropped"`
}

NetStats представляет статистику сети

type Network

type Network struct {
	IPAddress    string `json:"ip_address"`
	Gateway      string `json:"gateway"`
	MacAddress   string `json:"mac_address"`
	NetworkID    string `json:"network_id"`
	EndpointID   string `json:"endpoint_id"`
	IPv6Gateway  string `json:"ipv6_gateway"`
	GlobalIPv6   string `json:"global_ipv6"`
	PrefixLength int    `json:"prefix_length"`
}

Network представляет сетевую информацию

type NetworkSettings

type NetworkSettings struct {
	Networks   map[string]Network `json:"networks"`
	IPAddress  string             `json:"ip_address"`
	Gateway    string             `json:"gateway"`
	MacAddress string             `json:"mac_address"`
}

NetworkSettings представляет сетевые настройки контейнера

type Port

type Port struct {
	IP          string `json:"ip"`
	PrivatePort uint16 `json:"private_port"`
	PublicPort  uint16 `json:"public_port"`
	Type        string `json:"type"`
}

Port представляет информацию о порте контейнера

type SystemInfo

type SystemInfo struct {
	ContainersRunning int    `json:"containers_running"`
	ContainersStopped int    `json:"containers_stopped"`
	ContainersPaused  int    `json:"containers_paused"`
	ContainersTotal   int    `json:"containers_total"`
	Images            int    `json:"images"`
	ServerVersion     string `json:"server_version"`
	OSType            string `json:"os_type"`
	Architecture      string `json:"architecture"`
	CPUs              int    `json:"cpus"`
	Memory            uint64 `json:"memory"`
	Swap              uint64 `json:"swap"`
	KernelVersion     string `json:"kernel_version"`
	DockerRootDir     string `json:"docker_root_dir"`
}

SystemInfo представляет информацию о системе Docker

type Volume

type Volume struct {
	// Basic information
	Name       string            `json:"name"`
	Driver     string            `json:"driver"`
	Mountpoint string            `json:"mountpoint"`
	CreatedAt  time.Time         `json:"created_at"`
	Labels     map[string]string `json:"labels,omitempty"`
	Scope      string            `json:"scope"` // local, global
	Options    map[string]string `json:"options,omitempty"`

	// Usage information
	UsageData *VolumeUsageData `json:"usage_data,omitempty"`
}

Volume represents a Docker volume

type VolumeCache

type VolumeCache struct {
	VolumeName string              `json:"volume_name"`
	Path       string              `json:"path"`
	Entries    []*VolumeCacheEntry `json:"entries"`
	Total      int                 `json:"total"`
	UpdatedAt  time.Time           `json:"updated_at"`
	Scanning   bool                `json:"scanning"`
}

VolumeCache represents the complete cached volume information

type VolumeCacheEntry

type VolumeCacheEntry struct {
	Name      string              `json:"name"`
	Path      string              `json:"path"`
	Type      string              `json:"type"` // "file", "directory", "symlink"
	Size      int64               `json:"size,omitempty"`
	Mode      string              `json:"mode,omitempty"`
	Modified  time.Time           `json:"modified,omitempty"`
	IsDir     bool                `json:"is_dir"`
	IsSymlink bool                `json:"is_symlink,omitempty"`
	Children  []*VolumeCacheEntry `json:"children,omitempty"`
}

VolumeCacheEntry represents a cached entry in the volume hierarchy

type VolumeContentEntry

type VolumeContentEntry struct {
	Name      string    `json:"name"`
	Path      string    `json:"path"`
	Type      string    `json:"type"` // "file", "directory", "symlink"
	Size      int64     `json:"size,omitempty"`
	Mode      string    `json:"mode,omitempty"`
	Modified  time.Time `json:"modified,omitempty"`
	IsDir     bool      `json:"is_dir"`
	IsSymlink bool      `json:"is_symlink,omitempty"`
}

VolumeContentEntry represents a single file or directory in a volume

type VolumeContents

type VolumeContents struct {
	Name     string               `json:"name"`
	Path     string               `json:"path,omitempty"`
	Contents []VolumeContentEntry `json:"contents"`
	Total    int                  `json:"total"`
}

VolumeContents represents the contents of a volume

type VolumeCreateRequest

type VolumeCreateRequest struct {
	Name       string            `json:"name,omitempty"`
	Driver     string            `json:"driver,omitempty"`
	DriverOpts map[string]string `json:"driver_opts,omitempty"`
	Labels     map[string]string `json:"labels,omitempty"`
}

VolumeCreateRequest represents a request to create a volume

type VolumeDetail

type VolumeDetail struct {
	Volume
	Containers []VolumeMountInfo `json:"containers,omitempty"`
	Size       string            `json:"size,omitempty"`
}

VolumeDetail represents detailed volume information including mount info

type VolumeInspectResponse

type VolumeInspectResponse struct {
	Volume
	Status map[string]interface{} `json:"status,omitempty"`
}

VolumeInspectResponse represents detailed volume information

type VolumeListOptions

type VolumeListOptions struct {
	Filters map[string][]string `json:"filters,omitempty"`
}

VolumeListOptions represents options for listing volumes

type VolumeMountInfo

type VolumeMountInfo struct {
	ContainerID   string `json:"container_id"`
	ContainerName string `json:"container_name"`
	MountPath     string `json:"mount_path"`
	ReadOnly      bool   `json:"read_only"`
	Propagation   string `json:"propagation,omitempty"`
}

VolumeMountInfo represents information about how a volume is mounted in containers

type VolumePruneReport

type VolumePruneReport struct {
	VolumesDeleted          []string `json:"volumes_deleted"`
	SpaceReclaimed          uint64   `json:"space_reclaimed"`
	SpaceReclaimedFormatted string   `json:"space_reclaimed_formatted,omitempty"`
}

VolumePruneReport represents the result of pruning unused volumes

type VolumeScanJob

type VolumeScanJob struct {
	ScanID      string
	VolumeName  string
	Path        string
	Status      string // "pending", "running", "completed", "failed"
	StartedAt   time.Time
	CompletedAt time.Time
	Progress    int
	TotalItems  int
	Error       string
}

type VolumeScanRequest

type VolumeScanRequest struct {
	VolumeName string `json:"volume_name"`
	Path       string `json:"path,omitempty"`
}

VolumeScanRequest represents a request to start volume scanning

type VolumeScanResponse

type VolumeScanResponse struct {
	ScanID     string    `json:"scan_id"`
	VolumeName string    `json:"volume_name"`
	Path       string    `json:"path"`
	StartedAt  time.Time `json:"started_at"`
	Status     string    `json:"status"`
}

VolumeScanResponse represents the response from a scan operation

type VolumeScanStatus

type VolumeScanStatus struct {
	ScanID      string    `json:"scan_id"`
	VolumeName  string    `json:"volume_name"`
	Path        string    `json:"path"`
	Status      string    `json:"status"` // "pending", "running", "completed", "failed"
	StartedAt   time.Time `json:"started_at"`
	CompletedAt time.Time `json:"completed_at,omitempty"`
	Progress    int       `json:"progress"`
	TotalItems  int       `json:"total_items"`
	Error       string    `json:"error,omitempty"`
}

VolumeScanStatus represents the status of a scan operation

type VolumeStats

type VolumeStats struct {
	Name       string    `json:"name"`
	SizeBytes  int64     `json:"size_bytes"`
	RefCount   int       `json:"ref_count"`
	CreatedAt  time.Time `json:"created_at"`
	Mountpoint string    `json:"mountpoint"`
	Driver     string    `json:"driver"`
}

VolumeStats represents volume statistics

type VolumeSummary

type VolumeSummary struct {
	Name       string            `json:"name"`
	Driver     string            `json:"driver"`
	Mountpoint string            `json:"mountpoint"`
	CreatedAt  time.Time         `json:"created_at"`
	Size       string            `json:"size,omitempty"`
	RefCount   int               `json:"ref_count"`
	Labels     map[string]string `json:"labels,omitempty"`
}

VolumeSummary represents summary information for volume listing

type VolumeUsageData

type VolumeUsageData struct {
	SizeBytes int64 `json:"size_bytes"`
	RefCount  int   `json:"ref_count"`
}

VolumeUsageData represents volume usage statistics

Jump to

Keyboard shortcuts

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