takodstate

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SchemaVersion = 1
)

Variables

View Source
var ErrNotFound = errors.New("takod state not found")

Functions

func PersistToServers

func PersistToServers(pool *ssh.Pool, cfg *config.Config, environment string, serverNames []string, desired *DesiredRevision, actual *ActualSnapshot, nodeActual map[string]*ActualSnapshot, event Event, verbose bool) error

Types

type ActualNodeSnapshot

type ActualNodeSnapshot struct {
	Node       string                   `json:"node"`
	Services   map[string]ActualService `json:"services"`
	CapturedAt time.Time                `json:"capturedAt"`
}

type ActualService

type ActualService struct {
	Name                  string   `json:"name"`
	Image                 string   `json:"image,omitempty"`
	Replicas              int      `json:"replicas"`
	Containers            []string `json:"containers,omitempty"`
	ConfigHash            string   `json:"configHash,omitempty"`
	RuntimeID             string   `json:"runtimeId,omitempty"`
	HealthyReplicas       int      `json:"healthyReplicas,omitempty"`
	UnhealthyReplicas     int      `json:"unhealthyReplicas,omitempty"`
	StartingReplicas      int      `json:"startingReplicas,omitempty"`
	NoHealthcheckReplicas int      `json:"noHealthcheckReplicas,omitempty"`
	UnknownHealthReplicas int      `json:"unknownHealthReplicas,omitempty"`
}

type ActualSnapshot

type ActualSnapshot struct {
	SchemaVersion int                           `json:"schemaVersion"`
	Project       string                        `json:"project"`
	Environment   string                        `json:"environment"`
	Node          string                        `json:"node,omitempty"`
	TargetNodes   []string                      `json:"targetNodes,omitempty"`
	Services      map[string]ActualService      `json:"services"`
	Nodes         map[string]ActualNodeSnapshot `json:"nodes,omitempty"`
	CapturedAt    time.Time                     `json:"capturedAt"`
}

func BuildActualSnapshot

func BuildActualSnapshot(project string, environment string, targetNodes []string, actual map[string]*reconcile.ActualService) *ActualSnapshot

func BuildActualSnapshotWithNodes

func BuildActualSnapshotWithNodes(project string, environment string, targetNodes []string, actual map[string]*reconcile.ActualService, nodeActual map[string]map[string]*reconcile.ActualService) *ActualSnapshot

func BuildNodeActualSnapshot

func BuildNodeActualSnapshot(project string, environment string, node string, actual map[string]*reconcile.ActualService) *ActualSnapshot

type DesiredConfigFileMount

type DesiredConfigFileMount struct {
	Source      string `json:"source"`
	Target      string `json:"target"`
	Mode        string `json:"mode,omitempty"`
	ContentHash string `json:"contentHash,omitempty"`
}

type DesiredExportRecord

type DesiredExportRecord struct {
	Project     string `json:"project"`
	Environment string `json:"environment"`
	Service     string `json:"service"`
	Port        string `json:"port"`
	Target      int    `json:"target"`
	Protocol    string `json:"protocol,omitempty"`
}

type DesiredImport

type DesiredImport struct {
	Project     string   `json:"project"`
	Environment string   `json:"environment"`
	Service     string   `json:"service"`
	Port        string   `json:"port"`
	Servers     []string `json:"servers,omitempty"`
}

type DesiredRevision

type DesiredRevision struct {
	SchemaVersion int                       `json:"schemaVersion"`
	RevisionID    string                    `json:"revisionId"`
	Project       string                    `json:"project"`
	Environment   string                    `json:"environment"`
	Source        string                    `json:"source"`
	TargetNodes   []string                  `json:"targetNodes"`
	Services      map[string]DesiredService `json:"services"`
	Imports       map[string]DesiredImport  `json:"imports,omitempty"`
	Exports       []DesiredExportRecord     `json:"exports,omitempty"`
	Git           GitInfo                   `json:"git,omitempty"`
	CreatedAt     time.Time                 `json:"createdAt"`
}

