Documentation
¶
Index ¶
- Constants
- func EnsureHostPrefix(host string) string
- func ResolveCilodHost(host string) string
- type AuthChallengeRequest
- type AuthChallengeResponse
- type AuthConnectRequest
- type AuthConnectResponse
- type Client
- func (c *Client) Connect(sshPrivateKeyPath string) (string, error)
- func (c *Client) DestroyEnvironment(name string) error
- func (c *Client) DownEnvironment(name string) error
- func (c *Client) Exec(name string, service string, cmd []string) error
- func (c *Client) GetStatus(name string) (*EnvironmentStatus, error)
- func (c *Client) ListEnvironments() ([]Environment, error)
- func (c *Client) SetRetryPolicy(maxRetries int, delay time.Duration)
- func (c *Client) SetTimeout(timeout time.Duration)
- func (c *Client) SetToken(token string)
- func (c *Client) StreamLogs(name string, service string) (io.ReadCloser, error)
- func (c *Client) SyncWorkspace(name string, localPath string) error
- func (c *Client) UpEnvironment(name string, opts UpOptions) error
- func (c *Client) UpEnvironmentWithResponse(name string, opts UpOptions) (*EnvironmentUpResponse, error)
- func (c *Client) WireGuardExchange(publicKey string) (*WGConfig, error)
- type Environment
- type EnvironmentDestroyRequest
- type EnvironmentDestroyResponse
- type EnvironmentDownRequest
- type EnvironmentDownResponse
- type EnvironmentExecRequest
- type EnvironmentStatus
- type EnvironmentUpRequest
- type EnvironmentUpResponse
- type ExecOptions
- type FileSync
- type ListEnvironmentsResponse
- type LogOptions
- type NetworkInfo
- type ServiceStatus
- type Streamer
- type UpOptions
- type WGConfig
- type WebSocketMessage
- type WireGuardExchangeRequest
- type WireGuardExchangeResponse
- type WorkspaceSyncRequest
- type WorkspaceSyncResponse
Constants ¶
const DefaultCilodPort = 8080
DefaultCilodPort is the default port for cilod HTTP API
Variables ¶
This section is empty.
Functions ¶
func EnsureHostPrefix ¶
EnsureHostPrefix ensures the host has http:// or https:// prefix
func ResolveCilodHost ¶
ResolveCilodHost resolves a cilod host to a full URL If host is just an IP or hostname without port, adds default port
Types ¶
type AuthChallengeRequest ¶
type AuthChallengeRequest struct {
PublicKey string `json:"public_key"`
}
AuthChallengeRequest requests a new authentication challenge Client calls this before attempting authentication
type AuthChallengeResponse ¶
type AuthChallengeResponse struct {
Challenge string `json:"challenge"`
ExpiresAt time.Time `json:"expires_at"`
}
AuthChallengeResponse returns a challenge to be signed Client must sign this challenge with their SSH private key
type AuthConnectRequest ¶
type AuthConnectRequest struct {
Challenge string `json:"challenge"`
Signature string `json:"signature"`
// SignatureFormat is the ssh.Signature.Format returned by the signer.
// For RSA keys this may be "rsa-sha2-256"/"rsa-sha2-512" rather than "ssh-rsa".
SignatureFormat string `json:"signature_format,omitempty"`
PublicKey string `json:"public_key"`
}
AuthConnectRequest sends the signed challenge to authenticate
type AuthConnectResponse ¶
type AuthConnectResponse struct {
Token string `json:"token"`
ExpiresAt time.Time `json:"expires_at"`
}
AuthConnectResponse returns the session token after successful auth
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the cilod API client for CLI-to-cilod communication
func NewClient ¶
NewClient creates a new cilod client host can be a hostname (e.g., "cilod.example.com") or IP with port (e.g., "192.168.1.100:8080") token is the session token for authenticated requests (can be empty for unauthenticated calls)
func (*Client) Connect ¶
Connect authenticates with the cilod server using SSH key challenge-response Returns a session token that must be used for subsequent requests
func (*Client) DestroyEnvironment ¶
DestroyEnvironment permanently destroys an environment
func (*Client) DownEnvironment ¶
DownEnvironment stops an environment
func (*Client) Exec ¶
Exec executes a command in a container This is a stub - full WebSocket implementation in Task 11
func (*Client) GetStatus ¶
func (c *Client) GetStatus(name string) (*EnvironmentStatus, error)
GetStatus returns detailed status for an environment
func (*Client) ListEnvironments ¶
func (c *Client) ListEnvironments() ([]Environment, error)
ListEnvironments returns all environments managed by this cilod
func (*Client) SetRetryPolicy ¶
SetRetryPolicy sets the retry policy for transient failures
func (*Client) SetTimeout ¶
SetTimeout sets the HTTP client timeout
func (*Client) StreamLogs ¶
StreamLogs returns a reader for streaming logs from a service The caller must close the returned ReadCloser when done
func (*Client) SyncWorkspace ¶
SyncWorkspace syncs local workspace files to the cilod environment This is a stub - full rsync over SSH implementation later
func (*Client) UpEnvironmentWithResponse ¶
func (c *Client) UpEnvironmentWithResponse(name string, opts UpOptions) (*EnvironmentUpResponse, error)
type Environment ¶
type Environment struct {
Name string `json:"name"`
Status string `json:"status"` // running, stopped, error
CreatedAt time.Time `json:"created_at"`
Services []string `json:"services"`
Subnet string `json:"subnet"`
}
Environment represents a cilod environment
type EnvironmentDestroyRequest ¶
type EnvironmentDestroyRequest struct {
Force bool `json:"force,omitempty"` // Skip confirmation
}
EnvironmentDestroyRequest destroys an environment permanently DELETE /environments/:name
type EnvironmentDestroyResponse ¶
EnvironmentDestroyResponse confirms environment is destroyed
type EnvironmentDownRequest ¶
type EnvironmentDownRequest struct {
Force bool `json:"force,omitempty"` // Force stop even if busy
}
EnvironmentDownRequest stops an environment POST /environments/:name/down
type EnvironmentDownResponse ¶
EnvironmentDownResponse confirms environment is stopped
type EnvironmentExecRequest ¶
type EnvironmentExecRequest struct {
Service string `json:"service"` // Target service/container
Command []string `json:"command"` // Command to execute
TTY bool `json:"tty,omitempty"` // Allocate pseudo-TTY
Stdin bool `json:"stdin,omitempty"` // Attach stdin
}
EnvironmentExecRequest executes a command in a container POST /environments/:name/exec Upgrades to WebSocket for interactive sessions
type EnvironmentStatus ¶
type EnvironmentStatus struct {
Name string `json:"name"`
Status string `json:"status"`
Services []ServiceStatus `json:"services"`
Networks []NetworkInfo `json:"networks"`
LastActive time.Time `json:"last_active"`
}
EnvironmentStatus represents detailed environment status
type EnvironmentUpRequest ¶
type EnvironmentUpRequest struct {
WorkspacePath string `json:"workspace_path,omitempty"` // Optional: override workspace
Build bool `json:"build,omitempty"` // Rebuild containers
Recreate bool `json:"recreate,omitempty"` // Force recreate
Project string `json:"project,omitempty"`
Isolate []string `json:"isolate,omitempty"`
}
EnvironmentUpRequest starts or creates an environment POST /environments/:name/up
type EnvironmentUpResponse ¶
type EnvironmentUpResponse struct {
Name string `json:"name"`
Status string `json:"status"`
Services map[string]string `json:"services"` // service name -> IP
Subnet string `json:"subnet"`
}
EnvironmentUpResponse confirms environment is running
type ExecOptions ¶
ExecOptions provides options for remote exec
type FileSync ¶
type FileSync struct {
Path string `json:"path"` // Relative path in workspace
Content []byte `json:"content"` // File content (base64 encoded for JSON)
Mode uint32 `json:"mode"` // File permissions
ModTime int64 `json:"mod_time"` // Unix timestamp
Hash string `json:"hash"` // SHA256 hash for verification
}
FileSync describes a single file to sync
type ListEnvironmentsResponse ¶
type ListEnvironmentsResponse struct {
Environments []Environment `json:"environments"`
}
ListEnvironmentsResponse contains all environments managed by this cilod
type LogOptions ¶
LogOptions provides options for log streaming
type NetworkInfo ¶
type NetworkInfo struct {
Name string `json:"name"`
Subnet string `json:"subnet"`
Gateway string `json:"gateway"`
}
NetworkInfo describes a Docker network
type ServiceStatus ¶
type ServiceStatus struct {
Name string `json:"name"`
State string `json:"state"` // running, exited, etc.
Status string `json:"status"` // Up 2 hours, Exited (0), etc.
Health string `json:"health,omitempty"`
IP string `json:"ip,omitempty"`
}
ServiceStatus provides detailed service information
type Streamer ¶
type Streamer struct {
// contains filtered or unexported fields
}
Streamer provides WebSocket-based streaming for exec and logs
func NewStreamer ¶
NewStreamer creates a new WebSocket streamer
func (*Streamer) SetTimeout ¶
SetTimeout sets the WebSocket handshake timeout
func (*Streamer) StreamExec ¶
func (s *Streamer) StreamExec(ctx context.Context, env, service string, cmd []string, stdin io.Reader, stdout, stderr io.Writer, tty bool) error
StreamExec executes a command in a container via WebSocket Supports bidirectional streaming (stdin/stdout/stderr) and PTY allocation
type UpOptions ¶
type UpOptions struct {
WorkspacePath string
Build bool
Recreate bool
Project string
Isolate []string
}
UpOptions provides options for creating/starting an environment
type WGConfig ¶
type WGConfig struct {
ServerPublicKey string
ServerEndpoint string
ServerAddress string
AssignedIP string
AllowedIPs []string
EnvironmentSubnet string
}
WGConfig is the client-side WireGuard configuration
type WebSocketMessage ¶
type WebSocketMessage struct {
Type string `json:"type"` // "stdout", "stderr", "stdin", "error", "exit", "signal", "eof"
Data []byte `json:"data"` // Message payload
ExitCode int `json:"exit_code,omitempty"` // For exec exit
}
WebSocketMessage is the envelope for WebSocket communication
type WireGuardExchangeRequest ¶
type WireGuardExchangeRequest struct {
PublicKey string `json:"public_key"` // Client's WireGuard public key
EnvironmentID string `json:"environment_id"` // Optional: env to connect to
UserID string `json:"user_id"` // Optional: for multi-user tracking
}
WireGuardExchangeRequest initiates peer connection POST /wireguard/exchange
type WireGuardExchangeResponse ¶
type WireGuardExchangeResponse struct {
ServerPublicKey string `json:"server_public_key"` // cilod's WG public key
ServerEndpoint string `json:"server_endpoint"` // cilod's WG endpoint (IP:port)
ServerAddress string `json:"server_address"` // cilod's WG tunnel IP (for proxy/DNS)
AssignedIP string `json:"assigned_ip"` // IP assigned to client in WG subnet
AllowedIPs []string `json:"allowed_ips"` // Routes through tunnel
EnvironmentSubnet string `json:"environment_subnet,omitempty"`
}
WireGuardExchangeResponse provides server details for client configuration Client uses this to configure their WireGuard interface
type WorkspaceSyncRequest ¶
type WorkspaceSyncRequest struct {
EnvironmentName string `json:"environment_name"` // URL param
SyncType string `json:"sync_type"` // "full" or "incremental"
Files []FileSync `json:"files"` // Files to sync
DeletePaths []string `json:"delete_paths,omitempty"` // Paths to delete
}
WorkspaceSyncRequest receives workspace file sync POST /sync/:name Supports both full sync and incremental (rsync-style) updates
type WorkspaceSyncResponse ¶
type WorkspaceSyncResponse struct {
EnvironmentName string `json:"environment_name"`
FilesReceived int `json:"files_received"`
FilesUpdated int `json:"files_updated"`
FilesDeleted int `json:"files_deleted"`
Errors []string `json:"errors,omitempty"`
}
WorkspaceSyncResponse confirms sync completion