packet

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package packet implements a client to the Equinix Metal API.

Index

Constants

View Source
const (

	// DefaultLocalASN sets the Local ASN for BGP to our default of 65000.
	DefaultLocalASN = 65000
)

Variables

View Source
var (

	// ErrControlPlanEndpointNotFound is returned when the control plane endpoint is not found.
	ErrControlPlanEndpointNotFound = errors.New("control plane not found")
	// ErrElasticIPQuotaExceeded is returned when the quota for elastic IPs is exceeded.
	ErrElasticIPQuotaExceeded = errors.New("could not create an Elastic IP due to quota limits on the account, please contact Equinix Metal support")
	// ErrInvalidIP is returned when the IP is invalid.
	ErrInvalidIP = errors.New("invalid IP")
	// ErrMissingEnvVar is returned when a required environment variable is missing.
	ErrMissingEnvVar = errors.New("missing required env var")
	// ErrInvalidRequest is returned when the request is invalid.
	ErrInvalidRequest = errors.New("invalid request")
)

Functions

func DefaultCreateTags added in v0.5.0

func DefaultCreateTags(namespace, name, clusterName string) []string

DefaultCreateTags returns the default tags for an Equinix Metal resource.

func GenerateClusterTag

func GenerateClusterTag(clusterName string) string

GenerateClusterTag generates a tag for a cluster.

func GenerateMachineNameTag added in v0.5.0

func GenerateMachineNameTag(name string) string

GenerateMachineNameTag generates a tag for a machine.

func GenerateNamespaceTag added in v0.5.0

func GenerateNamespaceTag(namespace string) string

GenerateNamespaceTag generates a tag for a namespace.

func ItemsInList

func ItemsInList(list []string, items []string) bool

ItemsInList checks if all items are in the list.

Types

type Client added in v0.5.0

type Client struct {
	*metal.APIClient
}

Client is a wrapper around the Equinix Metal API client.

func GetClient

func GetClient() (*Client, error)

GetClient returns a new Equinix Metal client.

func NewClient

func NewClient(packetAPIKey string) *Client

NewClient creates a new Client for the given Packet credentials.

func (*Client) CreateIP added in v0.5.0

func (p *Client) CreateIP(ctx context.Context, _, clusterName, projectID, facility, metro string) (net.IP, error)

CreateIP reserves an IP via Packet API. The request fails straight if no IP are available for the specified project. This prevent the cluster to become ready.

func (*Client) EnableProjectBGP added in v0.6.0

func (p *Client) EnableProjectBGP(ctx context.Context, projectID string) error

EnableProjectBGP enables bgp on the project.

func (*Client) EnsureNodeBGPEnabled added in v0.6.0

func (p *Client) EnsureNodeBGPEnabled(ctx context.Context, id string) error

EnsureNodeBGPEnabled check if the node has bgp enabled, and set it if it does not.

func (*Client) GetDevice added in v0.5.0

func (p *Client) GetDevice(ctx context.Context, deviceID string) (*metal.Device, *http.Response, error)

GetDevice returns the device with the given ID.

func (*Client) GetDeviceAddresses added in v0.5.0

func (p *Client) GetDeviceAddresses(device *metal.Device) []corev1.NodeAddress

GetDeviceAddresses returns the addresses of the device.

func (*Client) GetDeviceByTags added in v0.5.0

func (p *Client) GetDeviceByTags(ctx context.Context, project string, tags []string) (*metal.Device, error)

GetDeviceByTags returns the first device that matches all of the tags.

func (*Client) GetIPByClusterIdentifier added in v0.5.0

func (p *Client) GetIPByClusterIdentifier(ctx context.Context, _, name, projectID string) (*metal.IPReservation, error)

GetIPByClusterIdentifier returns the IP reservation for the given cluster identifier.

func (*Client) NewDevice added in v0.5.0

func (p *Client) NewDevice(ctx context.Context, req CreateDeviceRequest) (*metal.Device, error)

NewDevice creates a new device.

type CreateDeviceRequest

type CreateDeviceRequest struct {
	ExtraTags            []string
	MachineScope         *scope.MachineScope
	ControlPlaneEndpoint string
}

CreateDeviceRequest is an object representing the API request to create a Device.

Directories

Path Synopsis
Package scope contains the scope interfaces for the Packet provider.
Package scope contains the scope interfaces for the Packet provider.

Jump to

Keyboard shortcuts

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