k8ssdk

package
v0.0.0-...-ae22146 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2024 License: Apache-2.0, MIT Imports: 18 Imported by: 0

README

k8ssdk

Brightbox API SDK for kubernetes applications

Documentation

Index

Constants

View Source
const (
	ProviderName   = "brightbox"
	ProviderPrefix = ProviderName + "://"
)
View Source
const (
	ValidAcmeDomainStatus = "valid"
)

Variables

This section is empty.

Functions

func ClearAuthEnvUsername

func ClearAuthEnvUsername()

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

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

Parse 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

Add the provider prefix to the server ID

func MapZoneHandleToRegion

func MapZoneHandleToRegion(zoneHandle string) (string, error)

Parse 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()

func SetAuthEnvAPIURL

func SetAuthEnvAPIURL(value string)

func SetAuthEnvAccount

func SetAuthEnvAccount()

func SetAuthEnvClientID

func SetAuthEnvClientID()

func SetAuthEnvPassword

func SetAuthEnvPassword()

func SetAuthEnvUsername

func SetAuthEnvUsername()

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

func (*Cloud) AllocateCloudIP

func (c *Cloud) AllocateCloudIP(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(group *brightbox.ServerGroup) (*brightbox.FirewallPolicy, error)

CreateFirewallPolicy creates a Firewall Policy

func (*Cloud) CreateFirewallRule

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

CreateFirewallRule creates a Firewall Rule

func (*Cloud) CreateLoadBalancer

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

CreateLoadBalancer creates a LoadBalancer

func (*Cloud) CreateServer

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

CreateServer creates a Brightbox Cloud Server

func (*Cloud) CreateServerGroup

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

CreateServerGroup creates a Server Group

func (*Cloud) DestroyCloudIP

func (c *Cloud) DestroyCloudIP(id string) error

DestroyCloudIP removes a Cloud IP allocation

func (*Cloud) DestroyCloudIPs

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

DestroyCloudIPs matching 'name' from a supplied list of cloudIPs

func (*Cloud) DestroyFirewallPolicy

func (c *Cloud) DestroyFirewallPolicy(id string) error

DestroyFirewallPolicy removes a Firewall Policy

func (*Cloud) DestroyLoadBalancer

func (c *Cloud) DestroyLoadBalancer(id string) error

DestroyLoadBalancer removes a Load Balancer

func (*Cloud) DestroyServer

func (c *Cloud) DestroyServer(id string) error

DestroyServer removes a Server

func (*Cloud) DestroyServerGroup

func (c *Cloud) DestroyServerGroup(id string) error

DestroyServerGroup removes a Server Group

func (*Cloud) EnsureMappedCloudIP

func (c *Cloud) EnsureMappedCloudIP(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(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() ([]brightbox.CloudIP, error)

GetCloudIPs obtains the list of allocated Cloud IPs

func (*Cloud) GetConfigMap

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

GetConfigMap fetches a Config Map from its ID

func (*Cloud) GetConfigMaps

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

GetConfigMaps obtains the list of Config Maps on the account

func (*Cloud) GetFirewallPolicyByName

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

GetFirewallPolicyByName get a FirewallPolicy from its name

func (*Cloud) GetImageByName

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

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

func (*Cloud) GetLoadBalancerByID

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

GetLoadBalancerByID finds a Load Balancer from its ID

func (*Cloud) GetLoadBalancerByName

func (c *Cloud) GetLoadBalancerByName(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(identifier string) (*brightbox.ServerGroup, error)

GetServerGroup fetches a Server Group from its ID

func (*Cloud) GetServerGroupByName

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

GetServerGroupByName fetches a Server Group from its name

func (*Cloud) GetServerGroups

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

GetServerGroups obtains the list of Server Groups on the account

func (*Cloud) GetServerType

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

GetServerType fetches a Server Type from its ID

func (*Cloud) GetServerTypes

func (c *Cloud) GetServerTypes() ([]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(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(newDetails *brightbox.FirewallRuleOptions) (*brightbox.FirewallRule, error)

UpdateFirewallRule updates a Firewall Rule

func (*Cloud) UpdateLoadBalancer

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

UpdateLoadBalancer updates a LoadBalancer

type CloudAccess

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

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

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

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

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

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

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

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

	//Issues a request to map the cloud ip to the destination
	MapCloudIP(identifier string, destination string) error

	//UnMapCloudIP issues a request to unmap the cloud ip
	UnMapCloudIP(identifier string) error

	//Creates a new Cloud IP
	CreateCloudIP(newCloudIP *brightbox.CloudIPOptions) (*brightbox.CloudIP, error)
	//adds servers to an existing server group
	AddServersToServerGroup(identifier string, serverIds []string) (*brightbox.ServerGroup, error)

	//removes servers from an existing server group
	RemoveServersFromServerGroup(identifier string, serverIds []string) (*brightbox.ServerGroup, error)

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

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

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

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

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

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

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

	// DestroyServer destroys an existing server
	DestroyServer(identifier string) error

	// DestroyServerGroup destroys an existing server group
	DestroyServerGroup(identifier string) error

	// DestroyFirewallPolicy issues a request to destroy the firewall policy
	DestroyFirewallPolicy(identifier string) error

	// DestroyLoadBalancer issues a request to destroy the load balancer
	DestroyLoadBalancer(identifier string) error

	// DestroyCloudIP issues a request to destroy the cloud ip
	DestroyCloudIP(identifier string) error

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

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

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

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

	// ServerType retrieves a detailed view on one server type
	ServerType(identifier 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