docker

package
v0.1.53 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddNetworkToCompose added in v0.1.5

func AddNetworkToCompose(content string, networkName string) (string, error)

func AddVolumeToService added in v0.1.5

func AddVolumeToService(content string, serviceName string, volumeMount string) (string, error)

AddVolumeToService adds a volume mount to a specific service in the compose file

func EnsureContainerNames added in v0.1.5

func EnsureContainerNames(content string, deploymentName string) (string, error)

EnsureContainerNames ensures all services have explicit container_name set. The primary service (preferring "app") gets deploymentName as its container name. All other services get "{deploymentName}-{serviceName}". Existing container_name values are preserved.

func ExecuteService added in v0.1.5

func ExecuteService(cfg *config.ServiceExecConfig, args []string) ([]byte, error)

func ExtractBindMounts added in v0.1.5

func ExtractBindMounts(composeContent string) []string

ExtractBindMounts parses compose content and returns bind mount host paths.

func GetDeploymentResources added in v0.1.5

func GetDeploymentResources(projectName string) (map[string]*ResourceLimits, error)

func HasVolumeMount added in v0.1.5

func HasVolumeMount(content string, serviceName string, volumeMount string) bool

HasVolumeMount checks if a service has a specific volume mount

func InspectContainerUser added in v0.1.5

func InspectContainerUser(containerName string) (string, error)

InspectContainerUser gets the UID:GID of the running process inside a container.

func MarshalComposeYAML added in v0.1.5

func MarshalComposeYAML(compose map[string]interface{}) ([]byte, error)

func ParseComposeYAML added in v0.1.5

func ParseComposeYAML(content string) (map[string]interface{}, error)

func RemoveVolumeFromService added in v0.1.5

func RemoveVolumeFromService(content string, serviceName string, volumeMount string) (string, error)

RemoveVolumeFromService removes a volume mount from a specific service in the compose file

func UpdateContainerResources added in v0.1.5

func UpdateContainerResources(containerID string, update *ResourceUpdate) error

Types

type APIClient added in v0.1.5

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

func NewAPIClient added in v0.1.5

func NewAPIClient() (*APIClient, error)

func (*APIClient) Close added in v0.1.5

func (a *APIClient) Close() error

func (*APIClient) ExecInContainer added in v0.1.5

func (a *APIClient) ExecInContainer(ctx context.Context, containerID string, command string) (string, error)

func (*APIClient) ExecInService added in v0.1.5

func (a *APIClient) ExecInService(ctx context.Context, project, service, command string) (string, error)

func (*APIClient) FindContainer added in v0.1.5

func (a *APIClient) FindContainer(ctx context.Context, project, service string) (string, error)

func (*APIClient) ListServiceContainers added in v0.1.5

func (a *APIClient) ListServiceContainers(ctx context.Context, project string) ([]container.Summary, error)

type ComposeExecutor

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

func NewComposeExecutor

func NewComposeExecutor(basePath string) *ComposeExecutor

func (*ComposeExecutor) Down

func (c *ComposeExecutor) Down(deploymentPath string) (string, error)

func (*ComposeExecutor) ExecCommand added in v0.1.5

func (c *ComposeExecutor) ExecCommand(containerID string, command string) (string, error)

func (*ComposeExecutor) GetImageInfo added in v0.1.5

func (c *ComposeExecutor) GetImageInfo(deploymentPath string) ([]ImageInfo, error)

func (*ComposeExecutor) GetStatus

func (c *ComposeExecutor) GetStatus(deploymentPath string) (string, error)

func (*ComposeExecutor) Logs

func (c *ComposeExecutor) Logs(deploymentPath string, tail int) (string, error)

func (*ComposeExecutor) PS

func (c *ComposeExecutor) PS(deploymentPath string) (string, error)

func (*ComposeExecutor) Pull

func (c *ComposeExecutor) Pull(deploymentPath string, onlyLatest bool) (string, error)

func (*ComposeExecutor) Rebuild added in v0.1.5

