infra

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2026 License: MIT Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PulumiVersion is the version of Pulumi to install
	PulumiVersion = "3.215.0"

	// PulumiBaseURL is the base URL for Pulumi releases
	PulumiBaseURL = "https://get.pulumi.com/releases/sdk"
)

Variables

View Source
var AWSEnvVars = struct {
	AccessKey string
	SecretKey string
}{
	AccessKey: "AWS_ACCESS_KEY_ID",
	SecretKey: "AWS_SECRET_ACCESS_KEY",
}

AWSEnvVars for AWS credentials

View Source
var CDNPricing = map[string]float64{
	"digitalocean": 0.01,
	"hetzner":      0.00,
	"aws":          0.085,
	"linode":       0.005,
}

CDNPricing maps provider -> price per GB transferred

View Source
var FallbackServerTypes = map[string][]string{
	"hetzner": {

		"cax11", "cax21", "cax31", "cax41",

		"cx23", "cx33", "cx43", "cx53",

		"cpx11", "cpx21", "cpx31", "cpx41", "cpx51",

		"ccx13", "ccx23", "ccx33", "ccx43", "ccx53", "ccx63",
	},
	"digitalocean": {

		"s-1vcpu-512mb-10gb", "s-1vcpu-1gb", "s-1vcpu-2gb", "s-2vcpu-2gb", "s-2vcpu-4gb",
		"s-4vcpu-8gb", "s-6vcpu-16gb", "s-8vcpu-32gb",

		"g-2vcpu-8gb", "g-4vcpu-16gb", "g-8vcpu-32gb",

		"c-2", "c-4", "c-8", "c-16",
	},
	"aws": {

		"t3.nano", "t3.micro", "t3.small", "t3.medium", "t3.large", "t3.xlarge", "t3.2xlarge",

		"t3a.nano", "t3a.micro", "t3a.small", "t3a.medium", "t3a.large",

		"m5.large", "m5.xlarge", "m5.2xlarge", "m5.4xlarge",

		"c5.large", "c5.xlarge", "c5.2xlarge",
	},
	"linode": {

		"g6-nanode-1", "g6-standard-1", "g6-standard-2", "g6-standard-4", "g6-standard-6",
		"g6-standard-8", "g6-standard-16",

		"g6-dedicated-2", "g6-dedicated-4", "g6-dedicated-8",
	},
}

FallbackServerTypes maps providers to their common server types Used as a fallback when dynamic API validation is not available For dynamic validation, use DynamicValidateServerType() with a token

View Source
var ProviderCaps = map[string]ProviderCapabilities{
	"digitalocean": {
		Name:            "DigitalOcean",
		HasVPC:          true,
		HasFirewall:     true,
		HasPrivateIP:    true,
		HasObjectStore:  true,
		HasBlockStorage: true,
		HasCDN:          true,
		HasLoadBalancer: true,
		MinServerCount:  1,
		MaxServerCount:  500,
	},
	"hetzner": {
		Name:            "Hetzner",
		HasVPC:          true,
		HasFirewall:     true,
		HasPrivateIP:    true,
		HasObjectStore:  true,
		HasBlockStorage: true,
		HasCDN:          false,
		HasLoadBalancer: true,
		MinServerCount:  1,
		MaxServerCount:  100,
	},
	"aws": {
		Name:            "AWS",
		HasVPC:          true,
		HasFirewall:     true,
		HasPrivateIP:    true,
		HasObjectStore:  true,
		HasBlockStorage: true,
		HasCDN:          true,
		HasLoadBalancer: true,
		MinServerCount:  1,
		MaxServerCount:  1000,
	},
	"linode": {
		Name:            "Linode",
		HasVPC:          true,
		HasFirewall:     true,
		HasPrivateIP:    true,
		HasObjectStore:  true,
		HasBlockStorage: true,
		HasCDN:          false,
		HasLoadBalancer: true,
		MinServerCount:  1,
		MaxServerCount:  250,
	},
}

ProviderCaps maps provider names to their capabilities

View Source
var ProviderEnvVars = map[string]string{
	"digitalocean": "DIGITALOCEAN_TOKEN",
	"hetzner":      "HCLOUD_TOKEN",
	"linode":       "LINODE_TOKEN",
}

