node

package
v0.0.0-...-249e25c Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2025 License: AGPL-3.0 Imports: 39 Imported by: 0

Documentation

Overview

Package node ...

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsPublicIP

func IsPublicIP(addr string) bool

func ValidRegion

func ValidRegion(region string, regions []*Region) bool

func ValidSKU

func ValidSKU(skuName string, skus []*SKU) bool

Types

type BillingType

type BillingType string
const (
	Monthly BillingType = "monthly"
	Hourly  BillingType = "hourly"
	Custom  BillingType = "custom"
)

type CreateRequest

type CreateRequest struct {
	User   string
	IPV4   string
	Name   string
	Region string
	SKU    string
	SSHKey string
	// hourly(0) | monthly(1)
	BillingType BillingType
	Spot        bool
}

CreateRequest ...

type CustomDriver

type CustomDriver struct{}

func NewCustomDriver

func NewCustomDriver() *CustomDriver

func (*CustomDriver) Create

func (d *CustomDriver) Create(ctx context.Context, req *CreateRequest) (*Node, error)

func (*CustomDriver) DefaultUser

func (d *CustomDriver) DefaultUser() string

func (*CustomDriver) Delete

func (d *CustomDriver) Delete(ctx context.Context, req *DeleteRequest) error

func (*CustomDriver) List

func (d *CustomDriver) List(ctx context.Context, req *ListRequest) ([]*Node, error)

func (*CustomDriver) Provider

func (d *CustomDriver) Provider() string

Provider ...

func (*CustomDriver) Regions

func (d *CustomDriver) Regions(ctx context.Context, req *RegionsRequest) ([]*Region, error)

func (*CustomDriver) SKUs

func (d *CustomDriver) SKUs(ctx context.Context, req *SKUsRequest) ([]*SKU, error)

type DeleteRequest

type DeleteRequest struct {
	Region     string
	ProviderID string
}

DeleteRequest ...

type DigitalOceanDriver

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

DigitalOceanDriver ...

func NewDigitalOceanDriver

func NewDigitalOceanDriver(token string) *DigitalOceanDriver

NewDigitalOceanDriver ...

func (*DigitalOceanDriver) Create

func (d *DigitalOceanDriver) Create(ctx context.Context, req *CreateRequest) (*Node, error)

Create ...

func (*DigitalOceanDriver) DefaultUser

func (d *DigitalOceanDriver) DefaultUser() string

func (*DigitalOceanDriver) Delete

func (d *DigitalOceanDriver) Delete(ctx context.Context, req *DeleteRequest) error

Delete ...

func (*DigitalOceanDriver) List

func (d *DigitalOceanDriver) List(ctx context.Context, req *ListRequest) ([]*Node, error)

List ...

func (*DigitalOceanDriver) Provider

func (d *DigitalOceanDriver) Provider() string

Provider ...

func (*DigitalOceanDriver) Regions

func (d *DigitalOceanDriver) Regions(ctx context.Context, req *RegionsRequest) ([]*Region, error)

Regions ...

func (*DigitalOceanDriver) SKUs

func (d *DigitalOceanDriver) SKUs(ctx context.Context, req *SKUsRequest) ([]*SKU, error)

SKUs ...

type DreamHostDriver

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

DreamHostDriver ...

func NewDreamHostDriver

func NewDreamHostDriver(tenantID, tenantName, username, password string) (*DreamHostDriver, error)

NewDreamHostDriver ...

func (*DreamHostDriver) Create

func (d *DreamHostDriver) Create(ctx context.Context, req *CreateRequest) (*Node, error)

Create ...

func (*DreamHostDriver) DefaultUser

func (d *DreamHostDriver) DefaultUser() string

func (*DreamHostDriver) Delete

func (d *DreamHostDriver) Delete(ctx context.Context, req *DeleteRequest) error

Delete ...

func (*DreamHostDriver) List

func (d *DreamHostDriver) List(ctx context.Context, req *ListRequest) ([]*Node, error)

List ...

func (*DreamHostDriver) Provider

func (d *DreamHostDriver) Provider() string

Provider ...

func (*DreamHostDriver) Regions

func (d *DreamHostDriver) Regions(ctx context.Context, req *RegionsRequest) ([]*Region, error)

Regions ...

func (*DreamHostDriver) SKUs

func (d *DreamHostDriver) SKUs(ctx context.Context, req *SKUsRequest) ([]*SKU, error)

SKUs ...

type Driver

type Driver interface {
	// Provider returns the name of the current provider configured
	Provider() string
	// Regions provides a list of available regions for the current credentials
	Regions(ctx context.Context, req *RegionsRequest) ([]*Region, error)
	// SKUs returns a list of available machine specs and prices
	SKUs(ctx context.Context, req *SKUsRequest) ([]*SKU, error)
	// Create provisions a new Node on the provider's service
	Create(ctx context.Context, req *CreateRequest) (*Node, error)
	// List returns existing nodes for the provider
	List(ctx context.Context, req *ListRequest) ([]*Node, error)
	// Delete allows for shutting down and deleting of a node
	Delete(ctx context.Context, req *DeleteRequest) error
	// DefaultUser returns the user allowed for connection and operations
	DefaultUser() string
}

