types

package
v1.17.0 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultImage

func DefaultImage(provider ProviderName) string

DefaultImage returns the default Ubuntu 24.04 image slug for each provider.

Types

type CreateServerOptions

type CreateServerOptions struct {
	Name      string
	Region    string
	Size      string
	Image     string
	SSHKeyIDs []string
	Tags      map[string]string
}

CreateServerOptions contains the parameters for creating a new server.

type DNSProvider

type DNSProvider interface {
	CreateZone(ctx context.Context, domain string) error
	GetZone(ctx context.Context, domain string) (*Zone, bool, error)
	CreateRecord(ctx context.Context, domain string, record DNSRecord) (*DNSRecord, error)
	DeleteRecord(ctx context.Context, domain string, recordID string) error
	ListRecords(ctx context.Context, domain string) ([]DNSRecord, error)
}

DNSProvider is optionally implemented by providers supporting DNS management.

type DNSRecord

type DNSRecord struct {
	ID    string
	Type  string
	Name  string
	Value string
	TTL   int
}

DNSRecord represents a DNS record.

type Provider

type Provider interface {
	Name() string
	DisplayName() string

	CreateServer(ctx context.Context, opts CreateServerOptions) (*Server, error)
	GetServer(ctx context.Context, id string) (*Server, error)
	GetServers(ctx context.Context) ([]Server, error)
	WaitForServer(ctx context.Context, id string, timeout time.Duration) (*Server, error)

	GetRegions(ctx context.Context) ([]Region, error)
	GetSizes(ctx context.Context, region string) ([]Size, error)

	GetSSHKey(ctx context.Context, fingerprint string) (*SSHKey, error)
	CreateSSHKey(ctx context.Context, name string, publicKey string) (*SSHKey, error)
}

Provider defines the interface for cloud server providers.

type ProviderName

type ProviderName string

ProviderName identifies a cloud provider.

const (
	ProviderDigitalOcean ProviderName = "digitalocean"
	ProviderHetzner      ProviderName = "hetzner"
)

func SupportedProviders

func SupportedProviders() []ProviderName

type ProviderWithDNS

type ProviderWithDNS interface {
	Provider
	DNSProvider
}

ProviderWithDNS combines both interfaces.

type Region

type Region struct {
	Slug      string
	Name      string
	Country   string
	Available bool
}

Region represents a cloud provider region/location.

type SSHKey

type SSHKey struct {
	ID          string
	Name        string
	Fingerprint string
	PublicKey   string
}

SSHKey represents an SSH public key registered with a provider.

type Server

type Server struct {
	ID           string
	Name         string
	Status       ServerStatus
	PublicIPv4   string
	PublicIPv6   string
	Region       string
	Size         string
	Image        string
	CreatedAt    time.Time
	DashboardURL string
}

Server represents a cloud server instance.

type ServerStatus

type ServerStatus string

ServerStatus represents the state of a server.

const (
	ServerStatusPending  ServerStatus = "pending"
	ServerStatusStarting ServerStatus = "starting"
	ServerStatusRunning  ServerStatus = "running"
	ServerStatusStopped  ServerStatus = "stopped"
	ServerStatusError    ServerStatus = "error"
	ServerStatusUnknown  ServerStatus = "unknown"
)

type Size

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

Size represents a server size/type.

type Zone

type Zone struct {
	ID   string
	Name string
	TTL  int
}

Zone represents a DNS zone/domain.

Jump to

Keyboard shortcuts

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