ProviderEnvVars maps providers to their default environment variable names

View Source
var ProviderImages = map[string]string{
	"digitalocean": "ubuntu-22-04-x64",
	"hetzner":      "ubuntu-22.04",
	"aws":          "ami-0c7217cdde317cfec",
	"linode":       "linode/ubuntu22.04",
}

ProviderImages maps providers to default Ubuntu 22.04 images

View Source
var ProviderRegions = map[string]map[string]string{
	"digitalocean": {
		"nyc":  "nyc1",
		"nyc1": "nyc1",
		"nyc3": "nyc3",
		"sfo":  "sfo3",
		"sfo3": "sfo3",
		"ams":  "ams3",
		"ams3": "ams3",
		"sgp":  "sgp1",
		"sgp1": "sgp1",
		"lon":  "lon1",
		"lon1": "lon1",
		"fra":  "fra1",
		"fra1": "fra1",
		"tor":  "tor1",
		"tor1": "tor1",
		"blr":  "blr1",
		"blr1": "blr1",
		"syd":  "syd1",
		"syd1": "syd1",
	},
	"hetzner": {
		"nuremberg":   "nbg1",
		"nbg1":        "nbg1",
		"falkenstein": "fsn1",
		"fsn1":        "fsn1",
		"helsinki":    "hel1",
		"hel1":        "hel1",
		"ashburn":     "ash",
		"ash":         "ash",
		"hillsboro":   "hil",
		"hil":         "hil",
	},
	"aws": {
		"us-east":    "us-east-1",
		"us-east-1":  "us-east-1",
		"us-west":    "us-west-2",
		"us-west-2":  "us-west-2",
		"eu-west":    "eu-west-1",
		"eu-west-1":  "eu-west-1",
		"ap-south":   "ap-south-1",
		"ap-south-1": "ap-south-1",
	},
	"linode": {
		"newark":     "us-east",
		"us-east":    "us-east",
		"fremont":    "us-west",
		"us-west":    "us-west",
		"frankfurt":  "eu-central",
		"eu-central": "eu-central",
		"singapore":  "ap-south",
		"ap-south":   "ap-south",
	},
}

ProviderRegions maps providers to their available regions with friendly names

View Source
var ProviderSizes = map[string]map[ServerSize]string{
	"digitalocean": {
		SizeSmall:  "s-1vcpu-1gb",
		SizeMedium: "s-2vcpu-4gb",
		SizeLarge:  "s-4vcpu-8gb",
		SizeXLarge: "s-8vcpu-16gb",
	},
	"hetzner": {
		SizeSmall:  "cx11",
		SizeMedium: "cx21",
		SizeLarge:  "cx31",
		SizeXLarge: "cx41",
	},
	"aws": {
		SizeSmall:  "t3.micro",
		SizeMedium: "t3.medium",
		SizeLarge:  "t3.large",
		SizeXLarge: "t3.xlarge",
	},
	"linode": {
		SizeSmall:  "g6-nanode-1",
		SizeMedium: "g6-standard-2",
		SizeLarge:  "g6-standard-4",
		SizeXLarge: "g6-standard-8",
	},
}

ProviderSizes maps generic sizes to provider-specific instance types

View Source
var S3EndpointMap = map[string]string{
	"digitalocean": "https://%s.digitaloceanspaces.com",
	"linode":       "https://%s.linodeobjects.com",
	"aws":          "",
	"hetzner":      "",
}

S3EndpointMap maps providers to their S3-compatible endpoints

