state

package
v0.42.0 Latest Latest
Warning

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

Go to latest
Published: May 4, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckpointsDir

func CheckpointsDir() string

CheckpointsDir returns the directory where state checkpoints are stored.

func CleanupShareDir added in v0.38.0

func CleanupShareDir(bundleID string)

CleanupShareDir removes artifacts in the share directory for a specific ID.

func CreateCheckpoint

func CreateCheckpoint(providerName, name string, rt provider.ContainerRuntime) error

CreateCheckpoint snapshots all running devx-managed containers using podman's CRIU integration.

func DecryptFile added in v0.38.0

func DecryptFile(inputPath, outputPath, passphrase string) error

DecryptFile decrypts a file using AES-256-GCM.

func DeleteCheckpoint

func DeleteCheckpoint(name string) error

DeleteCheckpoint completely removes a checkpoint and its archives.

func DownloadFromGCS added in v0.38.0

func DownloadFromGCS(gsURI, outputPath string) error

DownloadFromGCS downloads a file using the Google Cloud CLI.

func DownloadFromS3 added in v0.38.0

func DownloadFromS3(s3URI, outputPath string) error

DownloadFromS3 downloads a file using the AWS CLI.

func EncryptFile added in v0.38.0

func EncryptFile(inputPath, outputPath, passphrase string) error

EncryptFile encrypts a file using AES-256-GCM. The output file format is: [Salt(32 bytes)] + [Nonce(12 bytes)] + [Ciphertext + Tag]

func GenerateJSON

func GenerateJSON(r *DumpReport) string

GenerateJSON stringifies the report.

func GenerateMarkdown

func GenerateMarkdown(r *DumpReport) string

GenerateMarkdown converts the diagnostic dump into a readable markdown string.

func GeneratePassphrase added in v0.38.0

func GeneratePassphrase() string

GeneratePassphrase generates a 4-word mnemonic passphrase from a 2048-word BIP-39 English subset. Each word provides ~11 bits of entropy; 4 words = ~44 bits. Combined with PBKDF2 key stretching (600k iterations), this provides strong protection for ephemeral state bundles.

func ParseRelay added in v0.38.0

func ParseRelay(relayConfig string) (backend string, uri string, err error)

ParseRelay determines the backend type and normalized URI from a config string. Currently supports s3:// and gs:// prefixes. TODO(Idea 56): Implement HTTP relay support (e.g., https://transfer.sh) as a fallback for users without cloud credentials.

func RestoreCheckpoint

func RestoreCheckpoint(providerName, name string, rt provider.ContainerRuntime) error

RestoreCheckpoint restores all containers associated with the named checkpoint. Restores are performed sequentially to avoid port-binding races when CRIU re-binds the original network sockets.

func ShareDir added in v0.38.0

func ShareDir() string

ShareDir returns the base directory for state sharing operations.

func UploadToGCS added in v0.38.0

func UploadToGCS(filePath, gsURI string) error

UploadToGCS uploads a file using the Google Cloud CLI.

func UploadToS3 added in v0.38.0

func UploadToS3(filePath, s3URI string) error

UploadToS3 uploads a file using the AWS CLI.

Types

type BundleManifest added in v0.38.0

type BundleManifest struct {
	ID             string                  `json:"id"`
	Mode           string                  `json:"mode"` // "full" or "db-only"
	CheckpointName string                  `json:"checkpoint_name"`
	Containers     []string                `json:"containers,omitempty"` // Filenames of CRIU archives
	Databases      []database.SnapshotMeta `json:"databases,omitempty"`
	SizeBytes      int64                   `json:"size_bytes"`
}

BundleManifest describes the contents of a state replication bundle.

func UnbundleState added in v0.38.0

func UnbundleState(archivePath, extractDir string) (*BundleManifest, error)

UnbundleState extracts a bundle archive to a temporary directory and parses its manifest.

type BundleResult added in v0.38.0

type BundleResult struct {
	ArchivePath string
	Manifest    BundleManifest
}

BundleResult holds the result of a bundling operation.

func BundleState added in v0.38.0

func BundleState(checkpointName, bundleID string, dbSnapshots []database.SnapshotMeta, fullMode bool) (*BundleResult, error)

BundleState bundles CRIU checkpoints and database snapshots into a single tar.gz archive.

type CheckpointInfo

type CheckpointInfo struct {
	Name           string `json:"name"`
	ContainerCount int    `json:"container_count"`
	SizeBytes      int64  `json:"size_bytes"`
	CreatedAt      string `json:"created_at"`
}

CheckpointInfo holds metadata about a stored checkpoint.

func ListCheckpoints

func ListCheckpoints() ([]CheckpointInfo, error)

ListCheckpoints returns metadata for all existing checkpoints.

type ContainerDiagnostic

type ContainerDiagnostic struct {
	Name  string `json:"name"`
	Image string `json:"image,omitempty"`
	State string `json:"state"`
	Logs  string `json:"logs,omitempty"`
}

type DumpReport

type DumpReport struct {
	DoctorReport *doctor.Report     `json:"doctor_report"`
	VM           VMStatus           `json:"vm_status"`
	Topology     TopologyStatus     `json:"topology"`
	Tunnels      []TunnelDiagnostic `json:"tunnels"`
	Config       RedactedConfig     `json:"redacted_config"`
}

DumpReport represents the full topological and contextual state of the devx environment.

func GenerateDump

func GenerateDump(cfg *config.Config, prov *provider.Provider, vmState string, tsStatus string) (*DumpReport, error)

GenerateDump orchestrates the collection of state for all sub-systems.

type RedactedConfig

type RedactedConfig struct {
	YamlContent string `json:"yaml_content,omitempty"`
	EnvContent  string `json:"env_content,omitempty"`
}

type TopologyStatus

type TopologyStatus struct {
	DevxManagedContainers []ContainerDiagnostic `json:"devx_managed_containers"`
}

type TunnelDiagnostic

type TunnelDiagnostic struct {
	Name   string `json:"name"`
	Domain string `json:"domain"`
}

type VMStatus

type VMStatus struct {
	Name      string `json:"name"`
	Provider  string `json:"provider"`
	State     string `json:"state"`
	Tailscale string `json:"tailscale"`
}

Jump to

Keyboard shortcuts

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