k8ssdk

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2019 License: MIT Imports: 15 Imported by: 1

README

k8ssdk

Brightbox API SDK for kubernetes applications

Documentation

Index

Constants

View Source
const (
	LbActive   = "active"
	LbCreating = "creating"

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

Variables

This section is empty.

Functions

func ClearAuthEnvUsername

func ClearAuthEnvUsername()

func ErrorIfAcmeNotComplete

func ErrorIfAcmeNotComplete(acme *brightbox.LoadBalancerAcme) error

func ErrorIfNotComplete

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

func ErrorIfNotErased

func ErrorIfNotErased(lb *brightbox.LoadBalancer) error

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)

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)

Firewall Policy

func (*Cloud) CreateFirewallRule

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

Firewall Rules

func (*Cloud) CreateLoadBalancer

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

func (*Cloud) CreateServer

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

func (*Cloud) CreateServerGroup

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

func (*Cloud) DestroyCloudIP

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

func (*Cloud) DestroyCloudIPs

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

Destroy CloudIPs matching 'name' from a supplied list of cloudIPs

func (*Cloud) DestroyFirewallPolicy

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

func (*Cloud) DestroyLoadBalancer

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

func (*Cloud) DestroyServer

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

func (*Cloud) DestroyServerGroup

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

func (*Cloud) EnsureMappedCloudIP

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

func (*Cloud) EnsureOldCloudIPsDeposed

func (c *Cloud) EnsureOldCloudIPsDeposed(lb *brightbox.LoadBalancer, cip *brightbox.CloudIP, name string) error

EnsureOldCloudIPsDeposed unmaps any CloudIPs mapped to the loadbalancer that are not the allocated cloud ip.

func (*Cloud) GetCloudIPs

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

func (*Cloud) GetFirewallPolicyByName

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

get a FirewallPolicy By Name

func (*Cloud) GetLoadBalancerById

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

func (*Cloud) GetLoadBalancerByName

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

func (*Cloud) GetServer

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

func (*Cloud) GetServerGroup

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

func (*Cloud) GetServerGroupByName

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

get a serverGroup By Name

func (*Cloud) GetServerGroups

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

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)

func (*Cloud) UpdateLoadBalancer

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

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
}

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