View Source
var ServerPricing = map[string]map[string]Pricing{
	"digitalocean": {
		"small":  {Hourly: 0.009, Monthly: 6},
		"medium": {Hourly: 0.036, Monthly: 24},
		"large":  {Hourly: 0.071, Monthly: 48},
		"xlarge": {Hourly: 0.143, Monthly: 96},

		"s-1vcpu-1gb":  {Hourly: 0.009, Monthly: 6},
		"s-2vcpu-4gb":  {Hourly: 0.036, Monthly: 24},
		"s-4vcpu-8gb":  {Hourly: 0.071, Monthly: 48},
		"s-8vcpu-16gb": {Hourly: 0.143, Monthly: 96},
	},
	"hetzner": {
		"small":  {Hourly: 0.005, Monthly: 3.29},
		"medium": {Hourly: 0.008, Monthly: 5.39},
		"large":  {Hourly: 0.014, Monthly: 9.59},
		"xlarge": {Hourly: 0.027, Monthly: 17.99},

		"cx11": {Hourly: 0.005, Monthly: 3.29},
		"cx21": {Hourly: 0.008, Monthly: 5.39},
		"cx31": {Hourly: 0.014, Monthly: 9.59},
		"cx41": {Hourly: 0.027, Monthly: 17.99},
	},
	"aws": {
		"small":  {Hourly: 0.0104, Monthly: 7.59},
		"medium": {Hourly: 0.0416, Monthly: 30.37},
		"large":  {Hourly: 0.0832, Monthly: 60.74},
		"xlarge": {Hourly: 0.1664, Monthly: 121.47},

		"t3.micro":  {Hourly: 0.0104, Monthly: 7.59},
		"t3.medium": {Hourly: 0.0416, Monthly: 30.37},
		"t3.large":  {Hourly: 0.0832, Monthly: 60.74},
		"t3.xlarge": {Hourly: 0.1664, Monthly: 121.47},
	},
	"linode": {
		"small":  {Hourly: 0.0075, Monthly: 5},
		"medium": {Hourly: 0.018, Monthly: 12},
		"large":  {Hourly: 0.036, Monthly: 24},
		"xlarge": {Hourly: 0.072, Monthly: 48},

		"g6-nanode-1":   {Hourly: 0.0075, Monthly: 5},
		"g6-standard-2": {Hourly: 0.018, Monthly: 12},
		"g6-standard-4": {Hourly: 0.036, Monthly: 24},
		"g6-standard-8": {Hourly: 0.072, Monthly: 48},
	},
}

ServerPricing maps provider -> size -> pricing

View Source
var StoragePricing = map[string]map[string]float64{
	"digitalocean": {
		"spaces":  0.02,
		"volumes": 0.10,
	},
	"hetzner": {
		"object":  0.0052,
		"volumes": 0.052,
	},
	"aws": {
		"s3":  0.023,
		"ebs": 0.08,
	},
	"linode": {
		"object":  0.02,
		"volumes": 0.10,
	},
}

StoragePricing maps provider -> storage type -> price per GB/month

View Source
var ValidProtocols = []string{"tcp", "udp", "icmp"}

ValidProtocols defines allowed firewall protocols

View Source
var ValidServerTypes = FallbackServerTypes

ValidServerTypes is an alias for FallbackServerTypes for backwards compatibility

Functions

func ConvertToProvider

func ConvertToProvider(portable *PortableConfig, provider string) (*config.InfrastructureConfig, error)

ConvertToProvider converts a portable config to provider-specific

func DynamicValidateServerType

func DynamicValidateServerType(provider, serverType, token string) error

DynamicValidateServerType validates a server type dynamically using provider API

func EnsurePulumi added in v0.2.1

func EnsurePulumi(verbose bool) error

EnsurePulumi checks if Pulumi is installed and installs it if not

func EstimateMonthlyInfraCost

func EstimateMonthlyInfraCost(provider string, servers map[string]InfraServerSpec) float64

EstimateMonthlyInfraCost calculates estimated monthly cost for servers

func FormatMemory

func FormatMemory(mb int) string

FormatMemory formats memory in MB to human readable

func FormatPricing

func FormatPricing(monthly float64) string

FormatPricing formats pricing for display

func GenerateServersConfig

func GenerateServersConfig(infra *config.InfrastructureConfig, outputs map[string]interface{}) map[string]config.ServerConfig

GenerateServersConfig creates the servers config section from infrastructure outputs

func GetDefaultImage

func GetDefaultImage(provider string) string

GetDefaultImage returns the default image for a provider

func GetEnvironmentServers

func GetEnvironmentServers(infra *config.InfrastructureConfig) []string

