Documentation
¶
Index ¶
- Constants
- func FormatDeploymentID(id string) string
- func FormatDuration(d time.Duration) string
- func GetCurrentUser() string
- type DeploymentHistory
- type DeploymentState
- type DeploymentStatus
- type HealthCheckState
- type HistoryOptions
- type ServiceState
- type StateManager
- func (s *StateManager) CleanupOldDeployments() error
- func (s *StateManager) GetDeployment(deploymentID string) (*DeploymentState, error)
- func (s *StateManager) GetLatestSuccessful() (*DeploymentState, error)
- func (s *StateManager) GetPreviousDeployment(currentID string) (*DeploymentState, error)
- func (s *StateManager) Initialize() error
- func (s *StateManager) ListDeployments(opts *HistoryOptions) ([]*DeploymentState, error)
- func (s *StateManager) SaveDeployment(deployment *DeploymentState) error
Constants ¶
const ( // StateDir is the directory on the server where state is stored StateDir = "/var/lib/tako-cli" // MaxHistoryEntries is the maximum number of deployments to keep MaxHistoryEntries = 50 )
Variables ¶
This section is empty.
Functions ¶
func FormatDeploymentID ¶
FormatDeploymentID formats a deployment ID for display
func FormatDuration ¶
FormatDuration formats a duration for display
func GetCurrentUser ¶
func GetCurrentUser() string
GetCurrentUser returns the current system user for deployment tracking
Types ¶
type DeploymentHistory ¶
type DeploymentHistory struct {
ProjectName string `json:"projectName"`
Server string `json:"server"`
Deployments []*DeploymentState `json:"deployments"`
LastUpdated time.Time `json:"lastUpdated"`
}
DeploymentHistory contains all deployments for a project
type DeploymentState ¶
type DeploymentState struct {
ID string `json:"id"` // Unique deployment ID (timestamp-based)
Timestamp time.Time `json:"timestamp"` // When deployment occurred
ProjectName string `json:"projectName"` // Project name
Version string `json:"version"` // Project version
Status DeploymentStatus `json:"status"` // success, failed, rolled_back
Services map[string]ServiceState `json:"services"` // Deployed services
User string `json:"user"` // Who deployed
Host string `json:"host"` // Which server
Duration time.Duration `json:"duration"` // How long deployment took
Message string `json:"message"` // Deployment message/notes
Error string `json:"error,omitempty"` // Error if failed
// Git information
GitCommit string `json:"gitCommit,omitempty"` // Full commit hash
GitCommitShort string `json:"gitCommitShort,omitempty"` // Short commit hash (7 chars)
GitBranch string `json:"gitBranch,omitempty"` // Branch name
GitCommitMsg string `json:"gitCommitMsg,omitempty"` // Commit message
GitAuthor string `json:"gitAuthor,omitempty"` // Commit author
}
DeploymentState represents a single deployment's state
type DeploymentStatus ¶
type DeploymentStatus string
DeploymentStatus represents deployment outcome
const ( StatusInProgress DeploymentStatus = "in_progress" StatusSuccess DeploymentStatus = "success" StatusFailed DeploymentStatus = "failed" StatusRolledBack DeploymentStatus = "rolled_back" )
type HealthCheckState ¶
type HealthCheckState struct {
Enabled bool `json:"enabled"`
Path string `json:"path"`
Healthy bool `json:"healthy"`
LastCheck time.Time `json:"lastCheck"`
}
HealthCheckState represents health check status
type HistoryOptions ¶
type HistoryOptions struct {
Limit int // Max number of deployments to return
Status DeploymentStatus // Filter by status
Service string // Filter by service name
Since time.Time // Only deployments after this time
IncludeFailed bool // Include failed deployments
}
HistoryOptions for filtering deployment history
type ServiceState ¶
type ServiceState struct {
Name string `json:"name"`
Image string `json:"image"` // Image name with tag
ImageID string `json:"imageId"` // Docker image ID
ContainerID string `json:"containerId"` // Running container ID
Port int `json:"port"`
Replicas int `json:"replicas"`
Env map[string]string `json:"env"`
HealthCheck HealthCheckState `json:"healthCheck"`
}
ServiceState represents a deployed service's state
type StateManager ¶
type StateManager struct {
// contains filtered or unexported fields
}
StateManager manages deployment state on remote servers
func NewStateManager ¶
func NewStateManager(client *ssh.Client, projectName, server string) *StateManager
NewStateManager creates a new state manager
func (*StateManager) CleanupOldDeployments ¶
func (s *StateManager) CleanupOldDeployments() error
CleanupOldDeployments removes old deployment records
func (*StateManager) GetDeployment ¶
func (s *StateManager) GetDeployment(deploymentID string) (*DeploymentState, error)
GetDeployment retrieves a specific deployment by ID
func (*StateManager) GetLatestSuccessful ¶
func (s *StateManager) GetLatestSuccessful() (*DeploymentState, error)
GetLatestSuccessful returns the most recent successful deployment
func (*StateManager) GetPreviousDeployment ¶
func (s *StateManager) GetPreviousDeployment(currentID string) (*DeploymentState, error)
GetPreviousDeployment returns the deployment before the current one
func (*StateManager) Initialize ¶
func (s *StateManager) Initialize() error
Initialize ensures the state directory exists on the server
func (*StateManager) ListDeployments ¶
func (s *StateManager) ListDeployments(opts *HistoryOptions) ([]*DeploymentState, error)
ListDeployments lists all deployments with optional filtering
func (*StateManager) SaveDeployment ¶
func (s *StateManager) SaveDeployment(deployment *DeploymentState) error
SaveDeployment saves a deployment state to the server