dockerimport

package
v1.6.3 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2026 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

Package dockerimport adopts pre-existing Docker resources (hand-run containers, compose stacks, volumes, networks) into Miabi without tearing down what is running. Discovery lists the node's *unmanaged* resources; import creates the matching domain records. The default mode is adopt-in-place: an app record plus a synthetic active Release pointing at the live container, so status/logs/stats/stop/restart work immediately and the container keeps running. A native deploy later recreates it under Miabi conventions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Clients

type Clients interface {
	For(serverID uint) (docker.Client, error)
	LocalID() uint
	// SelfContainerID is Miabi's own container on the node (the control plane
	// locally, the agent remotely), or "" when it cannot be determined. Discovery
	// uses it to find the Compose project the platform stack runs under — see
	// platformComposeProject.
	SelfContainerID(serverID uint) string
}

Clients resolves a node's Docker client (local or remote agent).

type ImportItem

type ImportItem struct {
	Kind    string     // "container" | "volume" | "network"
	Ref     string     // container ID or volume/network name
	AppName string     // optional app name for containers
	Mode    ImportMode // containers only; default adopt
	// StackName groups this container's app under a Stack of that name (created or
	// reused). Typically the container's compose project, so each compose project
	// becomes its own stack. Empty = no stack (falls back to request StackName).
	StackName string
}

ImportItem is one resource to import.

type ImportMode

type ImportMode string

ImportMode selects how a container is adopted.

const (
	// ModeAdopt tracks the live container as-is (zero downtime); converge on the
	// next deploy.
	ModeAdopt ImportMode = "adopt"
	// ModeReconcile adopts, then immediately enqueues a native deploy that
	// recreates the container under Miabi conventions and removes the old one.
	ModeReconcile ImportMode = "reconcile"
)

type ImportRequest

type ImportRequest struct {
	WorkspaceID uint
	// StackName is a fallback stack for container items that carry no per-item
	// StackName (e.g. ungrouped containers). Per-item StackName takes precedence,
	// so a compose project maps to its own stack.
	StackName string
	Items     []ImportItem
}

ImportRequest is a selection of resources to import into a workspace.

type ImportResult

type ImportResult struct {
	// StackIDs lists the IDs of stacks created or reused during the import
	// (compose project → stack), keyed by stack name.
	StackIDs map[string]uint `json:"stack_ids,omitempty"`
	Items    []ItemResult    `json:"items"`
}

ImportResult is the aggregate outcome of an import batch.

type Importable

type Importable struct {
	Containers []ImportableContainer `json:"containers"`
	Volumes    []ImportableVolume    `json:"volumes"`
	Networks   []ImportableNetwork   `json:"networks"`
}

Importable is a node's set of adoptable (unmanaged) resources.

type ImportableContainer

type ImportableContainer struct {
	ID              string               `json:"id"`
	Name            string               `json:"name"`
	Image           string               `json:"image"`
	Tag             string               `json:"tag"`
	State           string               `json:"state"`
	Ports           []docker.PortMapping `json:"ports,omitempty"`
	EnvCount        int                  `json:"env_count"`
	SecretEnvKeys   []string             `json:"secret_env_keys,omitempty"`
	Volumes         []string             `json:"volumes,omitempty"`  // referenced Docker volume names
	Networks        []string             `json:"networks,omitempty"` // attached network names (non-system)
	RestartPolicy   string               `json:"restart_policy"`
	MemoryBytes     int64                `json:"memory_bytes"`
	NanoCPUs        int64                `json:"nano_cpus"`
	Command         []string             `json:"command,omitempty"`
	ComposeProject  string               `json:"compose_project,omitempty"`
	ComposeService  string               `json:"compose_service,omitempty"`
	SuggestedName   string               `json:"suggested_name"`
	AlreadyImported bool                 `json:"already_imported"`
}

ImportableContainer is an unmanaged container enriched from inspect, with its compose grouping and volume/network relationships.

type ImportableNetwork

type ImportableNetwork struct {
	Name            string   `json:"name"`
	Driver          string   `json:"driver"`
	UsedBy          []string `json:"used_by,omitempty"`
	AlreadyImported bool     `json:"already_imported"`
}

ImportableNetwork is an unmanaged Docker network and the unmanaged containers attached to it.

type ImportableVolume

type ImportableVolume struct {
	Name            string   `json:"name"`
	Driver          string   `json:"driver"`
	UsedBy          []string `json:"used_by,omitempty"`
	AlreadyImported bool     `json:"already_imported"`
}

ImportableVolume is an unmanaged Docker volume and the unmanaged containers that use it.

type ItemResult

type ItemResult struct {
	Kind    string `json:"kind"`
	Ref     string `json:"ref"`
	Status  string `json:"status"` // imported | skipped | failed
	Message string `json:"message,omitempty"`
	AppID   uint   `json:"app_id,omitempty"`
}

ItemResult reports the outcome of importing one item.

type Service

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

Service implements discovery + import of pre-existing Docker resources.

func (*Service) Discover

func (s *Service) Discover(ctx context.Context, serverID uint) (*Importable, error)

Discover lists the node's unmanaged containers/volumes/networks, enriched with inspect data, compose grouping, relationships, and already-imported flags.

func (*Service) Import

func (s *Service) Import(ctx context.Context, actorID, serverID uint, req ImportRequest) (*ImportResult, error)

Import creates Miabi records for the selected resources. Networks and volumes are imported first so containers can attach them. Each item's outcome is reported independently — one failure never aborts the batch.

Jump to

Keyboard shortcuts

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