func (c *ComposeExecutor) Rebuild(deploymentPath string) (string, error)

func (*ComposeExecutor) Restart

func (c *ComposeExecutor) Restart(deploymentPath string) (string, error)

func (*ComposeExecutor) Start

func (c *ComposeExecutor) Start(deploymentPath string) (string, error)

func (*ComposeExecutor) Stop

func (c *ComposeExecutor) Stop(deploymentPath string) (string, error)

func (*ComposeExecutor) Up

func (c *ComposeExecutor) Up(deploymentPath string) (string, error)

type ContainerStats added in v0.1.5

type ContainerStats struct {
	ContainerID   string  `json:"container_id"`
	Name          string  `json:"name"`
	CPUPercent    float64 `json:"cpu_percent"`
	MemoryUsage   uint64  `json:"memory_usage"`
	MemoryLimit   uint64  `json:"memory_limit"`
	MemoryPercent float64 `json:"memory_percent"`
	NetworkRx     uint64  `json:"network_rx"`
	NetworkTx     uint64  `json:"network_tx"`
	BlockRead     uint64  `json:"block_read"`
	BlockWrite    uint64  `json:"block_write"`
	PIDs          int     `json:"pids"`
}

func GetAllContainerStats added in v0.1.5

func GetAllContainerStats() ([]ContainerStats, error)

func GetContainerStats added in v0.1.5

func GetContainerStats(containerID string) (*ContainerStats, error)

func GetDeploymentStats added in v0.1.5

func GetDeploymentStats(projectName string) ([]ContainerStats, error)

type DeploymentStats

type DeploymentStats struct {
	TotalDeployments int       `json:"total_deployments"`
	Running          int       `json:"running"`
	Stopped          int       `json:"stopped"`
	Error            int       `json:"error"`
	Unknown          int       `json:"unknown"`
	LastUpdated      time.Time `json:"last_updated"`
}

type Discovery

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

func NewDiscovery

func NewDiscovery(basePath string) *Discovery

func (*Discovery) ApplyMountOwnership added in v0.1.5

func (d *Discovery) ApplyMountOwnership(deploymentPath string, mounts []MountOwnership) error

ApplyMountOwnership sets ownership and creates subdirectories for bind mounts. When User is specified (UID:GID format), directories are chowned to that user. When User is empty, directories are chmod'd to 0777 as a fallback for non-template deploys.

func (*Discovery) CreateDeployment

func (d *Discovery) CreateDeployment(name string, composeContent string, fileMounts []string) error

func (*Discovery) DeleteDeployment

func (d *Discovery) DeleteDeployment(name string) error

func (*Discovery) DeleteMetadata

func (d *Discovery) DeleteMetadata(name string) error

func (*Discovery) FindDeployments

func (d *Discovery) FindDeployments() ([]models.Deployment, error)

func (*Discovery) FindInfrastructure added in v0.1.5

func (d *Discovery) FindInfrastructure() ([]models.Deployment, error)

func (*Discovery) GetComposeFile

func (d *Discovery) GetComposeFile(name string) (string, string, error)

func (*Discovery) GetDeployment

func (d *Discovery) GetDeployment(name string) (*models.Deployment, error)

func (*Discovery) SaveMetadata

func (d *Discovery) SaveMetadata(name string, metadata *models.ServiceMetadata) error

func (*Discovery) UpdateComposeFile

func (d *Discovery) UpdateComposeFile(name string, content string) error

type ImageInfo added in v0.1.5

type ImageInfo struct {
	Service  string `json:"service"`
	Image    string `json:"image"`
	IsLatest bool   `json:"is_latest"`
	IsBuild  bool   `json:"is_build"`
}

type Manager

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

func NewManager

func NewManager(deploymentsPath string) *Manager

func (*Manager) ApplyMountOwnership added in v0.1.5

func (m *Manager) ApplyMountOwnership(name string, mounts []MountOwnership) error

func (*Manager) BasePath

func (m *Manager) BasePath() string

