Dev env setup.

This commit is contained in:
2025-10-11 21:40:45 +00:00
parent b76d2fb164
commit 92032202f4
13 changed files with 186 additions and 47 deletions

View File

@@ -485,7 +485,7 @@ func (m *Manager) GetStatus(instanceName, appName string) (*DeployedApp, error)
var podList struct {
Items []struct {
Status struct {
Phase string `json:"phase"`
Phase string `json:"phase"`
ContainerStatuses []struct {
Ready bool `json:"ready"`
} `json:"containerStatuses"`

View File

@@ -28,10 +28,10 @@ type BackupInfo struct {
// RestoreOptions configures restore behavior
type RestoreOptions struct {
DBOnly bool `json:"db_only"`
PVCOnly bool `json:"pvc_only"`
SkipGlobals bool `json:"skip_globals"`
SnapshotID string `json:"snapshot_id,omitempty"`
DBOnly bool `json:"db_only"`
PVCOnly bool `json:"pvc_only"`
SkipGlobals bool `json:"skip_globals"`
SnapshotID string `json:"snapshot_id,omitempty"`
}
// Manager handles backup and restore operations

View File

@@ -15,9 +15,9 @@ import (
// Manager handles node discovery operations
type Manager struct {
dataDir string
nodeMgr *node.Manager
talosctl *tools.Talosctl
dataDir string
nodeMgr *node.Manager
talosctl *tools.Talosctl
discoveryMu sync.Mutex
}
@@ -35,20 +35,20 @@ func NewManager(dataDir string, instanceName string) *Manager {
// DiscoveredNode represents a discovered node on the network
type DiscoveredNode struct {
IP string `json:"ip"`
Hostname string `json:"hostname,omitempty"`
MaintenanceMode bool `json:"maintenance_mode"`
Version string `json:"version,omitempty"`
Interface string `json:"interface,omitempty"`
IP string `json:"ip"`
Hostname string `json:"hostname,omitempty"`
MaintenanceMode bool `json:"maintenance_mode"`
Version string `json:"version,omitempty"`
Interface string `json:"interface,omitempty"`
Disks []string `json:"disks,omitempty"`
}
// DiscoveryStatus represents the current state of discovery
type DiscoveryStatus struct {
Active bool `json:"active"`
StartedAt time.Time `json:"started_at,omitempty"`
NodesFound []DiscoveredNode `json:"nodes_found"`
Error string `json:"error,omitempty"`
Active bool `json:"active"`
StartedAt time.Time `json:"started_at,omitempty"`
NodesFound []DiscoveredNode `json:"nodes_found"`
Error string `json:"error,omitempty"`
}
// GetDiscoveryDir returns the discovery directory for an instance

View File

@@ -13,27 +13,27 @@ import (
// Manager handles instance lifecycle operations
type Manager struct {
dataDir string
configMgr *config.Manager
secretsMgr *secrets.Manager
contextMgr *context.Manager
dataDir string
configMgr *config.Manager
secretsMgr *secrets.Manager
contextMgr *context.Manager
}
// NewManager creates a new instance manager
func NewManager(dataDir string) *Manager {
return &Manager{
dataDir: dataDir,
configMgr: config.NewManager(),
secretsMgr: secrets.NewManager(),
contextMgr: context.NewManager(dataDir),
dataDir: dataDir,
configMgr: config.NewManager(),
secretsMgr: secrets.NewManager(),
contextMgr: context.NewManager(dataDir),
}
}
// Instance represents a Wild Cloud instance
type Instance struct {
Name string
Path string
ConfigPath string
Name string
Path string
ConfigPath string
SecretsPath string
}

View File

@@ -13,9 +13,9 @@ import (
// Manager handles node configuration and state management
type Manager struct {
dataDir string
configMgr *config.Manager
talosctl *tools.Talosctl
dataDir string
configMgr *config.Manager
talosctl *tools.Talosctl
}
// NewManager creates a new node manager
@@ -407,8 +407,8 @@ func (m *Manager) Apply(instanceName, nodeIdentifier string, opts ApplyOptions)
// Post-application updates: move to production IP, exit maintenance mode
node.Applied = true
node.CurrentIP = node.TargetIP // Node now on production IP
node.Maintenance = false // Exit maintenance mode
node.CurrentIP = node.TargetIP // Node now on production IP
node.Maintenance = false // Exit maintenance mode
if err := m.updateNodeStatus(instanceName, node); err != nil {
return fmt.Errorf("failed to update node status: %w", err)
}

View File

@@ -30,7 +30,7 @@ type Operation struct {
Instance string `json:"instance"`
Status string `json:"status"` // pending, running, completed, failed, cancelled
Message string `json:"message,omitempty"`
Progress int `json:"progress"` // 0-100
Progress int `json:"progress"` // 0-100
LogFile string `json:"logFile,omitempty"` // Path to output log file
StartedAt time.Time `json:"started_at"`
EndedAt time.Time `json:"ended_at,omitempty"`

View File

@@ -95,6 +95,11 @@ func (m *Manager) GetSecret(secretsPath, key string) (string, error) {
return "", fmt.Errorf("getting secret %s: %w", key, err)
}
// yq returns "null" for non-existent keys
if value == "" || value == "null" {
return "", fmt.Errorf("secret not found: %s", key)
}
return value, nil
}

View File

@@ -24,9 +24,9 @@ type ServiceManifest struct {
// ConfigDefinition defines config that should be prompted during service setup
type ConfigDefinition struct {
Path string `yaml:"path" json:"path"` // Config path to set
Prompt string `yaml:"prompt" json:"prompt"` // User prompt text
Default string `yaml:"default" json:"default"` // Default value (supports templates)
Path string `yaml:"path" json:"path"` // Config path to set
Prompt string `yaml:"prompt" json:"prompt"` // User prompt text
Default string `yaml:"default" json:"default"` // Default value (supports templates)
Type string `yaml:"type,omitempty" json:"type,omitempty"` // Value type: string|int|bool (default: string)
}

View File

@@ -42,11 +42,11 @@ func NewManager(dataDir, servicesDir string) *Manager {
// Service represents a base service
type Service struct {
Name string `json:"name"`
Description string `json:"description"`
Status string `json:"status"`
Version string `json:"version"`
Namespace string `json:"namespace"`
Name string `json:"name"`
Description string `json:"description"`
Status string `json:"status"`
Version string `json:"version"`
Namespace string `json:"namespace"`
Dependencies []string `json:"dependencies,omitempty"`
}
@@ -557,8 +557,8 @@ func (m *Manager) Deploy(instanceName, serviceName, opID string, broadcaster *op
err := cmd.Run()
fmt.Printf("[DEBUG] Command completed for opID=%s, err=%v\n", opID, err)
if broadcaster != nil {
outputWriter.Flush() // Flush any remaining buffered data
broadcaster.Close(opID) // Close all SSE clients
outputWriter.Flush() // Flush any remaining buffered data
broadcaster.Close(opID) // Close all SSE clients
}
return err
} else {

View File

@@ -11,9 +11,9 @@ import (
// HealthStatus represents cluster health information
type HealthStatus struct {
Overall string `json:"overall"` // healthy, degraded, unhealthy
Overall string `json:"overall"` // healthy, degraded, unhealthy
Components map[string]string `json:"components"` // component -> status
Issues []string `json:"issues"`
Issues []string `json:"issues"`
}
// DashboardToken represents a Kubernetes dashboard token
@@ -96,7 +96,7 @@ func checkComponent(kubeconfigPath, name, namespace, selector string) error {
var result struct {
Items []struct {
Status struct {
Phase string `json:"phase"`
Phase string `json:"phase"`
ContainerStatuses []struct {
Ready bool `json:"ready"`
} `json:"containerStatuses"`