Documentation
¶
Index ¶
- Constants
- type ConfigInfo
- type ContainerInfo
- type DeploymentState
- type EnvironmentState
- type GlobalState
- type GraphMetadata
- type HealthCheck
- type LockInfo
- type Manager
- func (m *Manager) AcquireLock(operation string) error
- func (m *Manager) AcquireLockWithWait(operation string) error
- func (m *Manager) CheckBuildCache(serviceName string, files map[string]string) (bool, error)
- func (m *Manager) Exists() bool
- func (m *Manager) GetBasePath() string
- func (m *Manager) GetCurrentDeployment() (*DeploymentState, error)
- func (m *Manager) GetDeploymentHistory(limit int) ([]*DeploymentState, error)
- func (m *Manager) GetLastStableDeployment() (*DeploymentState, error)
- func (m *Manager) GetLockHolder() (*LockInfo, error)
- func (m *Manager) GetServiceState(serviceName string) (*ServiceState, error)
- func (m *Manager) IsLocked() bool
- func (m *Manager) LogDeployment(message string) error
- func (m *Manager) LogError(err error) error
- func (m *Manager) ReleaseLock() error
- func (m *Manager) SaveBuildCache(serviceName string, files map[string]string) error
- func (m *Manager) SaveDeployment(deployment *DeploymentState) error
- func (m *Manager) SaveServiceState(serviceName string, state *ServiceState) error
- type NetworkInfo
- type Resource
- type ResourceGraph
- type ResourceManager
- func (m *ResourceManager) Delete(urn string) error
- func (m *ResourceManager) Export() ([]byte, error)
- func (m *ResourceManager) GenerateURN(resourceType ResourceType, name string) string
- func (m *ResourceManager) Get(urn string) *Resource
- func (m *ResourceManager) GetByType(resourceType ResourceType) []*Resource
- func (m *ResourceManager) GetDependencyOrder() ([]*Resource, error)
- func (m *ResourceManager) HasChanged(urn string, inputs map[string]interface{}) bool
- func (m *ResourceManager) Import(data []byte) error
- func (m *ResourceManager) ListAll() []*Resource
- func (m *ResourceManager) Load() error
- func (m *ResourceManager) Register(resourceType ResourceType, name string, inputs map[string]interface{}, ...) (*Resource, error)
- func (m *ResourceManager) Remove(urn string)
- func (m *ResourceManager) Save() error
- func (m *ResourceManager) SetOutputs(urn string, outputs map[string]interface{}) error
- func (m *ResourceManager) SetStatus(urn string, status ResourceStatus) error
- type ResourceStatus
- type ResourceType
- type Resources
- type ServiceCurrent
- type ServiceDeploy
- type ServiceHistory
- type ServiceState
- type StateLock
- func (l *StateLock) Acquire(operation string) (*LockInfo, error)
- func (l *StateLock) AcquireWithWait(operation string) (*LockInfo, error)
- func (l *StateLock) ForceRelease() error
- func (l *StateLock) GetLockInfo() (*LockInfo, error)
- func (l *StateLock) IsLocked() bool
- func (l *StateLock) Release(lockInfo *LockInfo) error
- type VolumeInfo
Constants ¶
const ( // LockFileName is the name of the lock file LockFileName = ".lock" // LockTimeout is how long a lock is considered valid LockTimeout = 30 * time.Minute // LockPollInterval is how often to check for lock release LockPollInterval = 1 * time.Second // MaxLockWait is the maximum time to wait for a lock MaxLockWait = 5 * time.Minute )
const MaxLocalHistoryEntries = 50
MaxLocalHistoryEntries is the maximum number of deployment history files to keep
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConfigInfo ¶
ConfigInfo represents configuration metadata
type ContainerInfo ¶
type ContainerInfo struct {
ID string `json:"id"`
Node string `json:"node,omitempty"`
Status string `json:"status"`
StartedAt time.Time `json:"started_at"`
}
ContainerInfo represents a container instance
type DeploymentState ¶
type DeploymentState struct {
DeploymentID string `json:"deployment_id"`
Timestamp time.Time `json:"timestamp"`
Environment string `json:"environment"`
Mode string `json:"mode"`
Servers []string `json:"servers,omitempty"`
Status string `json:"status"` // success, failed, partial
DurationSeconds int `json:"duration_seconds"`
Services map[string]*ServiceDeploy `json:"services"`
Network *NetworkInfo `json:"network"`
Volumes []VolumeInfo `json:"volumes"`
Config ConfigInfo `json:"config"`
RollbackPoint bool `json:"rollback_point"`
Notes string `json:"notes"`
GitCommit string `json:"git_commit,omitempty"`
TriggeredBy string `json:"triggered_by,omitempty"`
}
DeploymentState represents a single deployment
type EnvironmentState ¶
type EnvironmentState struct {
Active bool `json:"active"`
Servers []string `json:"servers"`
LastDeployment time.Time `json:"last_deployment"`
DeploymentID string `json:"deployment_id"`
}
EnvironmentState represents state for a specific environment
type GlobalState ¶
type GlobalState struct {
Version string `json:"version"`
Project struct {
Name string `json:"name"`
CreatedAt time.Time `json:"created_at"`
LastDeployed time.Time `json:"last_deployed"`
} `json:"project"`
Mode string `json:"mode"` // runtime mode, e.g. "takod"
Environments map[string]*EnvironmentState `json:"environments"`
Metadata struct {
TakoVersion string `json:"tako_version"`
ConfigHash string `json:"config_hash"`
} `json:"metadata"`
}
GlobalState represents the overall project state
type GraphMetadata ¶ added in v0.0.3
type GraphMetadata struct {
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
LastDeployment string `json:"last_deployment,omitempty"`
DeploymentCount int `json:"deployment_count"`
}
GraphMetadata contains metadata about the resource graph
type HealthCheck ¶
type HealthCheck struct {
Endpoint string `json:"endpoint"`
LastCheck time.Time `json:"last_check"`
Status string `json:"status"`
ResponseTimeMs int `json:"response_time_ms"`
}
HealthCheck represents health check information
type LockInfo ¶ added in v0.0.3
type LockInfo struct {
ID string `json:"id"`
Operation string `json:"operation"` // deploy, destroy, rollback, etc.
Who string `json:"who"` // user@hostname
Created time.Time `json:"created"`
PID int `json:"pid"`
}
LockInfo contains information about who holds the lock
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager handles local state persistence in .tako directory
func NewManager ¶
NewManager creates a new state manager
func (*Manager) AcquireLock ¶ added in v0.1.4
AcquireLock acquires a cross-process lock for the given operation Returns an error if another process holds the lock
func (*Manager) AcquireLockWithWait ¶ added in v0.1.4
AcquireLockWithWait acquires a cross-process lock, waiting if necessary
func (*Manager) CheckBuildCache ¶
CheckBuildCache checks if rebuild is needed based on file checksums
func (*Manager) GetBasePath ¶
GetBasePath returns the base .tako directory path
func (*Manager) GetCurrentDeployment ¶
func (m *Manager) GetCurrentDeployment() (*DeploymentState, error)
GetCurrentDeployment returns the current deployment state
func (*Manager) GetDeploymentHistory ¶
func (m *Manager) GetDeploymentHistory(limit int) ([]*DeploymentState, error)
GetDeploymentHistory returns deployment history
func (*Manager) GetLastStableDeployment ¶
func (m *Manager) GetLastStableDeployment() (*DeploymentState, error)
GetLastStableDeployment returns the last stable deployment for rollback
func (*Manager) GetLockHolder ¶ added in v0.1.4
GetLockHolder returns information about who holds the lock
func (*Manager) GetServiceState ¶
func (m *Manager) GetServiceState(serviceName string) (*ServiceState, error)
GetServiceState retrieves service state
func (*Manager) IsLocked ¶ added in v0.1.4
IsLocked returns true if the state is locked by another process
func (*Manager) LogDeployment ¶
LogDeployment logs deployment messages
func (*Manager) ReleaseLock ¶ added in v0.1.4
ReleaseLock releases the cross-process lock
func (*Manager) SaveBuildCache ¶
SaveBuildCache saves build cache information
func (*Manager) SaveDeployment ¶
func (m *Manager) SaveDeployment(deployment *DeploymentState) error
SaveDeployment saves deployment state
func (*Manager) SaveServiceState ¶
func (m *Manager) SaveServiceState(serviceName string, state *ServiceState) error
SaveServiceState saves service-specific state
type NetworkInfo ¶
type NetworkInfo struct {
Name string `json:"name"`
Driver string `json:"driver"`
ID string `json:"id"`
}
NetworkInfo represents network configuration
type Resource ¶ added in v0.0.3
type Resource struct {
// URN is a unique identifier: urn:tako:{project}:{env}:{type}:{name}
URN string `json:"urn"`
Type ResourceType `json:"type"`
Name string `json:"name"`
Provider string `json:"provider"` // docker, takod, tako-proxy
// State
Status ResourceStatus `json:"status"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
// Inputs are the user-provided configuration
Inputs map[string]interface{} `json:"inputs"`
// Outputs are provider-generated values
Outputs map[string]interface{} `json:"outputs"`
// Dependencies are URNs of resources this depends on
Dependencies []string `json:"dependencies,omitempty"`
// Parent is the URN of the parent resource (for hierarchical resources)
Parent string `json:"parent,omitempty"`
// Checksum of inputs for change detection
InputsHash string `json:"inputs_hash"`
}
Resource represents a tracked deployment resource.
type ResourceGraph ¶ added in v0.0.3
type ResourceGraph struct {
Version int `json:"version"`
Project string `json:"project"`
Environment string `json:"environment"`
Resources map[string]*Resource `json:"resources"` // URN -> Resource
Metadata GraphMetadata `json:"metadata"`
}
ResourceGraph represents the complete state of all resources
type ResourceManager ¶ added in v0.0.3
type ResourceManager struct {
// contains filtered or unexported fields
}
ResourceManager manages the resource graph
func NewResourceManager ¶ added in v0.0.3
func NewResourceManager(basePath, project, environment string) *ResourceManager
NewResourceManager creates a new resource manager
func (*ResourceManager) Delete ¶ added in v0.0.3
func (m *ResourceManager) Delete(urn string) error
Delete marks a resource as deleted
func (*ResourceManager) Export ¶ added in v0.0.3
func (m *ResourceManager) Export() ([]byte, error)
Export exports the resource graph to a portable format
func (*ResourceManager) GenerateURN ¶ added in v0.0.3
func (m *ResourceManager) GenerateURN(resourceType ResourceType, name string) string
GenerateURN generates a URN for a resource
func (*ResourceManager) Get ¶ added in v0.0.3
func (m *ResourceManager) Get(urn string) *Resource
Get retrieves a resource by URN
func (*ResourceManager) GetByType ¶ added in v0.0.3
func (m *ResourceManager) GetByType(resourceType ResourceType) []*Resource
GetByType returns all resources of a specific type
func (*ResourceManager) GetDependencyOrder ¶ added in v0.0.3
func (m *ResourceManager) GetDependencyOrder() ([]*Resource, error)
GetDependencyOrder returns resources in dependency order (topological sort)
func (*ResourceManager) HasChanged ¶ added in v0.0.3
func (m *ResourceManager) HasChanged(urn string, inputs map[string]interface{}) bool
HasChanged checks if a resource's inputs have changed
func (*ResourceManager) Import ¶ added in v0.0.3
func (m *ResourceManager) Import(data []byte) error
Import imports a resource graph from exported data
func (*ResourceManager) ListAll ¶ added in v0.0.3
func (m *ResourceManager) ListAll() []*Resource
ListAll returns all resources sorted by type and name
func (*ResourceManager) Load ¶ added in v0.0.3
func (m *ResourceManager) Load() error
Load loads the resource graph from disk
func (*ResourceManager) Register ¶ added in v0.0.3
func (m *ResourceManager) Register(resourceType ResourceType, name string, inputs map[string]interface{}, dependencies []string) (*Resource, error)
Register registers a new resource or updates an existing one
func (*ResourceManager) Remove ¶ added in v0.0.3
func (m *ResourceManager) Remove(urn string)
Remove completely removes a resource from the graph
func (*ResourceManager) Save ¶ added in v0.0.3
func (m *ResourceManager) Save() error
Save saves the resource graph to disk
func (*ResourceManager) SetOutputs ¶ added in v0.0.3
func (m *ResourceManager) SetOutputs(urn string, outputs map[string]interface{}) error
SetOutputs sets the outputs for a resource after creation
func (*ResourceManager) SetStatus ¶ added in v0.0.3
func (m *ResourceManager) SetStatus(urn string, status ResourceStatus) error
SetStatus sets the status of a resource
type ResourceStatus ¶ added in v0.0.3
type ResourceStatus string
ResourceStatus represents the current status of a resource
const ( StatusPending ResourceStatus = "pending" StatusCreating ResourceStatus = "creating" StatusCreated ResourceStatus = "created" StatusUpdating ResourceStatus = "updating" StatusDeleting ResourceStatus = "deleting" StatusDeleted ResourceStatus = "deleted" StatusFailed ResourceStatus = "failed" )
type ResourceType ¶ added in v0.0.3
type ResourceType string
ResourceType represents the type of a tracked resource
const ( ResourceService ResourceType = "service" ResourceNetwork ResourceType = "network" ResourceVolume ResourceType = "volume" ResourceSecret ResourceType = "secret" ResourceConfig ResourceType = "config" ResourceImage ResourceType = "image" )
type Resources ¶
type Resources struct {
CPULimit string `json:"cpu_limit"`
MemoryLimit string `json:"memory_limit"`
CurrentCPU string `json:"current_cpu"`
CurrentMemory string `json:"current_memory"`
}
Resources represents resource usage
type ServiceCurrent ¶
type ServiceCurrent struct {
Version string `json:"version"`
Image string `json:"image"`
DeployedAt time.Time `json:"deployed_at"`
Replicas int `json:"replicas"`
Status string `json:"status"`
}
ServiceCurrent represents current service state
type ServiceDeploy ¶
type ServiceDeploy struct {
Image string `json:"image"`
ImageID string `json:"image_id"`
Replicas int `json:"replicas"`
Ports []int `json:"ports"`
Domains []string `json:"domains"`
Health string `json:"health"`
Containers []ContainerInfo `json:"containers"`
BuildTime int `json:"build_time_seconds,omitempty"`
}
ServiceDeploy represents a service in a deployment
type ServiceHistory ¶
type ServiceHistory struct {
Version string `json:"version"`
DeployedAt time.Time `json:"deployed_at"`
RetiredAt time.Time `json:"retired_at"`
Reason string `json:"reason"`
}
ServiceHistory represents historical service deployments
type ServiceState ¶
type ServiceState struct {
Name string `json:"name"`
Current ServiceCurrent `json:"current"`
History []ServiceHistory `json:"history"`
HealthChecks HealthCheck `json:"health_checks"`
Resources Resources `json:"resources"`
}
ServiceState represents the current state of a service
type StateLock ¶ added in v0.0.3
type StateLock struct {
// contains filtered or unexported fields
}
StateLock manages state file locking to prevent concurrent modifications
func NewStateLock ¶ added in v0.0.3
NewStateLock creates a new state lock manager
func (*StateLock) Acquire ¶ added in v0.0.3
Acquire attempts to acquire the lock for an operation using flock This is atomic and race-condition free. Returns an error if the lock is held.
func (*StateLock) AcquireWithWait ¶ added in v0.0.3
AcquireWithWait attempts to acquire the lock, waiting if necessary
func (*StateLock) ForceRelease ¶ added in v0.0.3
ForceRelease forcefully releases the lock (use with caution)
func (*StateLock) GetLockInfo ¶ added in v0.0.3
GetLockInfo returns information about the current lock holder
type VolumeInfo ¶
type VolumeInfo struct {
Name string `json:"name"`
Driver string `json:"driver"`
MountPoint string `json:"mount_point"`
}
VolumeInfo represents volume configuration