A Driver is defines the implementation of a third party driver such as DigitalOcean. The driver is used to facilitate provisioning and tearing down resources.

type GCPDriver

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

func NewGCPDriver

func NewGCPDriver(credentials []byte) (*GCPDriver, error)

func (*GCPDriver) Create

func (d *GCPDriver) Create(ctx context.Context, req *CreateRequest) (*Node, error)

func (*GCPDriver) DefaultUser

func (d *GCPDriver) DefaultUser() string

func (*GCPDriver) Delete

func (d *GCPDriver) Delete(ctx context.Context, req *DeleteRequest) error

func (*GCPDriver) List

func (d *GCPDriver) List(ctx context.Context, req *ListRequest) ([]*Node, error)

func (*GCPDriver) Provider

func (d *GCPDriver) Provider() string

func (*GCPDriver) Regions

func (d *GCPDriver) Regions(ctx context.Context, req *RegionsRequest) ([]*Region, error)

TODO: add long/lat to this

func (*GCPDriver) SKUs

func (d *GCPDriver) SKUs(ctx context.Context, req *SKUsRequest) ([]*SKU, error)

type HeficedDriver

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

HeficedDriver is a node driver which implements the Driver interface for the Heficed provider. More information can be found in the API docs. https://api.heficed.com/docs/swagger.html

func NewHeficedDriver

func NewHeficedDriver(clientID, clientSecret, tenantID string) (*HeficedDriver, error)

