k8ssdk

package module
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2024 License: MIT Imports: 23 Imported by: 1

README

k8ssdk

Brightbox API SDK for kubernetes applications

Documentation

Index

Constants

View Source
const (
	// ProviderName is set to brightobox
	ProviderName = "brightbox"
	// ProviderPrefix is the exported URL prefix including the provider name
	ProviderPrefix = ProviderName + "://"
)
View Source
const (

	// ValidAcmeDomainStatus indicates a valid acme state
	ValidAcmeDomainStatus = "valid"
)

Variables

This section is empty.

Functions

func ClearAuthEnvUsername

func ClearAuthEnvUsername()

ClearAuthEnvUsername removes the username from the environment

func ErrorIfAcmeNotComplete

func ErrorIfAcmeNotComplete(acme *brightbox.LoadBalancerAcme) error

ErrorIfAcmeNotComplete returns an appropriate error if ACME has not yet validated

func ErrorIfNotComplete

func ErrorIfNotComplete(lb *brightbox.LoadBalancer, cipID, name string) error

ErrorIfNotComplete returns an appropriate error if the Load Balancer has not yet built

func ErrorIfNotErased

func ErrorIfNotErased(lb *brightbox.LoadBalancer) error

ErrorIfNotErased returns an appropriate error if the Load Balancer has not been erased

func GetAuthEnvTokenHandler

func GetAuthEnvTokenHandler(t *testing.T) *httptest.Server

GetAuthEnvTokenHandler obtains an HTTP token handler using the auth environment

func IsUpdateLoadBalancerRequired

func IsUpdateLoadBalancerRequired(lb *brightbox.LoadBalancer, newDetails brightbox.LoadBalancerOptions) bool

IsUpdateLoadBalancerRequired checks whether a set of LoadBalancerOptions warrants an API update call.

func MapProviderIDToServerID

func MapProviderIDToServerID(providerID string) string

MapProviderIDToServerID parses the provider id string and return a string that should be a server id Should be no need for error checking here, since the input string is constrained in format by the k8s process

func MapServerIDToProviderID

func MapServerIDToProviderID(serverID string) string

MapServerIDToProviderID adds the provider prefix to the server ID

func MapZoneHandleToRegion

func MapZoneHandleToRegion(zoneHandle string) (string, error)

MapZoneHandleToRegion parses the zone handle and return the embedded region id Zone names are of the form: ${region-name}-${ix} So we look for the last '-' and trim just before that

func ResetAuthEnvironment

func ResetAuthEnvironment()

ResetAuthEnvironment clears the authorisation environment variables

func SetAuthEnvAPIURL

func SetAuthEnvAPIURL(value string)

SetAuthEnvAPIURL sets the APIURL in the environment

func SetAuthEnvAccount

func SetAuthEnvAccount()

SetAuthEnvAccount sets the account id in the environment

func SetAuthEnvClientID

func SetAuthEnvClientID()

SetAuthEnvClientID sets the client id in the environment

func SetAuthEnvPassword

func SetAuthEnvPassword()

SetAuthEnvPassword sets the password in the environment

func SetAuthEnvUsername

func SetAuthEnvUsername()

SetAuthEnvUsername sets the username in the environment

Types

type Cloud

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

Cloud allows access to the Brightbox Cloud and/or any EC2 compatible metadata.

func MakeTestClient

func MakeTestClient(testClient CloudAccess, testMetadata EC2Metadata) *Cloud

MakeTestClient creates a test client

func (*Cloud) AllocateCloudIP

func (c *Cloud) AllocateCloudIP(ctx context.Context, name string) (*brightbox.CloudIP, error)

AllocateCloudIP allocates a new Cloud IP and gives it the name specified

func (*Cloud) CloudClient

func (c *Cloud) CloudClient() (CloudAccess, error)

CloudClient returns the Brightbox Cloud client, or creates a new client from the current environment if one doesn't exist.

func (*Cloud) CreateFirewallPolicy

func (c *Cloud) CreateFirewallPolicy(ctx context.Context, group brightbox.ServerGroup) (*brightbox.FirewallPolicy, error)

CreateFirewallPolicy creates a Firewall Policy

func (*Cloud) CreateFirewallRule

func (c *Cloud) CreateFirewallRule(ctx context.Context, newDetails brightbox.FirewallRuleOptions) (*brightbox.FirewallRule, error)

CreateFirewallRule creates a Firewall Rule

func (*Cloud) CreateLoadBalancer

func (c *Cloud) CreateLoadBalancer(ctx context.Context, newDetails brightbox.LoadBalancerOptions) (*brightbox.LoadBalancer, error)

CreateLoadBalancer creates a LoadBalancer

func (*Cloud) CreateServer

func (c *Cloud) CreateServer(ctx context.Context, newDetails brightbox.ServerOptions) (*brightbox.Server, error)

CreateServer creates a Brightbox Cloud Server

func (*Cloud) CreateServerGroup

func (c *Cloud) CreateServerGroup(ctx context.Context, name string) (*brightbox.ServerGroup, error)

CreateServerGroup creates a Server Group

