cloud

package
v5.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2026 License: MIT Imports: 46 Imported by: 0

README

Cloud Infrastructure Feature - Implementation Summary

Overview

This implementation provides the foundation for automated cloud infrastructure provisioning using Pulumi's Go SDK, enabling users to spin up ephemeral worker nodes across multiple cloud providers for distributed scanning.

What Was Implemented

✅ Phase 1: Foundation (COMPLETED)
1. Package Structure

Created /internal/cloud/ with the following files:

  • config.go - Cloud config loading, validation, and environment variable resolution
  • provider.go - Provider interface and type definitions
  • pulumi.go - Pulumi Automation API wrapper
  • lifecycle.go - Orchestration logic (create → run → collect → destroy)
  • cost.go - Cost tracking and limit enforcement
  • state.go - Infrastructure state persistence (JSON format)
  • worker.go - Worker registration waiting and filtering
  • registry.go - Provider factory and registration
  • digitalocean.go - DigitalOcean provider implementation (foundation)
2. Configuration System
  • Extended /internal/config/config.go:

    • Added CloudConfig struct to main Config
    • Added cloud section to embedded YAML template
  • Created /internal/config/cloud_config.go:

    • CloudConfigs struct matching YAML schema
    • Provider configs (AWS, GCP, DigitalOcean, Linode, Azure)
    • Defaults, Limits, State, SSH, Setup sections
    • DefaultCloudConfigs() factory function
  • Environment Variable Resolution:

    • Supports ${VAR_NAME} syntax in config values
    • Automatically expands on load
3. CLI Commands

Created /pkg/cli/cloud.go with full command tree:

osmedeus cloud
├── config
│   ├── set <key> <value>     # Update cloud-settings.yaml
│   └── show                   # Display current config
├── create                     # Provision infrastructure
├── list                       # List active resources
├── destroy [id]              # Teardown infrastructure
└── run                        # Create + run workflow + destroy

Flags:

  • --provider - Override default provider
  • --mode - vm or serverless
  • --instances - Number of instances
  • --force - Force rebuild

Registered in /pkg/cli/root.go (line 309)

4. Dependencies

Added to go.mod:

  • github.com/pulumi/pulumi/sdk/v3 (v3.220.0)
  • github.com/pulumi/pulumi-digitalocean/sdk/v4 (v4.57.0)
  • github.com/digitalocean/godo (v1.175.0)
5. Core Abstractions

Provider Interface:

type Provider interface {
    Validate(ctx) error
    EstimateCost(mode, count) (*CostEstimate, error)
    CreateInfrastructure(ctx, opts) (*Infrastructure, error)
    DestroyInfrastructure(ctx, infra) error
    GetStatus(ctx, infra) (*InfraStatus, error)
    Type() ProviderType
}

Key Types:

  • ProviderType: aws, gcp, digitalocean, linode, azure
  • ExecutionMode: vm (Phase 1), serverless (Phase 2)
  • Infrastructure: Resources, Pulumi stack ID, metadata
  • Resource: VM/function details, IPs, worker ID, status
  • CostEstimate: Hourly/daily rates, breakdown, notes

LifecycleManager:

  • Cost validation before provisioning
  • Worker registration waiting (polls every 5s)
  • Graceful shutdown on SIGINT/SIGTERM
  • Cleanup on failure (configurable)

CostTracker:

  • Real-time cost calculation based on elapsed time
  • Limit enforcement (max_hourly_spend, max_total_spend)
  • Summary formatting for display

State Management:

  • JSON persistence in {{base_folder}}/cloud-state/infrastructure/
  • SaveInfrastructureState() / LoadInfrastructureState()
  • ListInfrastructures() for cloud list command
  • Recovery from interruptions

Worker Integration:

  • WaitForWorkers() polls distributed.Client.GetAllWorkers()
  • Filters by wosm- or cloud- prefix
  • Timeout handling (default 5min)
  • Status callback support
