Documentation
¶
Index ¶
- Constants
- func AgentLabels(stack, name string) map[string]string
- func ContainerExists(ctx context.Context, cli dockerclient.DockerClient, name string) (bool, string, error)
- func ContainerName(stack, name string) string
- func CreateContainer(ctx context.Context, cli dockerclient.DockerClient, cfg ContainerConfig) (string, error)
- func EnsureImage(ctx context.Context, cli dockerclient.DockerClient, imageName string) error
- func EnsureNetwork(ctx context.Context, cli dockerclient.DockerClient, name, driver, stack string) (string, error)
- func GetContainerHostPort(ctx context.Context, cli dockerclient.DockerClient, containerID string, ...) (int, error)
- func GetContainerIP(ctx context.Context, cli dockerclient.DockerClient, ...) (string, error)
- func ImageExists(ctx context.Context, cli dockerclient.DockerClient, imageName string) (bool, error)
- func ListManagedContainers(ctx context.Context, cli dockerclient.DockerClient, stack string) ([]types.Container, error)
- func ListManagedNetworks(ctx context.Context, cli dockerclient.DockerClient, stack string) ([]string, error)
- func ManagedLabels(stack, name string, isMCPServer bool) map[string]string
- func NewDockerClient() (dockerclient.DockerClient, error)
- func Ping(ctx context.Context, cli dockerclient.DockerClient) error
- func RemoveContainer(ctx context.Context, cli dockerclient.DockerClient, containerID string, ...) error
- func RemoveNetwork(ctx context.Context, cli dockerclient.DockerClient, name string) error
- func StartContainer(ctx context.Context, cli dockerclient.DockerClient, containerID string) error
- func StopContainer(ctx context.Context, cli dockerclient.DockerClient, containerID string, ...) error
- type ContainerConfig
- type DockerRuntime
- func (d *DockerRuntime) Client() dockerclient.DockerClient
- func (d *DockerRuntime) Close() error
- func (d *DockerRuntime) EnsureImage(ctx context.Context, imageName string) error
- func (d *DockerRuntime) EnsureNetwork(ctx context.Context, name string, opts runtime.NetworkOptions) error
- func (d *DockerRuntime) Exists(ctx context.Context, name string) (bool, runtime.WorkloadID, error)
- func (d *DockerRuntime) GetHostPort(ctx context.Context, id runtime.WorkloadID, exposedPort int) (int, error)
- func (d *DockerRuntime) List(ctx context.Context, filter runtime.WorkloadFilter) ([]runtime.WorkloadStatus, error)
- func (d *DockerRuntime) ListNetworks(ctx context.Context, stack string) ([]string, error)
- func (d *DockerRuntime) Ping(ctx context.Context) error
- func (d *DockerRuntime) Remove(ctx context.Context, id runtime.WorkloadID) error
- func (d *DockerRuntime) RemoveNetwork(ctx context.Context, name string) error
- func (d *DockerRuntime) Start(ctx context.Context, cfg runtime.WorkloadConfig) (*runtime.WorkloadStatus, error)
- func (d *DockerRuntime) Status(ctx context.Context, id runtime.WorkloadID) (*runtime.WorkloadStatus, error)
- func (d *DockerRuntime) Stop(ctx context.Context, id runtime.WorkloadID) error
Constants ¶
const ( LabelManaged = "gridctl.managed" LabelStack = "gridctl.stack" LabelMCPServer = "gridctl.mcp-server" LabelResource = "gridctl.resource" LabelAgent = "gridctl.agent" )
Labels used to identify gridctl-managed resources.
Variables ¶
This section is empty.
Functions ¶
func AgentLabels ¶
AgentLabels returns labels that identify a managed agent container.
func ContainerExists ¶
func ContainerExists(ctx context.Context, cli dockerclient.DockerClient, name string) (bool, string, error)
ContainerExists checks if a container with the given name exists.
func ContainerName ¶
ContainerName generates a deterministic container name.
func CreateContainer ¶
func CreateContainer(ctx context.Context, cli dockerclient.DockerClient, cfg ContainerConfig) (string, error)
CreateContainer creates a new container with the given configuration.
func EnsureImage ¶
func EnsureImage(ctx context.Context, cli dockerclient.DockerClient, imageName string) error
EnsureImage pulls the image if it doesn't exist locally.
func EnsureNetwork ¶
func EnsureNetwork(ctx context.Context, cli dockerclient.DockerClient, name, driver, stack string) (string, error)
EnsureNetwork creates the network if it doesn't exist. The stack parameter is used for labeling (for cleanup).
func GetContainerHostPort ¶
func GetContainerHostPort(ctx context.Context, cli dockerclient.DockerClient, containerID string, containerPort int) (int, error)
GetContainerHostPort returns the host port mapped to a container port.
func GetContainerIP ¶
func GetContainerIP(ctx context.Context, cli dockerclient.DockerClient, containerID, networkName string) (string, error)
GetContainerIP returns the IP address of a container on the specified network.
func ImageExists ¶
func ImageExists(ctx context.Context, cli dockerclient.DockerClient, imageName string) (bool, error)
ImageExists checks if an image exists locally.
func ListManagedContainers ¶
func ListManagedContainers(ctx context.Context, cli dockerclient.DockerClient, stack string) ([]types.Container, error)
ListManagedContainers returns all containers managed by gridctl.
func ListManagedNetworks ¶
func ListManagedNetworks(ctx context.Context, cli dockerclient.DockerClient, stack string) ([]string, error)
ListManagedNetworks returns all networks managed by gridctl for a stack.
func ManagedLabels ¶
ManagedLabels returns labels that identify a managed container.
func NewDockerClient ¶
func NewDockerClient() (dockerclient.DockerClient, error)
NewDockerClient creates a new Docker client using environment defaults.
func Ping ¶
func Ping(ctx context.Context, cli dockerclient.DockerClient) error
Ping checks if the Docker daemon is accessible.
func RemoveContainer ¶
func RemoveContainer(ctx context.Context, cli dockerclient.DockerClient, containerID string, force bool) error
RemoveContainer removes a container.
func RemoveNetwork ¶
func RemoveNetwork(ctx context.Context, cli dockerclient.DockerClient, name string) error
RemoveNetwork removes a network by name.
func StartContainer ¶
func StartContainer(ctx context.Context, cli dockerclient.DockerClient, containerID string) error
StartContainer starts a container by ID.
func StopContainer ¶
func StopContainer(ctx context.Context, cli dockerclient.DockerClient, containerID string, timeoutSecs int) error
StopContainer stops a container gracefully.
Types ¶
type ContainerConfig ¶
type ContainerConfig struct {
Name string
Image string
Command []string // Override container command
Env map[string]string
Port int // Container port
HostPort int // Host port to publish (0 = auto-assign)
NetworkName string
Labels map[string]string
Transport string // "http" or "stdio"
Volumes []string // Volume mounts in "host:container" or "host:container:mode" format
}
ContainerConfig holds the configuration for creating a container.
type DockerRuntime ¶
type DockerRuntime struct {
// contains filtered or unexported fields
}
DockerRuntime implements runtime.WorkloadRuntime using Docker.
func NewWithClient ¶
func NewWithClient(cli dockerclient.DockerClient) *DockerRuntime
NewWithClient creates a DockerRuntime with an existing client (for testing).
func (*DockerRuntime) Client ¶
func (d *DockerRuntime) Client() dockerclient.DockerClient
Client returns the underlying Docker client for advanced use cases. This is needed by MCP gateway for stdio transport and container logs.
func (*DockerRuntime) Close ¶
func (d *DockerRuntime) Close() error
Close releases runtime resources.
func (*DockerRuntime) EnsureImage ¶
func (d *DockerRuntime) EnsureImage(ctx context.Context, imageName string) error
EnsureImage ensures the image is available locally.
func (*DockerRuntime) EnsureNetwork ¶
func (d *DockerRuntime) EnsureNetwork(ctx context.Context, name string, opts runtime.NetworkOptions) error
EnsureNetwork creates the network if it doesn't exist.
func (*DockerRuntime) Exists ¶
func (d *DockerRuntime) Exists(ctx context.Context, name string) (bool, runtime.WorkloadID, error)
Exists checks if a workload exists by name.
func (*DockerRuntime) GetHostPort ¶
func (d *DockerRuntime) GetHostPort(ctx context.Context, id runtime.WorkloadID, exposedPort int) (int, error)
GetHostPort returns the host port for a workload's exposed port.
func (*DockerRuntime) List ¶
func (d *DockerRuntime) List(ctx context.Context, filter runtime.WorkloadFilter) ([]runtime.WorkloadStatus, error)
List returns all workloads matching the filter.
func (*DockerRuntime) ListNetworks ¶
ListNetworks returns all managed networks for a stack.
func (*DockerRuntime) Ping ¶
func (d *DockerRuntime) Ping(ctx context.Context) error
Ping checks if the runtime is accessible.
func (*DockerRuntime) Remove ¶
func (d *DockerRuntime) Remove(ctx context.Context, id runtime.WorkloadID) error
Remove removes a stopped workload.
func (*DockerRuntime) RemoveNetwork ¶
func (d *DockerRuntime) RemoveNetwork(ctx context.Context, name string) error
RemoveNetwork removes a network by name.
func (*DockerRuntime) Start ¶
func (d *DockerRuntime) Start(ctx context.Context, cfg runtime.WorkloadConfig) (*runtime.WorkloadStatus, error)
Start starts a workload and returns its status.
func (*DockerRuntime) Status ¶
func (d *DockerRuntime) Status(ctx context.Context, id runtime.WorkloadID) (*runtime.WorkloadStatus, error)
Status returns the current status of a workload.
func (*DockerRuntime) Stop ¶
func (d *DockerRuntime) Stop(ctx context.Context, id runtime.WorkloadID) error
Stop stops a running workload.