clients

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2023 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Overview

Package clients contains common logic and data structures for the supported cloud providers.

Package ec2 is a thin wrapper around the EC2 Client. Along with that it provides a few additions, like grabbing the instance IDs that have a predefined tag which we use to identify resources.

Index

Constants

View Source
const (
	TypeEC2 string = "ec2"
	TypeRDS string = "rds"
)
View Source
const (
	StatusStopped string = "STOPPED"
	StatusRunning string = "RUNNING"
	StatusPending string = "PENDING"
)
View Source
const StatusAvailable = "available"

Variables

This section is empty.

Functions

func GetUniqueTags

func GetUniqueTags() (map[string]bool, error)

GetUniqueTags makes a call through the EC2 client to collect all instance tags and returns a set of them

Types

type ClientCache

type ClientCache struct {
	Client client.Client
	Cache  cache.Cache
}

ClientCache holds the client and cache objects.

func GetClient

func GetClient() (ClientCache, error)

GetClient returns a ready to use kubernetes client and cache.

type CloudResource

type CloudResource interface {
	Start(startInput ResourceStartInput) error
	Stop(stopInput ResourceStopInput) error
	Status() (ResourceStatusOutput, error)
}

CloudResource provides generic Resource interface. A Resource is a group of instances which can be started or stopped. The interface also requires a method to list their statuses.

func ResourceFactory

func ResourceFactory(resType, tag string) (CloudResource, error)

ResourceFactory generates structs that abide by the CloudResource interface. The returned struct can start, stop, and list instances. Each new integration needso to be added to this factory function.

type EC2Monitor

type EC2Monitor struct {
	Type string
}

func (*EC2Monitor) GetNewResources

func (m *EC2Monitor) GetNewResources(clusterResources map[string]bool) ([]string, error)

GetNewResources compares the local cluster resources with the ones returned from EC2 and gives back a list of resources that need to be created on the cluster.

type EC2Resource

type EC2Resource struct {
	NameTag string
}

Resource represents a collection of EC2 instances grouped by a common "resource-booking/application" tag.

func (*EC2Resource) Start

func (r *EC2Resource) Start(startInput ResourceStartInput) error

Start makes a call through the EC2 client to start resource instances by their IDs.

func (*EC2Resource) Status

func (r *EC2Resource) Status() (ResourceStatusOutput, error)

Status returns the current summary of a given resource instance statuses. It makes a call through the EC2 client with a given set of instance IDs and summarises their status (active vs running).

func (*EC2Resource) Stop

func (r *EC2Resource) Stop(stopInput ResourceStopInput) error

Stop makes a call through the EC2 client to stop the instances that belong to the resource.

type RDSInstanceDetails

type RDSInstanceDetails struct {
	IDs           []*string
	Tags          map[string]string
	ResourceNames []*string
}

type RDSMonitor

type RDSMonitor struct {
	Type string
}

func (*RDSMonitor) GetNewResources

func (m *RDSMonitor) GetNewResources(clusterResources map[string]bool) ([]string, error)

type RDSResource

type RDSResource struct {
	NameTag string
}

func (*RDSResource) Start

func (r *RDSResource) Start(startInput ResourceStartInput) error

func (*RDSResource) Status

func (r *RDSResource) Status() (ResourceStatusOutput, error)

func (*RDSResource) Stop

func (r *RDSResource) Stop(stopInput ResourceStopInput) error

type ResourceMonitor

type ResourceMonitor interface {
	GetNewResources(clusterResources map[string]bool) ([]string, error)
}

func MonitorFactory

func MonitorFactory(monitorType string) (ResourceMonitor, error)

MonitorFactory generates structs that abide by the ResourceMonitor interface. The returned struct can get new resources of the specified type. Each new integration needso to be added to this factory function.

type ResourceStartInput

type ResourceStartInput struct {
	UID, EndAt string
}

ResourceStartInput stores data that is used for book-keeping during the starting of the resource

type ResourceStatusOutput

type ResourceStatusOutput struct {
	Available, Running    int
	LockedBy, LockedUntil string
}

ResourceStatusOutput holds the status summary of the resource.

type ResourceStopInput

type ResourceStopInput struct {
	UID string
}

ResourceStartInput stores data that is used for book-keeping during the stopping of the resource

Jump to

Keyboard shortcuts

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