GetEnvironmentServers returns server names for an environment from infrastructure

func GetEquivalentSize

func GetEquivalentSize(fromProvider, toProvider, size string) string

GetEquivalentSize finds equivalent size across providers

func GetProviderComparison

func GetProviderComparison(size string, count int) map[string]float64

GetProviderComparison returns pricing comparison across providers

func GetProviderRegions

func GetProviderRegions(provider string) []string

GetProviderRegions returns available regions for a provider

func GetPulumiInstallDir added in v0.2.1

func GetPulumiInstallDir() (string, error)

GetPulumiInstallDir returns the directory where Pulumi should be installed

func GetPulumiVersion added in v0.2.1

func GetPulumiVersion() (string, error)

GetPulumiVersion returns the installed Pulumi version

func GetRequiredCredentials

func GetRequiredCredentials(infra *config.InfrastructureConfig) map[string]string

GetRequiredCredentials returns the env vars needed for the infrastructure config

func GetServerProvider

func GetServerProvider(infra *config.InfrastructureConfig, spec config.InfraServerSpec) string

GetServerProvider returns the effective provider for a server

func GetServerRegion

func GetServerRegion(infra *config.InfrastructureConfig, spec config.InfraServerSpec) string

GetServerRegion returns the effective region for a server

func GetUsedProviders

func GetUsedProviders(infra *config.InfrastructureConfig) []string

GetUsedProviders returns all providers used in the infrastructure config

func GetValidServerTypes

func GetValidServerTypes(provider string) []string

GetValidServerTypes returns valid server types for a provider

func IsMultiProvider

func IsMultiProvider(infra *config.InfrastructureConfig) bool

IsMultiProvider returns true if config uses multiple providers

func IsValidProvider

func IsValidProvider(provider string) bool

IsValidProvider checks if a provider is supported

func MergeServersConfig

func MergeServersConfig(existing, generated map[string]config.ServerConfig) map[string]config.ServerConfig

MergeServersConfig merges generated servers with existing config Existing config takes precedence

func MigrateConfig

func MigrateConfig(infra *config.InfrastructureConfig, toProvider string) (*config.InfrastructureConfig, []string)

MigrateConfig converts config from one provider to another

func ParseIntFromString

func ParseIntFromString(s string) (int, error)

ParseIntFromString safely parses an integer from a string, returning an error if invalid

func PrintProviderComparison

func PrintProviderComparison(provider1, provider2 string)

PrintProviderComparison shows a comparison between two providers

func ResolveInfraConfig

func ResolveInfraConfig(infra *config.InfrastructureConfig) error

ResolveInfraConfig resolves and validates infrastructure configuration - Resolves credentials from environment variables if not specified - Resolves generic sizes to provider-specific sizes - Applies defaults to server specs - Resolves region aliases

func ResolveRegion

func ResolveRegion(provider, region string) string

ResolveRegion converts a friendly region name to provider-specific region

func ResolveSize

func ResolveSize(provider, size string) string

ResolveSize converts a generic or provider-specific size to the actual provider size

func ShowPricingComparison

func ShowPricingComparison()

ShowPricingComparison displays pricing across all providers

func ShowStoragePricing

func ShowStoragePricing()

ShowStoragePricing displays storage pricing

func ValidProviders

func ValidProviders() []string

ValidProviders returns list of supported providers

func ValidateCIDR

func ValidateCIDR(cidr string) error

ValidateCIDR checks if a CIDR block is valid

func ValidateCIDRs

func ValidateCIDRs(cidrs []string) error

ValidateCIDRs checks if all CIDR blocks in a slice are valid

func ValidateConfig

func ValidateConfig(infra *config.InfrastructureConfig) []string

ValidateConfig validates infrastructure config for a provider

func ValidateFirewallRules

func ValidateFirewallRules(rules []config.InfraFirewallRule) []string

ValidateFirewallRules validates all firewall rules

func ValidatePort

func ValidatePort(port int) error

ValidatePort checks if a port number is valid (1-65535)

func ValidatePorts

func ValidatePorts(ports []int) error

ValidatePorts checks if all ports in a slice are valid

func ValidateProtocol

func ValidateProtocol(protocol string) error

ValidateProtocol checks if a protocol is valid

func ValidateServerCount

func ValidateServerCount(count int, provider string) error

ValidateServerCount checks if server count is within allowed range

func ValidateServerType

func ValidateServerType(provider, serverType string) error

ValidateServerType checks if a server type is valid for a provider

Types

type DestroyOptions

type DestroyOptions struct {
	Preview     bool   // Preview what would be destroyed
	Environment string // Target environment
	Verbose     bool   // Verbose output
	Yes         bool   // Skip confirmation prompts
}

DestroyOptions configures the destroy operation

type InfraServerSpec

type InfraServerSpec struct {
	Size  string
	Count int
}

InfraServerSpec mirrors config.InfraServerSpec for pricing

type InfraState

type InfraState struct {
	Provider        string                  `json:"provider"`
	Region          string                  `json:"region"`
	Environment     string                  `json:"environment"`
	LastProvisioned time.Time               `json:"last_provisioned"`
	Servers         map[string]ServerOutput `json:"servers"`
	Network         *NetworkOutput          `json:"network,omitempty"`
	StackName       string                  `json:"stack_name"`
	Outputs         map[string]interface{}  `json:"outputs"`
}

InfraState tracks the complete infrastructure state

type NetworkOutput

type NetworkOutput struct {
	VPCID        string `json:"vpc_id,omitempty"`
	VPCName      string `json:"vpc_name,omitempty"`
	FirewallID   string `json:"firewall_id,omitempty"`
	FirewallName string `json:"firewall_name,omitempty"`
}

NetworkOutput contains provisioned network information

type Orchestrator

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

Orchestrator manages infrastructure provisioning operations

func NewOrchestrator

func NewOrchestrator(cfg *config.Config, takoDir string, environment string, verbose bool) (*Orchestrator, error)

NewOrchestrator creates a new infrastructure orchestrator

func (*Orchestrator) Destroy

func (o *Orchestrator) Destroy(ctx context.Context) (*ProvisionResult, error)

Destroy tears down infrastructure

func (*Orchestrator) GetInfraState

func (o *Orchestrator) GetInfraState() (*InfraState, error)

GetInfraState retrieves the current infrastructure state

func (*Orchestrator) GetOutputs

func (o *Orchestrator) GetOutputs() (map[string]interface{}, error)

GetOutputs retrieves the current infrastructure outputs

func (*Orchestrator) GetSSHKeyPair added in v0.2.6

func (o *Orchestrator) GetSSHKeyPair() *SSHKeyPair

GetSSHKeyPair returns the current SSH key pair, loading state if needed

func (*Orchestrator) IsProvisioned

func (o *Orchestrator) IsProvisioned() bool

IsProvisioned checks if infrastructure has been provisioned

func (*Orchestrator) Preview

func (o *Orchestrator) Preview(ctx context.Context) (*ProvisionResult, error)

Preview shows what infrastructure changes would be made

func (*Orchestrator) Provision

func (o *Orchestrator) Provision(ctx context.Context) (*ProvisionResult, error)

Provision creates or updates infrastructure

type PortableConfig

type PortableConfig struct {
	Region  string                        `yaml:"region"` // Friendly name: us-east, europe, asia
	Servers map[string]PortableServerSpec `yaml:"servers"`
}

PortableConfig represents a provider-agnostic infrastructure config

type PortableServerSpec

type PortableServerSpec struct {
	Size  string `yaml:"size"` // small, medium, large, xlarge
	Role  string `yaml:"role"` // manager, worker
	Count int    `yaml:"count"`
}

PortableServerSpec is a provider-agnostic server spec

type Pricing

type Pricing struct {
	Hourly  float64
	Monthly float64
}

Pricing contains monthly cost estimates in USD

func GetServerPricing

func GetServerPricing(provider, size string) Pricing

GetServerPricing returns pricing for a server size

type ProviderAPI

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

ProviderAPI handles fetching real data from provider APIs

func NewProviderAPI

func NewProviderAPI() *ProviderAPI

NewProviderAPI creates a new API client

func (*ProviderAPI) FetchRegions

