cloud

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2023 License: GPL-3.0 Imports: 35 Imported by: 3

Documentation

Index

Constants

View Source
const (
	StateRunning = InstanceState(0)
	StateStopped = InstanceState(1)
	StatePending = InstanceState(2)
	StateUnknown = InstanceState(3)
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AWSComputeProperties

type AWSComputeProperties struct {
	FilterTags map[string]string
}

type AWSStorageProperties

type AWSStorageProperties struct {
	Region string

	// size of block when uploading
	// blocks to a blob concurrently
	BlockSize int64

	// Concurrency
	UploadConcurrency   int
	DownloadConcurrency int
}

type AzureStorageProperties

type AzureStorageProperties struct {

	// size of block when
	// appending to a blob
	AppendBlockSize int
	// size of block when uploading
	// blocks to a blob concurrently
	PutBlockSize int64
}

type Compute

type Compute interface {

	// Properties that customize the behavior of
	// the Compute API such as search filters.
	SetProperties(props interface{})

	// Retreives a compute instance.
	GetInstance(name string) (ComputeInstance, error)

	// Retrieves instances having the given ids
	GetInstances(ids []string) ([]ComputeInstance, error)

	// Returns a list of all compute instances
	// within this cloud compute context
	ListInstances() ([]ComputeInstance, error)
}

interface for a cloud compute abstraction

func NewAWSCompute

func NewAWSCompute(
	session *session.Session,
) (Compute, error)

func NewAzureCompute

func NewAzureCompute(
	ctx context.Context,
	clientCreds *azidentity.ClientSecretCredential,
	clientOpts *arm.ClientOptions,
	resourceGroupName,
	locationName,
	subscriptionID string,
) (Compute, error)

func NewGoogleCompute

func NewGoogleCompute(
	service *compute.Service,
	projectID string,
	region string,
) (Compute, error)

type ComputeInstance

type ComputeInstance interface {
	ID() string
	Name() string
	PublicIP() string
	PublicDNS() string

	// Returns the instance's run state
	State() (InstanceState, error)

	// Start the instance.
	Start() error

	// Restart the instance
	Restart() error

	// Stop the instance
	Stop() error

	// Tests connectivity on a
	// given TCP port accepts
	CanConnect(port int) bool
}

type GoogleComputeProperties

type GoogleComputeProperties struct {
	Region,
	Zone string

	// timeout for start/stop operations
	OpTimeout time.Duration

	FilterLabels map[string]string
}

type GoogleStorageProperties

type GoogleStorageProperties struct {
	Region string

	// size of block when uploading
	// blocks to a blob concurrently
	BlockSize int
}

type InstanceState

type InstanceState int

instance states

func (InstanceState) String

func (s InstanceState) String() string

type Storage

type Storage interface {
	SetProperties(props interface{})

	// Creates a storage instance. In the case of AWS S3
	// or Google cloud storage this will be a bucket. For
	// Azure this would be a blob container.
	NewInstance(name string) (StorageInstance, error)

	// Returns a list of all storage instance within
	// this cloud storage context
	ListInstances() ([]StorageInstance, error)
}

interface for a cloud object store abstraction

func NewAWSStorage

func NewAWSStorage(
	session *session.Session,
	region string,
) (Storage, error)

func NewAzureStorage

func NewAzureStorage(
	ctx context.Context,
	clientCreds *azidentity.ClientSecretCredential,
	clientOpts *arm.ClientOptions,
	storageAccountName,
	resourceGroupName,
	locationName,
	subscriptionID,
	servicePrincipalID string,
) (Storage, error)

func NewGoogleStorage

func NewGoogleStorage(
	ctx context.Context,
	client *storage.Client,
	projectID,
	region string,
) (Storage, error)

type StorageInstance

type StorageInstance interface {
	Name() string
	Delete() error

	ListObjects(path string) ([]string, error)
	DeleteObject(path string) error

	Upload(name, contentType string, data io.Reader, size int64) error
	UploadFile(name, contentType, path string) error

	Download(name string, data io.Writer) error
	DownloadFile(name, path string) error
}

Jump to

Keyboard shortcuts

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