Documentation
¶
Overview ¶
Package services is the resource module for managing already-running services on a remote VM. Sibling to install (which CREATES) and deploy (which DEPLOYS).
Wraps three distinct server endpoints:
- Container lifecycle: POST /api/v2/tenant/container/{start,stop,remove} (JSON body)
- Container status: POST /api/v2/tenant/docker/container/status (JSON body)
- Host actions: POST /api/v2/tenant/services/action (multipart form, whitelisted action keys)
Maps 1:1 to the `vxcli services` command surface.
Index ¶
- type ActionResult
- type Client
- func (c *Client) List(ctx context.Context, ssh SSH) (*ActionResult, error)
- func (c *Client) Logs(ctx context.Context, ssh SSH, unit string) (*ActionResult, error)
- func (c *Client) Remove(ctx context.Context, ssh SSH, containerName string) (*LifecycleResult, error)
- func (c *Client) Restart(ctx context.Context, ssh SSH, containerName string) (*LifecycleResult, error)
- func (c *Client) Start(ctx context.Context, ssh SSH, containerName string) (*LifecycleResult, error)
- func (c *Client) Status(ctx context.Context, ssh SSH, name string) (*StatusResult, error)
- func (c *Client) Stop(ctx context.Context, ssh SSH, containerName string) (*LifecycleResult, error)
- func (c *Client) VM() *VMClient
- type ContainerSummary
- type LifecycleResult
- type SSH
- type StatusResult
- type VMClient
- func (vm *VMClient) Disk(ctx context.Context, ssh SSH) (*ActionResult, error)
- func (vm *VMClient) DiskCleanup(ctx context.Context, ssh SSH) (*ActionResult, error)
- func (vm *VMClient) DockerCleanup(ctx context.Context, ssh SSH) (*ActionResult, error)
- func (vm *VMClient) KillPort(ctx context.Context, ssh SSH, port string) (*ActionResult, error)
- func (vm *VMClient) ListContainers(ctx context.Context, ssh SSH) (*ActionResult, error)
- func (vm *VMClient) ListServices(ctx context.Context, ssh SSH) (*ActionResult, error)
- func (vm *VMClient) Memory(ctx context.Context, ssh SSH) (*ActionResult, error)
- func (vm *VMClient) Reboot(ctx context.Context, ssh SSH) (*ActionResult, error)
- func (vm *VMClient) RestartDocker(ctx context.Context, ssh SSH) (*ActionResult, error)
- func (vm *VMClient) Shutdown(ctx context.Context, ssh SSH) (*ActionResult, error)
- func (vm *VMClient) StopService(ctx context.Context, ssh SSH, unit string) (*ActionResult, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ActionResult ¶
type ActionResult struct {
Success bool `json:"success"`
Action string `json:"action"`
Output string `json:"output"`
Message string `json:"message"`
Error string `json:"error,omitempty"`
Raw map[string]interface{} `json:"-"`
}
ActionResult is the JSON envelope every admin-action endpoint returns.
type Client ¶
Client is the entry point. Construct via the parent SDK client:
c.Services()
Methods are concurrency-safe via the shared Transport.
func (*Client) List ¶
List returns the docker ps -a output for the host. Wraps the list_docker_containers admin action.
func (*Client) Logs ¶
Logs tails journalctl logs for a systemd unit (NOT for a docker container). The server template runs `journalctl -u <unit> -n 50`, falling back to /var/log/<unit> if the unit isn't registered.
func (*Client) Remove ¶
func (c *Client) Remove(ctx context.Context, ssh SSH, containerName string) (*LifecycleResult, error)
Remove (stop + delete) a container by name on the target VM. Destructive — wrap in your own confirmation prompt.
func (*Client) Restart ¶
func (c *Client) Restart(ctx context.Context, ssh SSH, containerName string) (*LifecycleResult, error)
Restart is a convenience: Stop, then Start. The server has no native restart endpoint for containers; we chain.
func (*Client) Start ¶
func (c *Client) Start(ctx context.Context, ssh SSH, containerName string) (*LifecycleResult, error)
Start a stopped container by name on the target VM.
func (*Client) Status ¶
Status inspects a single container by name (or all containers if name == ""). Endpoint: POST /api/v2/tenant/docker/container/status
type ContainerSummary ¶
type ContainerSummary struct {
ID string `json:"id"`
Name string `json:"name"`
Image string `json:"image"`
Status string `json:"status"`
Ports string `json:"ports"`
}
ContainerSummary mirrors the docker ps summary the server returns.
type LifecycleResult ¶
type LifecycleResult struct {
Success bool `json:"success,omitempty"`
Message string `json:"message,omitempty"`
ContainerID string `json:"container_id,omitempty"`
Removed bool `json:"removed,omitempty"`
Raw map[string]interface{} `json:"-"`
}
LifecycleResult is the JSON envelope every /container/{action} endpoint returns. Most fields are optional; raw is preserved for debugging.
type SSH ¶
type SSH struct {
Host string
User string
KeyPairName string
WorkspaceUser string
Organization string
}
SSH is the common SSH target. Same shape as install.SSH / deploy.SSH — every method here accepts it. KeyPairName resolves against your workspace Vault on the tenant node.
type StatusResult ¶
type StatusResult struct {
Success bool `json:"success"`
Hostname string `json:"hostname"`
Total int `json:"total"`
Containers []ContainerSummary `json:"containers"`
Raw map[string]interface{} `json:"-"`
}
StatusResult is the response shape of /docker/container/status.
type VMClient ¶
VMClient — host-level operations. Reachable via Client.VM().
func (*VMClient) DiskCleanup ¶
DiskCleanup — apt autoremove + apt clean + journalctl vacuum.
func (*VMClient) DockerCleanup ¶
DockerCleanup — docker system prune -af --volumes.
func (*VMClient) ListContainers ¶
ListContainers — docker ps -a (alias of Client.List for naming convenience).
func (*VMClient) ListServices ¶
ListServices — running systemd services.
func (*VMClient) RestartDocker ¶
RestartDocker — sudo systemctl restart docker.
func (*VMClient) StopService ¶
StopService — sudo systemctl stop <unit>.