func (*Cloud) DestroyCloudIP

func (c *Cloud) DestroyCloudIP(ctx context.Context, id string) error

DestroyCloudIP removes a Cloud IP allocation

func (*Cloud) DestroyCloudIPs

func (c *Cloud) DestroyCloudIPs(ctx context.Context, cloudIPList []brightbox.CloudIP, currentIPID string, name string) error

DestroyCloudIPs removes any CloudIPs from a supplied list of cloudIPs that matched 'name', and isn't the current cloudip

func (*Cloud) DestroyFirewallPolicy

func (c *Cloud) DestroyFirewallPolicy(ctx context.Context, id string) error

DestroyFirewallPolicy removes a Firewall Policy

func (*Cloud) DestroyLoadBalancer

func (c *Cloud) DestroyLoadBalancer(ctx context.Context, id string) error

DestroyLoadBalancer removes a Load Balancer

func (*Cloud) DestroyServer

func (c *Cloud) DestroyServer(ctx context.Context, id string) error

DestroyServer removes a Server

func (*Cloud) DestroyServerGroup

func (c *Cloud) DestroyServerGroup(ctx context.Context, id string) error

DestroyServerGroup removes a Server Group

func (*Cloud) EnsureMappedCloudIP

func (c *Cloud) EnsureMappedCloudIP(ctx context.Context, lb *brightbox.LoadBalancer, cip *brightbox.CloudIP) error

EnsureMappedCloudIP checks to make sure the Cloud IP is mapped to the Load Balancer. This function is idempotent.

func (*Cloud) EnsureOldCloudIPsDeposed

func (c *Cloud) EnsureOldCloudIPsDeposed(ctx context.Context, cloudIPList []brightbox.CloudIP, currentIPID string, name string) error

EnsureOldCloudIPsDeposed unmaps any CloudIPs mapped to the loadbalancer that isn't the current cloudip and matches 'name'

func (*Cloud) GetCloudIPs

func (c *Cloud) GetCloudIPs(ctx context.Context) ([]brightbox.CloudIP, error)

GetCloudIPs obtains the list of allocated Cloud IPs

func (*Cloud) GetConfigMap

func (c *Cloud) GetConfigMap(ctx context.Context, identifier string) (*brightbox.ConfigMap, error)

GetConfigMap fetches a Config Map from its ID

func (*Cloud) GetConfigMaps

func (c *Cloud) GetConfigMaps(ctx context.Context) ([]brightbox.ConfigMap, error)

GetConfigMaps obtains the list of Config Maps on the account

func (*Cloud) GetFirewallPolicyByName

func (c *Cloud) GetFirewallPolicyByName(ctx context.Context, name string) (*brightbox.FirewallPolicy, error)

GetFirewallPolicyByName get a FirewallPolicy from its name

func (*Cloud) GetImageByName

func (c *Cloud) GetImageByName(ctx context.Context, name string) (*brightbox.Image, error)

GetImageByName obtains the most recent available image that matches the supplied pattern

func (*Cloud) GetLoadBalancerByID

func (c *Cloud) GetLoadBalancerByID(ctx context.Context, id string) (*brightbox.LoadBalancer, error)

GetLoadBalancerByID finds a Load Balancer from its ID

func (*Cloud) GetLoadBalancerByName

func (c *Cloud) GetLoadBalancerByName(ctx context.Context, name string) (*brightbox.LoadBalancer, error)

GetLoadBalancerByName finds a Load Balancer from its name

func (*Cloud) GetServer

func (c *Cloud) GetServer(ctx context.Context, id string, notFoundError error) (*brightbox.Server, error)

GetServer retrieves a Brightbox Cloud Server

func (*Cloud) GetServerGroup

func (c *Cloud) GetServerGroup(ctx context.Context, identifier string) (*brightbox.ServerGroup, error)

GetServerGroup fetches a Server Group from its ID

func (*Cloud) GetServerGroupByName

func (c *Cloud) GetServerGroupByName(ctx context.Context, name string) (*brightbox.ServerGroup, error)

GetServerGroupByName fetches a Server Group from its name

func (*Cloud) GetServerGroups

func (c *Cloud) GetServerGroups(ctx context.Context) ([]brightbox.ServerGroup, error)

GetServerGroups obtains the list of Server Groups on the account

func (*Cloud) GetServerType

func (c *Cloud) GetServerType(ctx context.Context, identifier string) (*brightbox.ServerType, error)

GetServerType fetches a Server Type from its ID

func (*Cloud) GetServerTypes

func (c *Cloud) GetServerTypes(ctx context.Context) ([]brightbox.ServerType, error)

GetServerTypes obtains the list of Server Types on the account

func (*Cloud) MetadataClient

func (c *Cloud) MetadataClient() (EC2Metadata, error)

MetadataClient returns the EC2 Metadata client, or creates a new client from the default AWS config if one doesn't exist.

func (*Cloud) SyncServerGroup

func (c *Cloud) SyncServerGroup(ctx context.Context, group *brightbox.ServerGroup, newServerIDs []string) (*brightbox.ServerGroup, error)

