state

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 16, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConfigInfo

type ConfigInfo struct {
	Hash   string `json:"hash"`
	Source string `json:"source"`
}

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"`
	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"` // "swarm" or "single"
	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 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 Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager handles local state persistence in .tako directory

func NewManager

func NewManager(projectPath, projectName, environment string) (*Manager, error)

NewManager creates a new state manager

func (*Manager) CheckBuildCache

func (m *Manager) CheckBuildCache(serviceName string, files map[string]string) (bool, error)

CheckBuildCache checks if rebuild is needed based on file checksums

func (*Manager) Exists

func (m *Manager) Exists() bool

Exists checks if state directory exists

func (*Manager) GetBasePath

func (m *Manager) GetBasePath() string

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) GetServiceState

func (m *Manager) GetServiceState(serviceName string) (*ServiceState, error)

GetServiceState retrieves service state

func (*Manager) LogDeployment

func (m *Manager) LogDeployment(message string) error

LogDeployment logs deployment messages

func (*Manager) LogError

func (m *Manager) LogError(err error) error

LogError logs error messages

func (*Manager) SaveBuildCache

func (m *Manager) SaveBuildCache(serviceName string, files map[string]string) error

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 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 VolumeInfo

type VolumeInfo struct {
	Name       string `json:"name"`
	Driver     string `json:"driver"`
	MountPoint string `json:"mount_point"`
}

VolumeInfo represents volume configuration

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL