infrastructure

package
v0.0.0-...-1bdfbe6 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2022 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ServerSSHPort  = 22
	ServerRootUser = "root"
)
View Source
const ElevenConfigFileName = "config.json"
View Source
const (
	ServerImage = "ubuntu-22.04"
)

Variables

View Source
var (
	ErrElevenConfigNotFound = errors.New("ErrElevenConfigNotFound")
)
View Source
var (
	ErrInvalidServerType = errors.New("ErrInvalidServerType")
)

Functions

func CloseServerPort

func CloseServerPort(
	hetznerClient *hcloud.Client,
	firewallID int,
	portToClose string,
) error

func CreateElevenConfigStorage

func CreateElevenConfigStorage(
	elevenConfigDir string,
	apiToken string,
	region string,
) error

func DetachFirewallFromServer

func DetachFirewallFromServer(
	hetznerClient *hcloud.Client,
	firewallID int,
	serverID int,
) error

func LookupElevenConfig

func LookupElevenConfig(
	elevenConfigDir string,
	apiToken string,
	region string,
) (string, error)

func OpenServerPort

func OpenServerPort(
	hetznerClient *hcloud.Client,
	firewallID int,
	portToOpen string,
) error

func RemoveElevenConfig

func RemoveElevenConfig(
	elevenConfigDir string,
	apiToken string,
	region string,
) error

func RemoveFirewall

func RemoveFirewall(
	hetznerClient *hcloud.Client,
	firewallID int,
) error

func RemoveNetwork

func RemoveNetwork(
	hetznerClient *hcloud.Client,
	networkID int,
) error

func RemoveSSHKey

func RemoveSSHKey(
	hetznerClient *hcloud.Client,
	sshKeyID int,
) error

func RemoveServer

func RemoveServer(
	hetznerClient *hcloud.Client,
	serverID int,
) error

func SaveElevenConfig

func SaveElevenConfig(
	elevenConfigDir string,
	apiToken string,
	region string,
	configJSON []byte,
) error

func WaitForSSHAvailableInServer

func WaitForSSHAvailableInServer(
	serverPublicIPAddress string,
	serverSSHPort string,
) (returnedError error)

Types

type Firewall

type Firewall struct {
	ID               int  `json:"id"`
	AttachedToServer bool `json:"attached_to_server"`
}

func CreateFirewall

func CreateFirewall(
	hetznerClient *hcloud.Client,
	name string,
	rules []hcloud.FirewallRule,
) (returnedFirewall *Firewall, returnedError error)

type InitServerScriptResults

type InitServerScriptResults struct {
	ExitCode    string                   `json:"exit_code"`
	SSHHostKeys []entities.EnvSSHHostKey `json:"ssh_host_keys"`
}

func LookupServerInitScriptResults

func LookupServerInitScriptResults(
	serverPublicIPAddress string,
	serverSSHPort string,
	serverLoginUser string,
	sshPrivateKeyContent string,
) (returnedInitScriptResults *InitServerScriptResults, returnedError error)

type Location

type Location struct {
	ID          int                `json:"id"`
	Name        string             `json:"name"`
	NetworkZone hcloud.NetworkZone `json:"network_zone"`
}

func LookupLocation

func LookupLocation(
	hetznerClient *hcloud.Client,
	name string,
) (returnedLocation *Location, returnedError error)

type Network

type Network struct {
	ID int `json:"id"`
}

func CreateNetwork

func CreateNetwork(
	hetznerClient *hcloud.Client,
	name string,
	cidrBlock string,
	subnetCIDRBlock string,
	networkZone hcloud.NetworkZone,
) (returnedNetwork *Network, returnedError error)

type RawInitServerScriptResults

type RawInitServerScriptResults struct {
	ExitCode      string `json:"exit_code"`
	SSHHostKeys   string `json:"ssh_host_keys"`
	CloudInitLogs string `json:"cloud_init_logs"`
}

type SSHKey

type SSHKey struct {
	ID         int    `json:"id"`
	Name       string `json:"name"`
	PEMContent string `json:"pem_content"`
}

func CreateSSHKey

func CreateSSHKey(
	hetznerClient *hcloud.Client,
	name string,
) (returnedSSHKey *SSHKey, returnedError error)

type Server

type Server struct {
	ID                int                      `json:"id"`
	Type              string                   `json:"type"`
	PublicIPAddress   string                   `json:"tmp_public_ip_address"`
	InitScriptResults *InitServerScriptResults `json:"init_script_results"`
}

func CreateServer

func CreateServer(
	hetznerClient *hcloud.Client,
	locationID int,
	networkID int,
	serverType string,
	firewallID int,
	name string,
	sshKeyID int,
) (returnedServer *Server, returnedError error)

type ServerTypeInfos

type ServerTypeInfos struct {
	ID   int    `json:"id"`
	Name string `json:"name"`
}

func LookupServerTypeInfos

func LookupServerTypeInfos(
	hetznerClient *hcloud.Client,
	serverTypeName string,
	locationName string,
) (returnedServerTypeInfos *ServerTypeInfos, returnedError error)

Jump to

Keyboard shortcuts

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