deploy

package
v0.0.0-...-d5053ca Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2026 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Overview

Package deploy provides release management, health checks, and backup/restore. All operations are pure Go.

Index

Constants

View Source
const (
	GitHubRepo          = "E3CNC/E3CNC"
	GitHubAPI           = "https://api.github.com/repos/" + GitHubRepo
	GitHubReleases      = "https://github.com/" + GitHubRepo + "/releases"
	DefaultKeepReleases = 3
	DefaultKeepBackups  = 5
	HealthCheckRetries  = 12
	HealthCheckBackoff  = 10
)

Variables

This section is empty.

Functions

func ActivateRelease

func ActivateRelease(version string) error

ActivateRelease atomically switches the current symlink to a new release.

func Backup

func Backup(inst *instance.Instance) (string, error)

Backup creates a timestamped backup of an instance.

func DownloadArtifact

func DownloadArtifact(asset *GitHubAsset, destDir string) (string, error)

DownloadArtifact downloads a GitHub asset to a local path.

func ExtractArtifact

func ExtractArtifact(artifactPath string, releasesDir string, version string) (string, error)

ExtractArtifact extracts a .tar.zst stack artifact to the releases directory.

func Restore

func Restore(inst *instance.Instance, backupPath string) error

Restore restores an instance from a backup archive.

func VerifyChecksum

func VerifyChecksum(artifactPath string) bool

VerifyChecksum verifies the sha256 checksum of a downloaded artifact.

Types

type GitHubAsset

type GitHubAsset struct {
	Name               string `json:"name"`
	BrowserDownloadURL string `json:"browser_download_url"`
	Size               int    `json:"size"`
}

GitHubAsset represents a release asset from the GitHub API.

func FindStackArtifact

func FindStackArtifact() (*GitHubAsset, error)

FindStackArtifact fetches the latest release and finds the stack artifact.

type HTTPClient

type HTTPClient interface {
	Get(url string) (*http.Response, error)
}

HTTPClient is the interface used by health checks for HTTP requests. The production implementation is http.Client; tests can mock this.

var DefaultHTTPClient HTTPClient = &http.Client{Timeout: 5 * time.Second}

defaultHTTPClient is the production HTTP client used by health checks. Override in tests with deploy.DefaultHTTPClient = mockClient.

type HealthCheck

type HealthCheck struct {
	Name       string `json:"name"`
	Passed     bool   `json:"passed"`
	Detail     string `json:"detail"`
	IsOptional bool   `json:"optional,omitempty"`
}

HealthCheck represents a single health check result.

func RunHealthChecks

func RunHealthChecks(inst *instance.Instance) []HealthCheck

RunHealthChecks performs all 7 health checks against an instance.

type Release

type Release struct {
	Version   string         `json:"version"`
	Path      string         `json:"path"`
	Manifest  map[string]any `json:"manifest,omitempty"`
	SizeBytes int64          `json:"size_bytes"`
	CreatedAt string         `json:"created_at,omitempty"`
}

Release represents a single installed release directory.

func GetCurrentRelease

func GetCurrentRelease() *Release

GetCurrentRelease returns the active release.

func GetReleases

func GetReleases() []Release

GetReleases lists all installed releases.

func ReleaseFromDir

func ReleaseFromDir(path string) Release

ReleaseFromDir creates a Release from a release directory path.

func (Release) IsActive

func (r Release) IsActive() bool

IsActive returns true if this release is the current (active) one.

Jump to

Keyboard shortcuts

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