Documentation
¶
Overview ¶
Package hetzner wraps the Hetzner Cloud API for provisioning and tearing down the box: a default-deny firewall, an SSH key, and the server itself.
Index ¶
- Constants
- type Catalog
- type Client
- func (h *Client) Create(ctx context.Context, o CreateOpts) (Result, error)
- func (h *Client) Destroy(ctx context.Context, name string) error
- func (h *Client) Exists(ctx context.Context, name string) (bool, error)
- func (h *Client) IsAdopted(ctx context.Context, name string) bool
- func (h *Client) LabelAdopted(ctx context.Context, name string) error
- func (h *Client) ListServers(ctx context.Context) ([]ExistingServer, error)
- func (h *Client) TypeCatalog(ctx context.Context) (*Catalog, error)
- func (h *Client) Validate(ctx context.Context) error
- type CreateOpts
- type ExistingServer
- type Result
- type SizeOption
Constants ¶
const ( GroupDedicated = "Dedicated Resources" ClassCostOptimized = "Cost-Optimized" ClassRegular = "Regular Performance" ClassGeneral = "General Purpose" ArchX86Intel = "x86 (Intel)" ArchX86AMD = "x86 (AMD)" ArchArm = "Arm64 (Ampere)" )
Hetzner's selection hierarchy: Type (Shared/Dedicated) -> Class -> Architecture.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Catalog ¶
type Catalog struct {
// contains filtered or unexported fields
}
Catalog holds every available (type, region) option, classified.
func (*Catalog) All ¶
func (c *Catalog) All() []SizeOption
All returns the full option set (sorted cheapest-first within the same family).
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a thin wrapper around the hcloud client.
func (*Client) Create ¶
Create provisions the server with the firewall attached at create time (so there is never a window with open public ports).
func (*Client) Destroy ¶
Destroy deletes the server and its firewall. Missing resources are ignored. The server delete is async; we wait for it before deleting the firewall, otherwise Hetzner rejects the firewall delete (409, still attached).
func (*Client) LabelAdopted ¶
LabelAdopted tags an adopted server so it is recognizable, with an "adopted" marker so teardown refuses to delete a machine the user owned first.
func (*Client) ListServers ¶
func (h *Client) ListServers(ctx context.Context) ([]ExistingServer, error)
ListServers returns every server in the project.
func (*Client) TypeCatalog ¶
TypeCatalog fetches all server types once and builds the classified option set with per-region net monthly price. No size floor: the cheapest options show too.
type CreateOpts ¶
type CreateOpts struct {
Name string
Region string
ServerType string
WithoutIPv4 bool
UserData string
PublicKeys []string
}
CreateOpts describes the server to create.
type ExistingServer ¶
type ExistingServer struct {
Name, Type, Location, Status, IPv4, IPv6 string
HasIPv4 bool
Managed bool // already pocketdev-managed
}
ExistingServer is a server already in the project, for the adopt path.
type SizeOption ¶
type SizeOption struct {
Type string
Region string // location code, e.g. "nbg1"
City string // e.g. "Nuremberg"
Country string // ISO-3166 alpha-2, e.g. "DE"
Cores int
MemoryGB float32
DiskGB int
Monthly float64 // net monthly price (ex VAT), in Currency
Currency string // account currency, e.g. EUR or USD
Group string // GroupShared | GroupDedicated
Class string // ClassCostOptimized | ClassRegular | ClassGeneral
ArchLabel string // ArchX86Intel | ArchX86AMD | ArchArm
}
SizeOption is one buyable (server type, region) combination, classified into Hetzner's Type -> Class -> Architecture hierarchy.