func (api *ProviderAPI) FetchRegions(provider string) ([]RegionInfo, error)

FetchRegions gets available regions from provider API

func (*ProviderAPI) FetchSizes

func (api *ProviderAPI) FetchSizes(provider, region string) ([]SizeInfo, error)

FetchSizes gets available server sizes from provider API

type ProviderCapabilities

type ProviderCapabilities struct {
	Name            string
	HasVPC          bool
	HasFirewall     bool
	HasPrivateIP    bool
	HasObjectStore  bool
	HasBlockStorage bool
	HasCDN          bool
	HasLoadBalancer bool
	MinServerCount  int
	MaxServerCount  int
}

ProviderCapabilities defines what features each provider supports

type ProvisionOptions

type ProvisionOptions struct {
	Preview     bool   // Preview changes without applying
	Environment string // Target environment
	Verbose     bool   // Verbose output
	Yes         bool   // Skip confirmation prompts
}

ProvisionOptions configures the provision operation

type ProvisionResult

type ProvisionResult struct {
	Success  bool                    `json:"success"`
	Servers  map[string]ServerOutput `json:"servers"`
	Network  *NetworkOutput          `json:"network,omitempty"`
	Outputs  map[string]interface{}  `json:"outputs"`
	Summary  string                  `json:"summary"`
	Error    string                  `json:"error,omitempty"`
	Duration time.Duration           `json:"duration"`
}

ProvisionResult contains the result of a provision operation

type RegionInfo

type RegionInfo struct {
	Slug        string
	Name        string
	Available   bool
	Description string
}

RegionInfo contains region details

type SSHKeyManager

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

SSHKeyManager handles SSH key generation and state management

func NewSSHKeyManager

func NewSSHKeyManager(takoDir string) *SSHKeyManager

NewSSHKeyManager creates a new SSH key manager

func (*SSHKeyManager) CleanupKeys

func (m *SSHKeyManager) CleanupKeys() error

CleanupKeys removes generated keys and state

func (*SSHKeyManager) EnsureKeyPair

func (m *SSHKeyManager) EnsureKeyPair(projectName string) (*SSHKeyPair, error)

EnsureKeyPair ensures an SSH key pair exists, generating one if needed

func (*SSHKeyManager) GetKeyDir

func (m *SSHKeyManager) GetKeyDir() string

GetKeyDir returns the directory where SSH keys are stored

func (*SSHKeyManager) GetKeyPair

func (m *SSHKeyManager) GetKeyPair() *SSHKeyPair

GetKeyPair returns the current key pair, loading state if needed

func (*SSHKeyManager) GetKeyStatePath

func (m *SSHKeyManager) GetKeyStatePath() string

GetKeyStatePath returns the path to the SSH key state file

func (*SSHKeyManager) GetPrivateKeyPath

func (m *SSHKeyManager) GetPrivateKeyPath() string

GetPrivateKeyPath returns the private key path

func (*SSHKeyManager) GetProviderKeyID

func (m *SSHKeyManager) GetProviderKeyID(provider string) string

GetProviderKeyID returns the key ID for a specific provider

func (*SSHKeyManager) GetPublicKey

func (m *SSHKeyManager) GetPublicKey() string

GetPublicKey returns the public key content

func (*SSHKeyManager) HasKeyPair

func (m *SSHKeyManager) HasKeyPair() bool

HasKeyPair returns true if a key pair exists

func (*SSHKeyManager) LoadState

func (m *SSHKeyManager) LoadState() error

LoadState loads the SSH key state from disk

func (*SSHKeyManager) SaveState

func (m *SSHKeyManager) SaveState() error

SaveState saves the SSH key state to disk

func (*SSHKeyManager) SetProviderKeyID

func (m *SSHKeyManager) SetProviderKeyID(provider, keyID string) error

SetProviderKeyID sets the key ID for a specific provider

type SSHKeyPair

type SSHKeyPair struct {
	PrivateKeyPath string `json:"private_key_path"`
	PublicKeyPath  string `json:"public_key_path"`
	PublicKey      string `json:"public_key"` // The actual public key content
	Fingerprint    string `json:"fingerprint"`
	NewlyGenerated bool   `json:"-"` // true when key was just generated (not persisted)
}