6. DigitalOcean Provider (Foundation)
  • Provider struct: Token, region, size, snapshot, SSH keys, godo client
  • Validation: Tests API access via account info
  • Cost estimation: Pricing map for common droplet sizes
  • Cloud-init script: Installs osmedeus, sets up SSH, joins as worker
  • Pulumi integration: Placeholder for digitalocean.Droplet resources

What's NOT Yet Implemented

⏳ Phase 2: Completion Tasks
  1. DigitalOcean Droplet Creation

    • Complete createDropletProgram() with actual Pulumi resources
    • SSH key creation/upload
    • Firewall rules
    • Output extraction (IPs, droplet IDs)
    • Status monitoring
  2. Result Collection

    • SSH rsync integration from internal/runner
    • Workspace aggregation on master
    • Optional database import via db_import_* functions
  3. Cloud Run Workflow

    • Full lifecycle: create → wait → submit tasks → monitor → collect → destroy
    • Distributed task submission via distributed.Master
    • Progress UI via terminal.Printer
    • Cost monitoring ticker
  4. Error Handling

    • Robust retry logic
    • Partial failure handling
    • Resource leak prevention
    • Better error messages
  5. Additional Providers

    • AWS EC2 implementation
    • GCP Compute Engine implementation
    • Linode implementation
    • Azure implementation
  6. Image Building

    • cloud build command to create provider images/snapshots
    • Packer integration or provider-native tools
    • Pre-baked osmedeus images for faster boot
  7. Testing

    • Unit tests for config, cost, state
    • Integration tests (requires cloud credentials)
    • End-to-end test script
    • Cost limit validation tests
  8. Documentation

    • Usage examples in CLAUDE.md
    • API documentation
    • Troubleshooting guide

Testing the Current Implementation

Build Test
make fmt && make build
# ✅ Compiles successfully (152MB binary)
CLI Test
./bin/osmedeus cloud --help
# ✅ Shows cloud command help

./bin/osmedeus cloud config --help
# ✅ Shows config subcommands

./bin/osmedeus cloud create --help
# ✅ Shows create flags
Config Test
# Set a config value
osmedeus cloud config set defaults.provider digitalocean
osmedeus cloud config set providers.digitalocean.token ${DIGITALOCEAN_TOKEN}

# Show current config
osmedeus cloud config show

Architecture Decisions

  1. Local Pulumi State: No Pulumi Cloud account required, state stored in {{base_folder}}/cloud-state/
  2. Provider in Same Package: Moved from cloud/providers/ to cloud/ to avoid import cycles
  3. Worker Auto-Registration: Leverages existing distributed.Worker system, no custom registration needed
  4. State Persistence: JSON format for easy inspection and debugging
  5. Cost Tracking: Proactive limits prevent accidental overspending
  6. Graceful Shutdown: Signal handlers ensure cleanup even on interruption

Next Steps for Full Implementation

Priority 1: Complete DigitalOcean Provider
  1. Implement full Pulumi program in createDropletProgram()
  2. Add SSH key management
  3. Extract outputs (IPs, IDs) from Pulumi stack
  4. Test single-instance creation end-to-end
Priority 2: Implement Cloud Run Workflow
  1. Add distributed task submission logic
  2. Integrate cost monitoring ticker
  3. Add confirmation prompts
  4. Test full lifecycle with simple workflow
Priority 3: Result Collection
  1. Integrate SSH runner's CopyFromRemote()
  2. Aggregate results to master workspace
  3. Optional: Auto-import to master database
Priority 4: Error Handling & Polish
  1. Add retry logic for API failures
  2. Better error messages
  3. Progress indicators
  4. Confirmation prompts

Files Modified