SyncServerGroup ensures a Brightbox Server Group contains the supplied list of Servers and nothing else

func (*Cloud) UpdateFirewallRule

func (c *Cloud) UpdateFirewallRule(ctx context.Context, newDetails brightbox.FirewallRuleOptions) (*brightbox.FirewallRule, error)

UpdateFirewallRule updates a Firewall Rule

func (*Cloud) UpdateLoadBalancer

func (c *Cloud) UpdateLoadBalancer(ctx context.Context, newDetails brightbox.LoadBalancerOptions) (*brightbox.LoadBalancer, error)

UpdateLoadBalancer updates a LoadBalancer

type CloudAccess

type CloudAccess interface {
	//Fetch a server
	Server(context.Context, string) (*brightbox.Server, error)

	//creates a new server
	CreateServer(context.Context, brightbox.ServerOptions) (*brightbox.Server, error)

	//Fetch a list of LoadBalancers
	LoadBalancers(context.Context) ([]brightbox.LoadBalancer, error)

	//Retrieves a detailed view of one load balancer
	LoadBalancer(context.Context, string) (*brightbox.LoadBalancer, error)

	//Creates a new load balancer
	CreateLoadBalancer(context.Context, brightbox.LoadBalancerOptions) (*brightbox.LoadBalancer, error)

	//Updates an existing load balancer
	UpdateLoadBalancer(context.Context, brightbox.LoadBalancerOptions) (*brightbox.LoadBalancer, error)

	//Retrieves a list of all cloud IPs
	CloudIPs(context.Context) ([]brightbox.CloudIP, error)

	//retrieves a detailed view of one cloud ip
	CloudIP(context.Context, string) (*brightbox.CloudIP, error)

	//Issues a request to map the cloud ip to the destination
	MapCloudIP(context.Context, string, brightbox.CloudIPAttachment) (*brightbox.CloudIP, error)

	//UnMapCloudIP issues a request to unmap the cloud ip
	UnMapCloudIP(context.Context, string) (*brightbox.CloudIP, error)

	//Creates a new Cloud IP
	CreateCloudIP(context.Context, brightbox.CloudIPOptions) (*brightbox.CloudIP, error)

	//adds servers to an existing server group
	AddServersToServerGroup(context.Context, string, brightbox.ServerGroupMemberList) (*brightbox.ServerGroup, error)

	//removes servers from an existing server group
	RemoveServersFromServerGroup(context.Context, string, brightbox.ServerGroupMemberList) (*brightbox.ServerGroup, error)

	// ServerGroups retrieves a list of all server groups
	ServerGroups(context.Context) ([]brightbox.ServerGroup, error)

	//Fetch a server group
	ServerGroup(context.Context, string) (*brightbox.ServerGroup, error)

	//creates a new server group
	CreateServerGroup(context.Context, brightbox.ServerGroupOptions) (*brightbox.ServerGroup, error)

	//creates a new firewall policy
	CreateFirewallPolicy(context.Context, brightbox.FirewallPolicyOptions) (*brightbox.FirewallPolicy, error)

	//creates a new firewall rule
	CreateFirewallRule(context.Context, brightbox.FirewallRuleOptions) (*brightbox.FirewallRule, error)

	//updates an existing firewall rule
	UpdateFirewallRule(context.Context, brightbox.FirewallRuleOptions) (*brightbox.FirewallRule, error)

	//retrieves a list of all firewall policies
	FirewallPolicies(context.Context) ([]brightbox.FirewallPolicy, error)

	// DestroyServer destroys an existing server
	DestroyServer(context.Context, string) (*brightbox.Server, error)

	// DestroyServerGroup destroys an existing server group
	DestroyServerGroup(context.Context, string) (*brightbox.ServerGroup, error)

	// DestroyFirewallPolicy issues a request to destroy the firewall policy
	DestroyFirewallPolicy(context.Context, string) (*brightbox.FirewallPolicy, error)

	// DestroyLoadBalancer issues a request to destroy the load balancer
	DestroyLoadBalancer(context.Context, string) (*brightbox.LoadBalancer, error)

	// DestroyCloudIP issues a request to destroy the cloud ip
	DestroyCloudIP(context.Context, string) (*brightbox.CloudIP, error)

	// ConfigMaps retrieves a list of all config maps
	Images(context.Context) ([]brightbox.Image, error)

	// ConfigMaps retrieves a list of all config maps
	ConfigMaps(context.Context) ([]brightbox.ConfigMap, error)

	// ConfigMap retrieves a detailed view on one config map
	ConfigMap(context.Context, string) (*brightbox.ConfigMap, error)

	// ServerTypes retrieves a list of all server types
	ServerTypes(context.Context) ([]brightbox.ServerType, error)

	// ServerType retrieves a detailed view on one server type
	ServerType(context.Context, string) (*brightbox.ServerType, error)
}

CloudAccess is an abstraction over the Brightbox API to allow testing

type EC2Metadata

type EC2Metadata interface {
	// Query the EC2 metadata service (used to discover instance-id etc)
	GetMetadata(path string) (string, error)
}

EC2Metadata is an abstraction over the AWS metadata service.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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