SSHKeyPair represents a generated SSH key pair

type SSHKeyState

type SSHKeyState struct {
	KeyPair      SSHKeyPair        `json:"key_pair"`
	ProviderKeys map[string]string `json:"provider_keys"` // provider -> key ID on that provider
}

SSHKeyState stores the generated key and uploaded key IDs per provider

type ServerOutput

type ServerOutput struct {
	ID        string `json:"id"`
	Name      string `json:"name"`
	PublicIP  string `json:"public_ip"`
	PrivateIP string `json:"private_ip,omitempty"`
	Status    string `json:"status"`
	Region    string `json:"region"`
	Role      string `json:"role"`
	Index     int    `json:"index"` // For servers with count > 1
}

ServerOutput contains provisioned server information

type ServerSize

type ServerSize string

ServerSize represents a generic server size that maps to provider-specific sizes

const (
	SizeSmall  ServerSize = "small"  // 1 vCPU, 1GB RAM
	SizeMedium ServerSize = "medium" // 2 vCPU, 4GB RAM
	SizeLarge  ServerSize = "large"  // 4 vCPU, 8GB RAM
	SizeXLarge ServerSize = "xlarge" // 8 vCPU, 16GB RAM
)

type ServerType

type ServerType struct {
	ID          string  `json:"id"`
	Name        string  `json:"name"`
	Description string  `json:"description"`
	CPUs        int     `json:"cpus"`
	Memory      int     `json:"memory"` // in MB
	Disk        int     `json:"disk"`   // in GB
	PriceHourly float64 `json:"price_hourly"`
	Available   bool    `json:"available"`
}

ServerType represents a server type from a provider

type ServerTypeCache

type ServerTypeCache struct {
	Provider  string       `json:"provider"`
	Types     []ServerType `json:"types"`
	FetchedAt time.Time    `json:"fetched_at"`
	ExpiresAt time.Time    `json:"expires_at"`
}

ServerTypeCache represents cached server types for a provider

type SizeInfo

type SizeInfo struct {
	Slug         string
	Description  string
	VCPUs        int
	Memory       int // MB
	Disk         int // GB
	PriceHourly  float64
	PriceMonthly float64
	Available    bool
}

SizeInfo contains server size details

type StateBackend

type StateBackend string

StateBackend represents the type of state storage backend

const (
	BackendLocal   StateBackend = "local"   // Local filesystem
	BackendS3      StateBackend = "s3"      // S3-compatible storage
	BackendManager StateBackend = "manager" // Store on manager node via SSH
)

type StateManager

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

StateManager manages Pulumi state and Tako infrastructure state integration

func NewStateManager

func NewStateManager(basePath, projectName, environment string) *StateManager

NewStateManager creates a new state manager

func NewStateManagerWithConfig

func NewStateManagerWithConfig(basePath, projectName, environment string, infraConfig *config.InfrastructureConfig) *StateManager

NewStateManagerWithConfig creates a state manager with infrastructure config

func (*StateManager) ClearState

func (m *StateManager) ClearState() error

ClearState removes all infrastructure state (used after destroy)

func (*StateManager) CreateStack

func (m *StateManager) CreateStack(ctx context.Context, program pulumi.RunFunc) (auto.Stack, error)

CreateStack creates or selects a Pulumi stack with configured backend

func (*StateManager) Destroy

func (m *StateManager) Destroy(ctx context.Context, stack auto.Stack, verbose bool) (*auto.DestroyResult, error)

Destroy tears down infrastructure

func (*StateManager) EnsureDirectories

func (m *StateManager) EnsureDirectories() error

EnsureDirectories creates required directories for Pulumi state

func (*StateManager) GetBackend

func (m *StateManager) GetBackend() StateBackend

GetBackend returns the configured state backend type

func (*StateManager) GetBackendEnvVars

func (m *StateManager) GetBackendEnvVars() map[string]string

GetBackendEnvVars returns environment variables needed for the backend

func (*StateManager) GetBackendURL

func (m *StateManager) GetBackendURL() string