Created
  • /internal/cloud/*.go (9 files)
  • /internal/config/cloud_config.go
  • /pkg/cli/cloud.go
  • /internal/cloud/README.md (this file)
Modified
  • /internal/config/config.go (added CloudConfig struct + YAML template)
  • /pkg/cli/root.go (registered cloudCmd)
  • go.mod (added Pulumi + DigitalOcean dependencies)

Summary

The cloud infrastructure feature foundation is complete and compiles successfully. The architecture is sound, the CLI is functional, and the abstractions are clean. The remaining work is primarily:

  1. Completing the DigitalOcean Pulumi program
  2. Implementing the cloud run workflow orchestration
  3. Adding result collection via SSH
  4. Testing end-to-end with real cloud resources

The implementation follows Osmedeus patterns (Cobra CLI, YAML config, terminal printer) and integrates seamlessly with the existing distributed system.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExpandPath added in v5.0.2

func ExpandPath(path string) string

ExpandPath expands ~ to the user's home directory

func GenerateCloudInit added in v5.0.2

func GenerateCloudInit(redisURL, sshPublicKey string, setupCommands []string) string

GenerateCloudInit generates the cloud-init user data script for worker VMs. The script installs osmedeus, sets up SSH access, and joins the worker to the master.

func InfrastructureExists

func InfrastructureExists(infraID, statePath string) bool

InfrastructureExists checks if an infrastructure state exists

func LoadCloudConfig

func LoadCloudConfig(configPath string) (*config.CloudConfigs, error)

LoadCloudConfig loads and parses the cloud configuration from the specified path

func RemoveInfrastructureState

func RemoveInfrastructureState(infraID, statePath string) error

RemoveInfrastructureState removes infrastructure state from disk

func ResolveTemplatePaths added in v5.0.2

func ResolveTemplatePaths(cfg *config.CloudConfigs, baseFolder string)

ResolveTemplatePaths expands {{base_folder}} in path fields of the cloud config. Call this after LoadCloudConfig with the actual base folder path.

func SaveCloudConfig

func SaveCloudConfig(cfg *config.CloudConfigs, configPath string) error

SaveCloudConfig saves the cloud configuration to the specified path

func SaveInfrastructureState

func SaveInfrastructureState(infra *Infrastructure, statePath string) error

SaveInfrastructureState persists infrastructure state to disk

func ValidateCloudConfig

func ValidateCloudConfig(cfg *config.CloudConfigs) error

ValidateCloudConfig validates the cloud configuration

func WaitForWorkers

func WaitForWorkers(ctx context.Context, client *distributed.Client, expectedCount int, timeout time.Duration) ([]string, error)

WaitForWorkers waits for the expected number of workers to register

func WaitForWorkersWithStatus

func WaitForWorkersWithStatus(ctx context.Context, client *distributed.Client, expectedCount int, timeout time.Duration, statusCallback func(current, expected int)) ([]string, error)

WaitForWorkersWithStatus waits for workers and reports detailed status

Types

type AWSProvider added in v5.0.2

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

AWSProvider implements the Provider interface for AWS

func NewAWSProvider added in v5.0.2

func NewAWSProvider(accessKeyID, secretAccessKey, region, instanceType, ami, amiFilter string, useSpot bool) (*AWSProvider, error)

NewAWSProvider creates a new AWS provider

func (*AWSProvider) CreateInfrastructure added in v5.0.2

func (p *AWSProvider) CreateInfrastructure(ctx context.Context, opts *CreateOptions) (*Infrastructure, error)

CreateInfrastructure provisions AWS EC2 instances

func (*AWSProvider) DestroyInfrastructure added in v5.0.2

func (p *AWSProvider) DestroyInfrastructure(ctx context.Context, infra *Infrastructure) error

DestroyInfrastructure tears down AWS resources

func (*AWSProvider) EstimateCost added in v5.0.2

func (p *AWSProvider) EstimateCost(mode ExecutionMode, instanceCount int) (*CostEstimate, error)

EstimateCost estimates the cost for the given configuration

func (*AWSProvider) GetStatus added in v5.0.2

func (p *AWSProvider) GetStatus(ctx context.Context, infra *Infrastructure) (*InfraStatus, error)

GetStatus retrieves the current status of infrastructure

func (*AWSProvider) Type added in v5.0.2

func (p *AWSProvider) Type() ProviderType

Type returns the provider type

func (*AWSProvider) Validate added in v5.0.2

func (p *AWSProvider) Validate(ctx context.Context) error

Validate checks if the provider configuration is valid

type AzureProvider added in v5.0.2

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

AzureProvider implements the Provider interface for Azure

func NewAzureProvider added in v5.0.2

func NewAzureProvider(subscriptionID, tenantID, clientID, clientSecret, location, vmSize, imageReference string) (*AzureProvider, error)

NewAzureProvider creates a new Azure provider

func (*AzureProvider) CreateInfrastructure added in v5.0.2

func (p *AzureProvider) CreateInfrastructure(ctx context.Context, opts *CreateOptions) (*Infrastructure, error)

CreateInfrastructure provisions Azure VMs

func (*AzureProvider) DestroyInfrastructure added in v5.0.2

func (p *AzureProvider) DestroyInfrastructure(ctx context.Context, infra *Infrastructure) error

DestroyInfrastructure tears down Azure resources

func (*AzureProvider) EstimateCost added in v5.0.2

func (p *AzureProvider) EstimateCost(mode ExecutionMode, instanceCount int) (*CostEstimate, error)

EstimateCost estimates the cost for the given configuration

func (*AzureProvider) GetStatus added in v5.0.2

func (p *AzureProvider) GetStatus(ctx context.Context, infra *Infrastructure) (*InfraStatus, error)

GetStatus retrieves the current status of infrastructure

func (*AzureProvider) Type added in v5.0.2

func (p *AzureProvider) Type() ProviderType

Type returns the provider type

func (*AzureProvider) Validate added in v5.0.2

func (p *AzureProvider) Validate(ctx context.Context) error

Validate checks if the provider configuration is valid

type CloudSSHClient added in v5.0.2

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

CloudSSHClient wraps a pooled SSH connection for cloud operations. It provides command execution (blocking and streaming) plus SFTP file transfers.

func NewCloudSSHClient added in v5.0.2

func NewCloudSSHClient(ctx context.Context, cfg SSHConfig) (*CloudSSHClient, error)

NewCloudSSHClient creates a new SSH client using the global connection pool.

func (*CloudSSHClient) Close added in v5.0.2

func (c *CloudSSHClient) Close()

Close releases the connection back to the pool.

func (*CloudSSHClient) DownloadDir added in v5.0.2

func (c *CloudSSHClient) DownloadDir(remotePath, localPath string) error

DownloadDir recursively downloads a remote directory to local via SFTP.

func (*CloudSSHClient) DownloadFile added in v5.0.2

func (c *CloudSSHClient) DownloadFile(remotePath, localPath string) error

DownloadFile copies a remote file to the local filesystem via SFTP.

func (*CloudSSHClient) RunCommand added in v5.0.2

func (c *CloudSSHClient) RunCommand(ctx context.Context, command string) (string, int, error)

RunCommand executes a command on the remote host and returns the output.

func (*CloudSSHClient) RunCommandStreaming added in v5.0.2

func (c *CloudSSHClient) RunCommandStreaming(ctx context.Context, command string, prefix string) error

RunCommandStreaming executes a command, streaming stdout/stderr line-by-line with a prefix. Blocks until the command completes.

func (*CloudSSHClient) RunCommandStreamingWithCallback added in v5.0.2

func (c *CloudSSHClient) RunCommandStreamingWithCallback(ctx context.Context, command string, prefix string, onLine LineCallback) error

RunCommandStreamingWithCallback is like RunCommandStreaming but calls onLine for each ANSI-stripped output line, allowing the caller to observe progress without parsing stdout.

func (*CloudSSHClient) UploadFile added in v5.0.2

func (c *CloudSSHClient) UploadFile(localPath, remotePath string) error

UploadFile copies a local file to the remote host via SFTP.

type CostEstimate

type CostEstimate struct {
	// HourlyCost is the estimated hourly cost
	HourlyCost float64

	// DailyCost is the estimated daily cost
	DailyCost float64

	// Currency is the currency code (default: USD)
	Currency string

	// Breakdown provides cost breakdown by resource type
	Breakdown map[string]float64

	// Notes contains additional cost information
	Notes []string
}

CostEstimate represents estimated costs

type CostTracker

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

CostTracker tracks ongoing infrastructure costs

func NewCostTracker

func NewCostTracker(hourlyRate, maxTotalSpend float64) *CostTracker

NewCostTracker creates a new cost tracker

func (*CostTracker) CheckLimits

func (ct *CostTracker) CheckLimits() error

CheckLimits validates that current cost is within limits

func (*CostTracker) GetCostSummary

func (ct *CostTracker) GetCostSummary() string

GetCostSummary returns a formatted cost summary

func (*CostTracker) GetCurrentCost

func (ct *CostTracker) GetCurrentCost() float64

GetCurrentCost returns the current accumulated cost

func (*CostTracker) GetElapsedTime

func (ct *CostTracker) GetElapsedTime() time.Duration

GetElapsedTime returns the elapsed time since tracking started

func (*CostTracker) GetEstimatedFinalCost

func (ct *CostTracker) GetEstimatedFinalCost(duration time.Duration) float64

GetEstimatedFinalCost estimates final cost for a given duration

func (*CostTracker) UpdateCost

func (ct *CostTracker) UpdateCost() float64

UpdateCost calculates the current cost based on elapsed time

type CreateOptions

type CreateOptions struct {
	// Mode is the execution mode (vm or serverless)
	Mode ExecutionMode

	// InstanceCount is the number of instances to create
	InstanceCount int

	// InstanceType is the instance size/type (e.g., "s-2vcpu-4gb" for DigitalOcean)
	InstanceType string

	// UseSpot indicates whether to use spot/preemptible instances
	UseSpot bool

	// ImageID is the cloud image/snapshot to use
	ImageID string

	// RedisURL is the master Redis URL for worker registration
	RedisURL string

	// SSHPublicKey is the SSH public key for authentication
	SSHPublicKey string

	// SSHPrivateKey is the SSH private key for result collection
	SSHPrivateKey string

	// SSHUser is the SSH username
	SSHUser string

	// SetupCommands are additional commands to run on boot
	SetupCommands []string

	// Tags are resource tags/labels
	Tags map[string]string

	// Timeout is the maximum time to wait for infrastructure creation
	Timeout time.Duration

	// StatePath is the resolved path for Pulumi state storage.
	// Set by LifecycleManager from the cloud config's State.Path.
	StatePath string
}

CreateOptions contains options for creating infrastructure

type DigitalOceanProvider

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

DigitalOceanProvider implements the Provider interface for DigitalOcean

func NewDigitalOceanProvider

func NewDigitalOceanProvider(token, region, size, snapshotID, sshKeyFingerprint string) (*DigitalOceanProvider, error)

NewDigitalOceanProvider creates a new DigitalOcean provider

func (*DigitalOceanProvider) CreateInfrastructure

func (p *DigitalOceanProvider) CreateInfrastructure(ctx context.Context, opts *CreateOptions) (*Infrastructure, error)

CreateInfrastructure provisions DigitalOcean droplets

func (*DigitalOceanProvider) DestroyInfrastructure

func (p *DigitalOceanProvider) DestroyInfrastructure(ctx context.Context, infra *Infrastructure) error

DestroyInfrastructure tears down DigitalOcean resources

func (*DigitalOceanProvider) EstimateCost

func (p *DigitalOceanProvider) EstimateCost(mode ExecutionMode, instanceCount int) (*CostEstimate, error)

EstimateCost estimates the cost for the given configuration

func (*DigitalOceanProvider) GetStatus

func (p *DigitalOceanProvider) GetStatus(ctx context.Context, infra *Infrastructure) (*InfraStatus, error)

GetStatus retrieves the current status of infrastructure

func (*DigitalOceanProvider) Type

Type returns the provider type

func (*DigitalOceanProvider) Validate

func (p *DigitalOceanProvider) Validate(ctx context.Context) error

Validate checks if the provider configuration is valid

type ExecutionMode

type ExecutionMode string

ExecutionMode represents the execution mode (VM or serverless)

const (
	ModeVM         ExecutionMode = "vm"
	ModeServerless ExecutionMode = "serverless"
)

type GCPProvider added in v5.0.2

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

GCPProvider implements the Provider interface for Google Cloud Platform

func NewGCPProvider added in v5.0.2

func NewGCPProvider(projectID, credentialsFile, region, zone, machineType, imageFamily string, usePreemptible bool) (*GCPProvider, error)

NewGCPProvider creates a new GCP provider

func (*GCPProvider) CreateInfrastructure added in v5.0.2

func (p *GCPProvider) CreateInfrastructure(ctx context.Context, opts *CreateOptions) (*Infrastructure, error)

CreateInfrastructure provisions GCP compute instances

func (*GCPProvider) DestroyInfrastructure added in v5.0.2

func (p *GCPProvider) DestroyInfrastructure(ctx context.Context, infra *Infrastructure) error

DestroyInfrastructure tears down GCP resources

func (*GCPProvider) EstimateCost added in v5.0.2

func (p *GCPProvider) EstimateCost(mode ExecutionMode, instanceCount int) (*CostEstimate, error)

EstimateCost estimates the cost for the given configuration

func (*GCPProvider) GetStatus added in v5.0.2

func (p *GCPProvider) GetStatus(ctx context.Context, infra *Infrastructure) (*InfraStatus, error)

GetStatus retrieves the current status of infrastructure

func (*GCPProvider) Type added in v5.0.2

func (p *GCPProvider) Type() ProviderType

Type returns the provider type

func (*GCPProvider) Validate added in v5.0.2

func (p *GCPProvider) Validate(ctx context.Context) error

Validate checks if the provider configuration is valid

type HetznerProvider added in v5.0.2

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

HetznerProvider implements the Provider interface for Hetzner Cloud

func NewHetznerProvider added in v5.0.2

func NewHetznerProvider(token, location, serverType, image, sshKeyName string) (*HetznerProvider, error)

NewHetznerProvider creates a new Hetzner Cloud provider

func (*HetznerProvider) CreateInfrastructure added in v5.0.2

func (p *HetznerProvider) CreateInfrastructure(ctx context.Context, opts *CreateOptions) (*Infrastructure, error)

CreateInfrastructure provisions Hetzner Cloud servers

func (*HetznerProvider) DestroyInfrastructure added in v5.0.2

func (p *HetznerProvider) DestroyInfrastructure(ctx context.Context, infra *Infrastructure) error

DestroyInfrastructure tears down Hetzner Cloud resources

func (*HetznerProvider) EstimateCost added in v5.0.2

func (p *HetznerProvider) EstimateCost(mode ExecutionMode, instanceCount int) (*CostEstimate, error)

EstimateCost estimates the cost for the given configuration

func (*HetznerProvider) GetStatus added in v5.0.2

func (p *HetznerProvider) GetStatus(ctx context.Context, infra *Infrastructure) (*InfraStatus, error)

GetStatus retrieves the current status of infrastructure

func (*HetznerProvider) Type added in v5.0.2

func (p *HetznerProvider) Type() ProviderType

Type returns the provider type

func (*HetznerProvider) Validate added in v5.0.2

func (p *HetznerProvider) Validate(ctx context.Context) error

Validate checks if the provider configuration is valid

type InfraStatus

type InfraStatus struct {
	// Status is the overall status (running, stopped, error, etc.)
	Status string

	// ReadyCount is the number of ready resources
	ReadyCount int

	// TotalCount is the total number of resources
	TotalCount int

	// WorkersRegistered is the number of workers that have registered
	WorkersRegistered int

	// Details contains status details for each resource
	Details []ResourceStatus
}

InfraStatus represents the status of infrastructure

type Infrastructure

type Infrastructure struct {
	// ID is a unique identifier for this infrastructure
	ID string

	// Provider is the cloud provider type
	Provider ProviderType

	// Mode is the execution mode
	Mode ExecutionMode

	// CreatedAt is when the infrastructure was created
	CreatedAt time.Time

	// PulumiStackID is the Pulumi stack identifier
	PulumiStackID string

	// StatePath is the resolved Pulumi state directory used during creation.
	// Persisted so that Destroy can locate the correct state.
	StatePath string `json:"state_path,omitempty"`

	// Resources are the created resources (VMs, functions, etc.)
	Resources []Resource

	// Metadata contains additional provider-specific data
	Metadata map[string]interface{}
}

Infrastructure represents created cloud infrastructure

func ListInfrastructures

func ListInfrastructures(statePath string) ([]*Infrastructure, error)

ListInfrastructures lists all saved infrastructure states

func LoadInfrastructureState

func LoadInfrastructureState(infraID, statePath string) (*Infrastructure, error)

LoadInfrastructureState loads infrastructure state from disk

type LifecycleManager

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

LifecycleManager orchestrates the complete lifecycle of cloud infrastructure

func NewLifecycleManager

func NewLifecycleManager(cfg *config.CloudConfigs, provider Provider, client *distributed.Client) *LifecycleManager

NewLifecycleManager creates a new lifecycle manager

func (*LifecycleManager) CreateAndRun

func (lm *LifecycleManager) CreateAndRun(ctx context.Context, opts *CreateOptions) (*Infrastructure, error)

CreateAndRun provisions infrastructure, waits for workers, runs workflow, and cleans up

func (*LifecycleManager) Destroy

func (lm *LifecycleManager) Destroy(ctx context.Context, infra *Infrastructure) error

Destroy tears down infrastructure

func (*LifecycleManager) GetStatus

func (lm *LifecycleManager) GetStatus(ctx context.Context, infra *Infrastructure) (*InfraStatus, error)

GetStatus retrieves infrastructure status

func (*LifecycleManager) MonitorCost

func (lm *LifecycleManager) MonitorCost(ctx context.Context, interval time.Duration) error

MonitorCost monitors ongoing costs during execution

type LineCallback added in v5.0.2

type LineCallback func(line string)

LineCallback is called for each ANSI-stripped output line during streaming.

type LinodeProvider added in v5.0.2

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

LinodeProvider implements the Provider interface for Linode

func NewLinodeProvider added in v5.0.2

func NewLinodeProvider(token, region, linodeType, image string) (*LinodeProvider, error)

NewLinodeProvider creates a new Linode provider

func (*LinodeProvider) CreateInfrastructure added in v5.0.2

func (p *LinodeProvider) CreateInfrastructure(ctx context.Context, opts *CreateOptions) (*Infrastructure, error)

CreateInfrastructure provisions Linode instances

func (*LinodeProvider) DestroyInfrastructure added in v5.0.2

func (p *LinodeProvider) DestroyInfrastructure(ctx context.Context, infra *Infrastructure) error

DestroyInfrastructure tears down Linode resources

func (*LinodeProvider) EstimateCost added in v5.0.2

func (p *LinodeProvider) EstimateCost(mode ExecutionMode, instanceCount int) (*CostEstimate, error)

EstimateCost estimates the cost for the given configuration

func (*LinodeProvider) GetStatus added in v5.0.2

func (p *LinodeProvider) GetStatus(ctx context.Context, infra *Infrastructure) (*InfraStatus, error)

GetStatus retrieves the current status of infrastructure

func (*LinodeProvider) Type added in v5.0.2

func (p *LinodeProvider) Type() ProviderType

Type returns the provider type

func (*LinodeProvider) Validate added in v5.0.2

func (p *LinodeProvider) Validate(ctx context.Context) error

Validate checks if the provider configuration is valid

type Provider

type Provider interface {
	// Validate checks if the provider configuration is valid
	Validate(ctx context.Context) error

	// EstimateCost estimates the cost for the given configuration
	EstimateCost(mode ExecutionMode, instanceCount int) (*CostEstimate, error)

	// CreateInfrastructure provisions the cloud resources
	CreateInfrastructure(ctx context.Context, opts *CreateOptions) (*Infrastructure, error)

	// DestroyInfrastructure tears down the cloud resources
	DestroyInfrastructure(ctx context.Context, infra *Infrastructure) error

	// GetStatus retrieves the current status of infrastructure
	GetStatus(ctx context.Context, infra *Infrastructure) (*InfraStatus, error)

	// Type returns the provider type
	Type() ProviderType
}

Provider is the interface that all cloud providers must implement

func CreateProvider

func CreateProvider(cfg *config.CloudConfigs, providerType ProviderType) (Provider, error)

CreateProvider creates a provider instance based on cloud configuration

type ProviderRegistry

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

ProviderRegistry manages provider instances

func NewProviderRegistry

func NewProviderRegistry() *ProviderRegistry

NewProviderRegistry creates a new provider registry

func (*ProviderRegistry) Get

func (r *ProviderRegistry) Get(providerType ProviderType) (Provider, error)

Get retrieves a provider by type

func (*ProviderRegistry) List

func (r *ProviderRegistry) List() []ProviderType

List returns all registered provider types

func (*ProviderRegistry) Register

func (r *ProviderRegistry) Register(provider Provider)

Register registers a provider

type ProviderType

type ProviderType string

ProviderType represents the cloud provider type

const (
	ProviderAWS          ProviderType = "aws"
	ProviderGCP          ProviderType = "gcp"
	ProviderDigitalOcean ProviderType = "digitalocean"
	ProviderLinode       ProviderType = "linode"
	ProviderAzure        ProviderType = "azure"
	ProviderHetzner      ProviderType = "hetzner"
)

type PulumiManager

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

PulumiManager manages Pulumi stacks for infrastructure provisioning

func NewPulumiManager

func NewPulumiManager(projectName, stackName, statePath string) (*PulumiManager, error)

NewPulumiManager creates a new Pulumi manager with local backend

func (*PulumiManager) Destroy

func (pm *PulumiManager) Destroy(ctx context.Context) error

Destroy tears down the infrastructure and removes the stack and its state

func (*PulumiManager) GetOutputs

func (pm *PulumiManager) GetOutputs(ctx context.Context) (map[string]auto.OutputValue, error)

GetOutputs retrieves the stack outputs (IPs, IDs, etc.)

func (*PulumiManager) GetStackName

func (pm *PulumiManager) GetStackName() string

GetStackName returns the stack name

func (*PulumiManager) SetConfig added in v5.0.2

func (pm *PulumiManager) SetConfig(ctx context.Context, key, value string, secret bool) error

SetConfig sets a Pulumi stack configuration value

func (*PulumiManager) Up

func (pm *PulumiManager) Up(ctx context.Context, program pulumi.RunFunc) error

Up provisions infrastructure using the provided Pulumi program

type PulumiWriter added in v5.0.2

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

PulumiWriter is an io.Writer that colorizes Pulumi progress output

func NewPulumiWriter added in v5.0.2

func NewPulumiWriter() *PulumiWriter

NewPulumiWriter creates a writer that colorizes Pulumi output lines

func (*PulumiWriter) Flush added in v5.0.2

func (w *PulumiWriter) Flush()

Flush writes any remaining buffered content

func (*PulumiWriter) Write added in v5.0.2

func (w *PulumiWriter) Write(p []byte) (int, error)

type Resource

type Resource struct {
	// Type is the resource type (e.g., "vm", "function")
	Type string

	// ID is the cloud provider's resource ID
	ID string

	// Name is a human-readable name
	Name string

	// PublicIP is the public IP address (if applicable)
	PublicIP string

	// PrivateIP is the private IP address (if applicable)
	PrivateIP string

	// SSHEnabled indicates if SSH access is available
	SSHEnabled bool

	// WorkerID is the Osmedeus worker ID after registration
	WorkerID string

	// Status is the current resource status
	Status string

	// Metadata contains additional resource-specific data
	Metadata map[string]interface{}
}

Resource represents a single cloud resource

type ResourceStatus

type ResourceStatus struct {
	// ResourceID is the resource identifier
	ResourceID string

	// Status is the resource status
	Status string

	// Message provides additional status information
	Message string

	// WorkerRegistered indicates if the worker has registered
	WorkerRegistered bool
}

ResourceStatus represents the status of a single resource

type SSHConfig added in v5.0.2

type SSHConfig struct {
	Host     string
	Port     int
	User     string
	KeyFile  string
	Password string
}

SSHConfig holds the parameters needed to connect to a remote host

Jump to

Keyboard shortcuts

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