NewHeficedDriver creates a HeficedDriver from oauth credentials. It uses the `oauth2` package and requires ["kronoscloud, "sshkeys"] scope. An error is returned if there is a problem creating the oauth token, or there is no provided `tenantID`.

func (*HeficedDriver) Create

func (d *HeficedDriver) Create(ctx context.Context, req *CreateRequest) (*Node, error)

Create provisions a new node based on the name which matches the spec definition in `heficedSpecsAlacart`. If the ssh public key provided in the request is not already existing, a new key entry is added. The order is then placed and waits for the machine to have an "running" status. An error is returned if there is a problem finding the template, finding or adding the ssh key, or placing the order.

func (*HeficedDriver) DefaultUser

func (d *HeficedDriver) DefaultUser() string

DefaultUser used to log into the instances

func (*HeficedDriver) Delete

func (d *HeficedDriver) Delete(ctx context.Context, req *DeleteRequest) error

Delete force stops the instance ID from the request, then cancels the instance immediately rather than at the end of the billing period.

func (*HeficedDriver) List

func (d *HeficedDriver) List(ctx context.Context, req *ListRequest) ([]*Node, error)

List returns a list of Node that current have a status of "running".

func (*HeficedDriver) Provider

func (d *HeficedDriver) Provider() string

Provider returns the driver's provider name

func (*HeficedDriver) Regions

func (d *HeficedDriver) Regions(ctx context.Context, req *RegionsRequest) ([]*Region, error)

Regions returns a list of available regions for the current credentials

func (*HeficedDriver) SKUs

func (d *HeficedDriver) SKUs(ctx context.Context, req *SKUsRequest) ([]*SKU, error)

SKUs queries a list of templates and creates a set of machine sizes from predefined specs in `heficed.go`. The templates are determined by region provided in the `SKUsRequest` and quotes for each 'order' built are requested and added on to the resulting SKU.

type HetznerDriver

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

HetznerDriver ...

func NewHetznerDriver

func NewHetznerDriver(token string) *HetznerDriver

NewHetznerDriver ...

func (*HetznerDriver) Create

func (d *HetznerDriver) Create(ctx context.Context, req *CreateRequest) (*Node, error)

Create ...

func (*HetznerDriver) DefaultUser

func (d *HetznerDriver) DefaultUser() string

func (*HetznerDriver) Delete

func (d *HetznerDriver) Delete(ctx context.Context, req *DeleteRequest) error

Delete ...

func (*HetznerDriver) List

func (d *HetznerDriver) List(ctx context.Context, req *ListRequest) ([]*Node, error)

List ...

func (*HetznerDriver) Provider

func (d *HetznerDriver) Provider() string

Provider ...

func (*HetznerDriver) Regions

func (d *HetznerDriver) Regions(ctx context.Context, req *RegionsRequest) ([]*Region, error)

Regions ...

func (*HetznerDriver) SKUs

func (d *HetznerDriver) SKUs(ctx context.Context, req *SKUsRequest) ([]*SKU, error)

SKUs ...

type ListRequest

type ListRequest struct{}

ListRequest ...

type Networks

type Networks struct {
	V4 []string `json:"v4,omitempty"`
	V6 []string `json:"v6,omitempty"`
}

Networks represents the Node's networks.

type Node

type Node struct {
	User             string    `json:"user,omitempty"`
	Driver           string    `json:"driver,omitempty"`
	ProviderName     string    `json:"provider_name,omitempty"`
	ProviderID       string    `json:"provider_id,omitempty"`
	Name             string    `json:"name,omitempty"`
	Memory           int       `json:"memory,omitempty"`
	CPUs             int       `json:"vcpus,omitempty"`
	Disk             int       `json:"disk,omitempty"`
	Networks         *Networks `json:"networks,omitempty"`
	Status           bool      `json:"status,omitempty"`
	Region           *Region   `json:"region,omitempty"`
	SKU              *SKU      `json:"sku,omitempty"`
	WireguardPrivKey string    `json:"wireguard_priv_key,omitempty"`
	WireguardIPv4    string    `json:"wireguard_ipv4,omitempty"`
	StartedAt        int64     `json:"started_at,omitempty"`
	StoppedAt        int64     `json:"stopped_at,omitempty"`
	Type             NodeType  `json:"node_type,omitempty"`
}

Node represents a host

type NodeType

type NodeType string
const (
	TypeWorker     NodeType = "worker"
	TypeController NodeType = "controller"
)

func (*NodeType) Set

func (t *NodeType) Set(v string) error

Set must have pointer receiver so it doesn't change the value of a copy

func (*NodeType) String

func (t *NodeType) String() string

String is used both by fmt.Print and by Cobra in help text

func (*NodeType) Type

func (t *NodeType) Type() string

Type is only used in help text

type OVHDriver

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

OVHDriver ...

func NewOVHDriver

func NewOVHDriver(region, appKey, appSecret, consumerKey, projectID string) (*OVHDriver, error)

NewOVHDriver ...

func (*OVHDriver) Create

func (d *OVHDriver) Create(ctx context.Context, req *CreateRequest) (*Node, error)

Create ...

func (*OVHDriver) DefaultUser

func (d *OVHDriver) DefaultUser() string

func (*OVHDriver) Delete

func (d *OVHDriver) Delete(ctx context.Context, req *DeleteRequest) error

Delete ...

func (*OVHDriver) List

func (d *OVHDriver) List(ctx context.Context, req *ListRequest) ([]*Node, error)

List ...

func (*OVHDriver) Provider

func (d *OVHDriver) Provider() string

Provider ...

func (*OVHDriver) Regions

func (d *OVHDriver) Regions(ctx context.Context, req *RegionsRequest) ([]*Region, error)

Regions ...

func (*OVHDriver) SKUs

func (d *OVHDriver) SKUs(ctx context.Context, req *SKUsRequest) ([]*SKU, error)

SKUs ...

type Price

type Price struct {
	Value    float64
	Currency string
}

Price ...

type Region

type Region struct {
	Name   string
	City   string
	LatLng s2.LatLng
}

Region represents the Node's datacenter location

type Regions

type Regions []*Region

Regions ...

func (*Regions) FindByName

func (r *Regions) FindByName(name string) *Region

type RegionsRequest

type RegionsRequest struct{}

RegionsRequest ...

type SKU

type SKU struct {
	Name         string
	CPUs         int
	Memory       int
	Disk         int
	NetworkCap   int
	NetworkSpeed int
	PriceMonthly *Price
	PriceHourly  *Price
}

SKU ...

type SKUsRequest

type SKUsRequest struct {
	Region string
}

SKUsRequest ...

type ScalewayDriver

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

ScalewayDriver ...

func NewScalewayDriver

func NewScalewayDriver(organizationID, accessKey, secretKey string) (*ScalewayDriver, error)

NewScalewayDriver ...

func (*ScalewayDriver) Create

func (d *ScalewayDriver) Create(ctx context.Context, req *CreateRequest) (*Node, error)

Create ...

func (*ScalewayDriver) DefaultUser

func (d *ScalewayDriver) DefaultUser() string

func (*ScalewayDriver) Delete

func (d *ScalewayDriver) Delete(ctx context.Context, req *DeleteRequest) error

Delete ...

func (*ScalewayDriver) List

func (d *ScalewayDriver) List(ctx context.Context, req *ListRequest) ([]*Node, error)

List ...

func (*ScalewayDriver) Provider

func (d *ScalewayDriver) Provider() string

Provider ...

func (*ScalewayDriver) Regions

func (d *ScalewayDriver) Regions(ctx context.Context, req *RegionsRequest) ([]*Region, error)

Regions ...

func (*ScalewayDriver) SKUs

func (d *ScalewayDriver) SKUs(ctx context.Context, req *SKUsRequest) ([]*SKU, error)

SKUs ...

Jump to

Keyboard shortcuts

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