GetBackendURL returns the backend URL for Pulumi based on configuration

func (*StateManager) GetInfraDir

func (m *StateManager) GetInfraDir() string

GetInfraDir returns the path to the infrastructure state directory

func (*StateManager) GetPulumiDir

func (m *StateManager) GetPulumiDir() string

GetPulumiDir returns the path to the Pulumi workspace directory

func (*StateManager) GetS3BucketSuggestion

func (m *StateManager) GetS3BucketSuggestion() string

GetS3BucketSuggestion returns a suggested bucket name for the project

func (*StateManager) GetServerIP

func (m *StateManager) GetServerIP(serverName string, index int) (string, error)

GetServerIP retrieves a server's IP from cached outputs

func (*StateManager) GetStackName

func (m *StateManager) GetStackName() string

GetStackName returns the Pulumi stack name for this environment

func (*StateManager) GetStateBackendDescription

func (m *StateManager) GetStateBackendDescription() string

GetStateBackendDescription returns a human-readable description of the state backend

func (*StateManager) IsProvisioned

func (m *StateManager) IsProvisioned() bool

IsProvisioned checks if infrastructure has been provisioned

func (*StateManager) LoadInfraState

func (m *StateManager) LoadInfraState() (*InfraState, error)

LoadInfraState loads the infrastructure state

func (*StateManager) LoadOutputs

func (m *StateManager) LoadOutputs() (map[string]interface{}, error)

LoadOutputs reads cached infrastructure outputs

func (*StateManager) Preview

func (m *StateManager) Preview(ctx context.Context, stack auto.Stack, verbose bool) (*auto.PreviewResult, error)

Preview runs a preview of infrastructure changes

func (*StateManager) RequiresRemoteSync

func (m *StateManager) RequiresRemoteSync() bool

RequiresRemoteSync returns true if the backend requires syncing state to remote

func (*StateManager) SaveInfraState

func (m *StateManager) SaveInfraState(state *InfraState) error

SaveInfraState saves the complete infrastructure state

func (*StateManager) SaveOutputs

func (m *StateManager) SaveOutputs(outputs auto.OutputMap) error

SaveOutputs persists Pulumi stack outputs for Tako to use

func (*StateManager) Up

func (m *StateManager) Up(ctx context.Context, stack auto.Stack, verbose bool) (*auto.UpResult, error)

Up applies infrastructure changes

func (*StateManager) ValidateS3Config

func (m *StateManager) ValidateS3Config() error

ValidateS3Config validates S3 backend configuration

type TypesFetcher

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

TypesFetcher handles dynamic fetching of server types from provider APIs

func GetTypesFetcher

func GetTypesFetcher() *TypesFetcher

GetTypesFetcher returns the global types fetcher instance

func NewTypesFetcher

func NewTypesFetcher(cacheDir string) *TypesFetcher

NewTypesFetcher creates a new types fetcher with caching

func (*TypesFetcher) ClearCache

func (f *TypesFetcher) ClearCache(provider string) error

ClearCache clears the cache for a provider or all providers

func (*TypesFetcher) GetServerTypes

func (f *TypesFetcher) GetServerTypes(provider, token string) ([]ServerType, error)

GetServerTypes returns available server types for a provider

func (*TypesFetcher) ListAvailableTypes

func (f *TypesFetcher) ListAvailableTypes(provider, token string) (string, error)

ListAvailableTypes returns a formatted list of available server types

func (*TypesFetcher) ValidateServerType

func (f *TypesFetcher) ValidateServerType(provider, serverType, token string) (bool, string, error)

ValidateServerType checks if a server type is valid for a provider

type Wizard

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

Wizard handles interactive infrastructure configuration

func NewWizard

func NewWizard() *Wizard

NewWizard creates a new wizard instance

func (*Wizard) Run

func (w *Wizard) Run() (*WizardResult, error)

Run executes the interactive wizard

type WizardResult

type WizardResult struct {
	Config         *config.InfrastructureConfig
	EstimatedCost  float64
	YAMLContent    string
	ProviderEnvVar string
}

WizardResult contains the generated infrastructure configuration

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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