platform.go
package platform
// Platform provides cloud infrastructure operations.
// Use providers to create: mock.New(), digitalocean.New(), aws.New(), gcp.New()
type Platform struct {
Backend
}
// Backend is the interface that providers implement.
type Backend interface {
// Servers
CreateServer(opts ServerOptions) (*Server, error)
GetServer(name string) (*Server, error)
DeleteServer(id string) error
// Volumes
CreateVolume(name string, sizeGB int, region Region) (*Volume, error)
GetVolume(name string) (*Volume, error)
AttachVolume(volumeID, serverID string) error
DetachVolume(volumeID string) error
// DNS
CreateDNSZone(domain string) (*DNSZone, error)
GetDNSZone(domain string) (*DNSZone, error)
AddDNSRecord(zone string, record DNSRecord) error
DeleteDNSRecord(zone, recordID string) error
}
// ServerOptions configures server creation.
type ServerOptions struct {
Name string
Size Size
Region Region
Image string // Provider-specific image ID/slug
SSHKey string // SSH key fingerprint (use GetSSHKeyFingerprint to get)
Tags []string
}
// SSHKeyProvider is an optional interface for SSH key management.
type SSHKeyProvider interface {
// GetSSHKeyFingerprint finds or registers an SSH key, returns fingerprint.
GetSSHKeyFingerprint(publicKey string) (string, error)
}