func (*Manager) ComposeExec added in v0.1.5

func (m *Manager) ComposeExec(ctx context.Context, name string, service string, command string) (string, error)

func (*Manager) CreateDeployment

func (m *Manager) CreateDeployment(name string, composeContent string, fileMounts []string) error

func (*Manager) DeleteDeployment

func (m *Manager) DeleteDeployment(name string) error

func (*Manager) ExecuteQuickAction added in v0.1.5

func (m *Manager) ExecuteQuickAction(name string, actionID string) (string, error)

func (*Manager) GetComposeFile

func (m *Manager) GetComposeFile(name string) (string, string, error)

func (*Manager) GetComposeServiceNames added in v0.1.5

func (m *Manager) GetComposeServiceNames(name string) ([]string, error)

func (*Manager) GetComposeServices added in v0.1.5

func (m *Manager) GetComposeServices(name string) ([]models.Service, error)

func (*Manager) GetDeployment

func (m *Manager) GetDeployment(name string) (*models.Deployment, error)

func (*Manager) GetDeploymentImages added in v0.1.5

func (m *Manager) GetDeploymentImages(name string) ([]ImageInfo, error)

func (*Manager) GetDeploymentLogs

func (m *Manager) GetDeploymentLogs(name string, tail int) (string, error)

func (*Manager) GetStats

func (m *Manager) GetStats() (*DeploymentStats, error)

func (*Manager) ListDeployments

func (m *Manager) ListDeployments() ([]models.Deployment, error)

func (*Manager) ListInfrastructure added in v0.1.5

func (m *Manager) ListInfrastructure() ([]models.Deployment, error)

func (*Manager) PullDeployment added in v0.1.5

func (m *Manager) PullDeployment(name string, onlyLatest bool) (string, error)

func (*Manager) RebuildDeployment added in v0.1.5

func (m *Manager) RebuildDeployment(name string) (string, error)

func (*Manager) ResolveService added in v0.1.5

func (m *Manager) ResolveService(name string, serviceName string) (string, error)

func (*Manager) RestartDeployment

func (m *Manager) RestartDeployment(name string) (string, error)

func (*Manager) SaveMetadata

func (m *Manager) SaveMetadata(name string, metadata *models.ServiceMetadata) error

func (*Manager) StartDeployment

func (m *Manager) StartDeployment(name string) (string, error)

func (*Manager) StopDeployment

func (m *Manager) StopDeployment(name string) (string, error)

func (*Manager) UpdateDeployment

func (m *Manager) UpdateDeployment(name string, composeContent string) error

type MountOwnership added in v0.1.5

type MountOwnership struct {
	HostPath       string
	User           string // "UID:GID" or empty
	Subdirectories []string
}

MountOwnership describes ownership and subdirectory requirements for a bind mount.

type ResourceLimits added in v0.1.5

type ResourceLimits struct {
	MemoryLimit   int64   `json:"memory_limit"`
	MemorySwap    int64   `json:"memory_swap"`
	CPUs          float64 `json:"cpus"`
	CPUShares     int64   `json:"cpu_shares"`
	RestartPolicy string  `json:"restart_policy"`
}

func GetContainerResources added in v0.1.5

func GetContainerResources(containerID string) (*ResourceLimits, error)

type ResourceUpdate added in v0.1.5

type ResourceUpdate struct {
	MemoryLimit *int64   `json:"memory_limit,omitempty"`
	MemorySwap  *int64   `json:"memory_swap,omitempty"`
	CPUs        *float64 `json:"cpus,omitempty"`
	CPUShares   *int64   `json:"cpu_shares,omitempty"`
}

type ServiceExecutor added in v0.1.5

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

func NewServiceExecutor added in v0.1.5

func NewServiceExecutor(cfg *config.ServiceExecConfig) *ServiceExecutor

func (*ServiceExecutor) Execute added in v0.1.5

func (e *ServiceExecutor) Execute(args []string) ([]byte, error)

Jump to

Keyboard shortcuts

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