serverprovider

package
v0.0.0-...-aa36cb2 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2024 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package serverprovider provides a way to interact with a server provider, e.g. Hetzner. It abstracts away the details of the provider like ordering, provisioning, getting available offerings, etc. It can be thought of as a generic API across all providers. All state is kept at the server provider itself--this means all IDs are server-provider specific and no state is shared across providers and no state is kept within Metal.

Index

Constants

View Source
const EquinixSlug = "equinix"
View Source
const HetznerSlug = "hetzner"
View Source
const OVHSlug = "ovh"
View Source
const ScalewaySlug = "scaleway"
View Source
const VultrSlug = "vultr"

Variables

View Source
var ErrServerNotFound = errors.New("server not found")
View Source
var ErrTransactionNotFound = errors.New("transaction not found")

Functions

This section is empty.

Types

type Addon

type Addon struct {
	Id          string
	Name        string
	Description string
	Min         int
	Max         int
	Prices      []Price
}

type Equinix

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

func NewEquinix

func NewEquinix(opts ...EquinixOption) (*Equinix, error)

func (*Equinix) GetCurrentOfferings

func (e *Equinix) GetCurrentOfferings() ([]Offering, error)

func (*Equinix) GetServer

func (e *Equinix) GetServer(serverId string) (Server, error)

func (*Equinix) GetTransaction

func (e *Equinix) GetTransaction(id string) (Transaction, error)

func (*Equinix) OrderServer

func (e *Equinix) OrderServer(order Order) (Transaction, error)

func (*Equinix) Slug

func (e *Equinix) Slug() string

type EquinixOption

type EquinixOption func(*Equinix) error

func WithEquinixClient

func WithEquinixClient(client *metal.APIClient) EquinixOption

type Hetzner

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

func NewHetzner

func NewHetzner(opts ...HetznerOption) (*Hetzner, error)

func (*Hetzner) GetCurrentOfferings

func (h *Hetzner) GetCurrentOfferings() ([]Offering, error)

func (*Hetzner) GetServer

func (h *Hetzner) GetServer(serverId string) (Server, error)

func (*Hetzner) GetTransaction

func (h *Hetzner) GetTransaction(id string) (Transaction, error)

func (*Hetzner) OrderServer

func (h *Hetzner) OrderServer(order Order) (Transaction, error)

func (*Hetzner) Slug

func (h *Hetzner) Slug() string

type HetznerOption

type HetznerOption func(*Hetzner) error

func WithAuthorizedKeyFingerprint

func WithAuthorizedKeyFingerprint(fingerprint string) HetznerOption

func WithHrobotClient

func WithHrobotClient(client *hrobot.Client) HetznerOption

func WithTestMode

func WithTestMode(testMode bool) HetznerOption

type OVH

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

func NewOVH

func NewOVH(opts ...OVHOption) (*OVH, error)

func (*OVH) GetCurrentOfferings

func (o *OVH) GetCurrentOfferings() ([]Offering, error)

func (*OVH) GetServer

func (o *OVH) GetServer(serverId string) (Server, error)

func (*OVH) GetTransaction

func (o *OVH) GetTransaction(id string) (Transaction, error)

func (*OVH) OrderServer

func (o *OVH) OrderServer(order Order) (Transaction, error)

func (*OVH) Slug

func (o *OVH) Slug() string

type OVHOption

type OVHOption func(*OVH) error

func WithOVHClient

func WithOVHClient(client *ovh.Client) OVHOption

type Offering

type Offering struct {
	Id          string
	Name        string
	Description string
	Locations   []string
	Prices      []Price
	Addons      []Addon
}

type Order

type Order struct {
	OfferingId string
	LocationId string
	AddonIds   []string
}

type Price

type Price struct {
	Currency      string
	Location      string
	AmountMonthly float64
	AmountSetup   float64
}

type Scaleway

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

func NewScaleway

func NewScaleway(opts ...ScalewayOption) (*Scaleway, error)

func (*Scaleway) GetCurrentOfferings

func (s *Scaleway) GetCurrentOfferings() ([]Offering, error)

func (*Scaleway) GetServer

func (s *Scaleway) GetServer(serverId string) (Server, error)

func (*Scaleway) GetTransaction

func (s *Scaleway) GetTransaction(id string) (Transaction, error)

func (*Scaleway) OrderServer

func (s *Scaleway) OrderServer(order Order) (Transaction, error)

func (*Scaleway) Slug

func (s *Scaleway) Slug() string

type ScalewayOption

type ScalewayOption func(*Scaleway) error

func WithScalewayClient

func WithScalewayClient(client *scw.Client) ScalewayOption

type Server

type Server struct {
	Id            string
	ProviderSlug  string
	OfferingId    string
	Location      string
	Status        ServerStatus
	StatusDetails string
	Ipv4          string
	Ipv6          string
}

type ServerProvider

type ServerProvider interface {
	Slug() string
	GetCurrentOfferings() ([]Offering, error)
	OrderServer(order Order) (Transaction, error)
	GetTransaction(id string) (Transaction, error)
	GetServer(serverId string) (Server, error)
}

type ServerStatus

type ServerStatus string
const (
	ServerStatusPending ServerStatus = "pending"
	ServerStatusRunning ServerStatus = "running"
)

type Transaction

type Transaction struct {
	Id            string
	Status        TransactionStatus
	StatusDetails string
	ServerId      string
	OfferingId    string
	Location      string
	AddonIds      []string
}

type TransactionStatus

type TransactionStatus string
const (
	TransactionStatusPending   TransactionStatus = "pending"
	TransactionStatusCompleted TransactionStatus = "completed"
	TransactionStatusCanceled  TransactionStatus = "canceled"
)

type Vultr

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

func NewVultr

func NewVultr(opts ...VultrOption) (*Vultr, error)

func (*Vultr) GetCurrentOfferings

func (v *Vultr) GetCurrentOfferings() ([]Offering, error)

func (*Vultr) GetServer

func (v *Vultr) GetServer(serverId string) (Server, error)

func (*Vultr) GetTransaction

func (v *Vultr) GetTransaction(id string) (Transaction, error)

func (*Vultr) OrderServer

func (v *Vultr) OrderServer(order Order) (Transaction, error)

func (*Vultr) Slug

func (v *Vultr) Slug() string

type VultrOption

type VultrOption func(*Vultr) error

func WithVultrClient

func WithVultrClient(client *govultr.Client) VultrOption

Jump to

Keyboard shortcuts

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