operations

package
v1.0.0-rc07 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: Apache-2.0 Imports: 20 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package operations provides operational components for cluster management, including drift detection, backup management, and disaster recovery.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncryptBackup

func EncryptBackup(backupPath, passphrase string) error

EncryptBackup encrypts a backup with a passphrase

Types

type Backup

type Backup struct {
	ID              string
	Cluster         string
	CreatedAt       time.Time
	CreatedBy       string
	Size            int64
	Compressed      bool
	Encrypted       bool
	EncryptionAlgo  string
	Contents        BackupContents
	Checksum        string
	StorageLocation string
	RetentionUntil  time.Time
}

Backup represents a cluster backup

type BackupContents

type BackupContents struct {
	ConfigFile     []byte
	AgeKeys        []byte // Encrypted
	SSHKeys        []byte // Encrypted
	GitOpsState    []byte
	TerraformState []byte
}

BackupContents represents the contents of a backup

type BackupManager

type BackupManager interface {
	CreateBackup(ctx context.Context, cluster string) (*Backup, error)
	RestoreBackup(ctx context.Context, backupID string, passphrase string) error
	ListBackups(cluster string) ([]*Backup, error)
	DeleteBackup(backupID string) error
	ScheduleBackups(ctx context.Context, cluster string, interval time.Duration, retention time.Duration, onBackup func(*Backup, error)) error
}

BackupManager handles backup and restoration of cluster configurations

func NewBackupManager

func NewBackupManager(pathResolver *paths.PathResolver, backupDir string) (BackupManager, error)

NewBackupManager creates a new backup manager

type BackupMetadata

type BackupMetadata struct {
	ID              string    `json:"id"`
	Cluster         string    `json:"cluster"`
	CreatedAt       time.Time `json:"created_at"`
	CreatedBy       string    `json:"created_by"`
	Size            int64     `json:"size"`
	Compressed      bool      `json:"compressed"`
	Encrypted       bool      `json:"encrypted"`
	EncryptionAlgo  string    `json:"encryption_algo"`
	Contents        []string  `json:"contents"`
	Checksum        string    `json:"checksum"`
	StorageLocation string    `json:"storage_location"`
	RetentionUntil  time.Time `json:"retention_until"`
}

BackupMetadata stores metadata about a backup

type CloudProvider

type CloudProvider interface {
	// GetInstances retrieves all instances for the cluster
	GetInstances(ctx context.Context, cluster string) ([]Instance, error)

	// GetNetworks retrieves all networks for the cluster
	GetNetworks(ctx context.Context, cluster string) ([]Network, error)

	// GetSecurityGroups retrieves all security groups for the cluster
	GetSecurityGroups(ctx context.Context, cluster string) ([]SecurityGroup, error)

	// GetLoadBalancers retrieves all load balancers for the cluster
	GetLoadBalancers(ctx context.Context, cluster string) ([]LoadBalancer, error)
}

CloudProvider defines the interface for cloud provider operations

type ConfigLoader

type ConfigLoader interface {
	LoadConfig(ctx context.Context, cluster string) (*v2.Config, error)
}

ConfigLoader defines the interface for loading cluster configurations

type DriftDetector

type DriftDetector interface {
	// DetectDrift compares desired configuration with actual infrastructure state
	DetectDrift(ctx context.Context, cluster string) (*DriftReport, error)

	// ReconcileDrift corrects detected drift
	ReconcileDrift(ctx context.Context, cluster string, dryRun bool) error

	// SchedulePeriodicCheck schedules periodic drift detection
	SchedulePeriodicCheck(interval time.Duration, callback func(*DriftReport))
}

DriftDetector defines the interface for detecting infrastructure drift

func NewDriftDetector

func NewDriftDetector(configLoader ConfigLoader, provider CloudProvider) DriftDetector

NewDriftDetector creates a new drift detector

type DriftReport

type DriftReport struct {
	ID           string          `json:"id"`
	Cluster      string          `json:"cluster"`
	DetectedAt   time.Time       `json:"detected_at"`
	Drifts       []ResourceDrift `json:"drifts"`
	Severity     Severity        `json:"severity"`
	Reconcilable bool            `json:"reconcilable"`
	Summary      DriftSummary    `json:"summary"`
}

DriftReport represents the result of drift detection

type DriftSummary

type DriftSummary struct {
	TotalDrifts       int `json:"total_drifts"`
	CriticalCount     int `json:"critical_count"`
	WarningCount      int `json:"warning_count"`
	InfoCount         int `json:"info_count"`
	ReconcilableCount int `json:"reconcilable_count"`
}

DriftSummary provides aggregate statistics about drift

type Instance

type Instance struct {
	ID     string            `json:"id"`
	Name   string            `json:"name"`
	Flavor string            `json:"flavor"`
	Image  string            `json:"image"`
	Status string            `json:"status"`
	Tags   map[string]string `json:"tags"`
}

Instance represents a compute instance

type LoadBalancer

type LoadBalancer struct {
	ID       string   `json:"id"`
	Name     string   `json:"name"`
	VIP      string   `json:"vip"`
	Members  []string `json:"members"`
	Protocol string   `json:"protocol"`
}

LoadBalancer represents a load balancer

type Network

type Network struct {
	ID      string   `json:"id"`
	Name    string   `json:"name"`
	CIDR    string   `json:"cidr"`
	Subnets []string `json:"subnets"`
}

Network represents a network resource

type ResourceDrift

type ResourceDrift struct {
	ResourceType string      `json:"resource_type"`
	ResourceID   string      `json:"resource_id"`
	ResourceName string      `json:"resource_name"`
	Field        string      `json:"field"`
	Expected     interface{} `json:"expected"`
	Actual       interface{} `json:"actual"`
	Severity     Severity    `json:"severity"`
	Reconcilable bool        `json:"reconcilable"`
}

ResourceDrift represents a single resource drift

type SecurityGroup

type SecurityGroup struct {
	ID    string         `json:"id"`
	Name  string         `json:"name"`
	Rules []SecurityRule `json:"rules"`
}

SecurityGroup represents a security group

type SecurityRule

type SecurityRule struct {
	Direction   string `json:"direction"`
	Protocol    string `json:"protocol"`
	PortRange   string `json:"port_range"`
	RemoteIP    string `json:"remote_ip"`
	Description string `json:"description"`
}

SecurityRule represents a security group rule

type Severity

type Severity int

Severity represents the severity level of drift

const (
	// SeverityInfo represents informational drift (metadata, timestamps)
	SeverityInfo Severity = iota
	// SeverityWarning represents warning-level drift (worker nodes, tags, labels)
	SeverityWarning
	// SeverityCritical represents critical drift (control plane, network configuration)
	SeverityCritical
)

func (Severity) String

func (s Severity) String() string

String returns the string representation of severity

Jump to

Keyboard shortcuts

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