func BuildDesiredRevision

func BuildDesiredRevision(cfg *config.Config, environment string, source string, services map[string]config.ServiceConfig, imageRefs map[string]string, targetNodes []string, git GitInfo) (*DesiredRevision, error)

type DesiredService

type DesiredService struct {
	Name           string                      `json:"name"`
	Type           string                      `json:"type"`
	Image          string                      `json:"image,omitempty"`
	Build          string                      `json:"build,omitempty"`
	Dockerfile     string                      `json:"dockerfile,omitempty"`
	Platform       string                      `json:"platform,omitempty"`
	Command        string                      `json:"command,omitempty"`
	Port           int                         `json:"port,omitempty"`
	Ports          []config.PortConfig         `json:"ports,omitempty"`
	Replicas       int                         `json:"replicas"`
	Restart        string                      `json:"restart,omitempty"`
	Persistent     bool                        `json:"persistent,omitempty"`
	Placement      *config.PlacementConfig     `json:"placement,omitempty"`
	Domains        []string                    `json:"domains,omitempty"`
	Volumes        []string                    `json:"volumes,omitempty"`
	Configs        []DesiredConfigFileMount    `json:"configs,omitempty"`
	EnvKeys        []string                    `json:"envKeys,omitempty"`
	EnvFile        bool                        `json:"envFile,omitempty"`
	SecretRefs     []string                    `json:"secretRefs,omitempty"`
	DependsOn      []string                    `json:"dependsOn,omitempty"`
	Export         *config.ServiceExportConfig `json:"export,omitempty"`
	HealthCheck    config.HealthCheckConfig    `json:"healthCheck,omitempty"`
	DeployStrategy string                      `json:"deployStrategy,omitempty"`
	DeployOrder    string                      `json:"deployOrder,omitempty"`
	MaxUnavailable int                         `json:"maxUnavailable,omitempty"`
	DeployMonitor  string                      `json:"deployMonitor,omitempty"`
	Hooks          config.HooksConfig          `json:"hooks,omitempty"`
}

type Event

type Event struct {
	SchemaVersion int               `json:"schemaVersion"`
	Type          string            `json:"type"`
	Project       string            `json:"project"`
	Environment   string            `json:"environment"`
	RevisionID    string            `json:"revisionId,omitempty"`
	Service       string            `json:"service,omitempty"`
	Message       string            `json:"message,omitempty"`
	Details       map[string]string `json:"details,omitempty"`
	Time          time.Time         `json:"time"`
}

func NewEvent

func NewEvent(project string, environment string, eventType string, revisionID string, message string, details map[string]string) Event

type GitInfo

type GitInfo struct {
	Commit      string `json:"commit,omitempty"`
	CommitShort string `json:"commitShort,omitempty"`
	Branch      string `json:"branch,omitempty"`
	Message     string `json:"message,omitempty"`
	Author      string `json:"author,omitempty"`
}

type Manager

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

func NewManager

func NewManager(client *ssh.Client, cfg *config.Config, environment string) *Manager

func (*Manager) AppendEvent

func (m *Manager) AppendEvent(event Event) error

func (*Manager) ReadActual

func (m *Manager) ReadActual() (*ActualSnapshot, error)

func (*Manager) ReadDesired

func (m *Manager) ReadDesired() (*DesiredRevision, error)

func (*Manager) ReadNodeActual

func (m *Manager) ReadNodeActual(node string) (*ActualSnapshot, error)

func (*Manager) WriteActual

func (m *Manager) WriteActual(snapshot *ActualSnapshot) error

func (*Manager) WriteDesired

func (m *Manager) WriteDesired(revision *DesiredRevision) error

func (*Manager) WriteNodeActual

func (m *Manager) WriteNodeActual(node string, snapshot *ActualSnapshot) error

Jump to

Keyboard shortcuts

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