cloud

package
v0.0.0-...-230cbbc Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2019 License: BSD-2-Clause Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// GcpCredentialsFileKey is the Env variable to store path
	// to service accounts credentials JSON file
	GcpCredentialsFileKey = "GOOGLE_APPLICATION_CREDENTIALS"
)

Variables

View Source
var (
	// ErrPermissionDenied is returned if not enough permissions to perform action
	ErrPermissionDenied = errors.New("permission denied")
)

Functions

This section is empty.

Types

type AllResourceCollection

type AllResourceCollection struct {
	Owner     string
	Instances []Instance
	Images    []Image
	Volumes   []Volume
	Snapshots []Snapshot
	Buckets   []Bucket
}

AllResourceCollection encapsulates collections of all resources, including buckets

type Bucket

type Bucket interface {
	Resource
	LastModified() time.Time
	ObjectCount() int64
	TotalSizeGB() float64
	StorageTypeSizesGB() map[string]float64
}

Bucket represents a bucket in a CSP, such as an S3 bucket in AWS

type CSP

type CSP string

CSP represent a cloud service provider, such as AWS

const (
	// AWS is AWS
	AWS CSP = "AWS"
	// GCP is Google Cloud Platform
	GCP CSP = "GCP"
)

type Image

type Image interface {
	Resource
	Name() string
	SizeGB() int64

	MakePrivate() error
}

Image composes the Resource interface, and descibe an image in any CSP. Such as an AMI in AWS.

type Instance

type Instance interface {
	Resource
	InstanceType() string
}

Instance composes the Resource interface, and descibes an instance in any CSP.

type Resource

type Resource interface {
	CSP() CSP
	Owner() string
	ID() string
	Tags() map[string]string
	Location() string
	Public() bool
	CreationTime() time.Time

	SetTag(key, value string, overwrite bool) error
	RemoveTag(key string) error
	Cleanup() error
}

Resource represents a generic resource in any CSP. It should be concretizised further.

type ResourceCollection

type ResourceCollection struct {
	Owner     string
	Instances []Instance
	Images    []Image
	Volumes   []Volume
	Snapshots []Snapshot
}

ResourceCollection encapsulates collections of multiple resources. Does not include buckets.

type ResourceManager

type ResourceManager interface {
	// Owners return a list of all owners the manager handle
	Owners() []string
	// BucketsPerAccount returns a mapping from account/project to
	// its associated buckets
	BucketsPerAccount() map[string][]Bucket
	// InstancesPerAccount returns a mapping from account/project
	// to its associated instances
	InstancesPerAccount() map[string][]Instance
	// ImagesPerAccount returns a mapping from account/project
	// to its associated images
	ImagesPerAccount() map[string][]Image
	// VolumesPerAccount returns a mapping from account/project
	// to its associated volumes
	VolumesPerAccount() map[string][]Volume
	// SnapshotsPerAccount returns a mapping from account/project
	// to its associated snaphots
	SnapshotsPerAccount() map[string][]Snapshot
	// AllResourcesPerAccount will return a mapping from account/project
	// to all of the resources associated with that account/project
	AllResourcesPerAccount() map[string]*ResourceCollection
	// CleanupInstances termiantes a list of instances, which is faster
	// than calling Cleanup() on every individual instance
	CleanupInstances([]Instance) error
	// CleanupImages de-registers a list of images
	CleanupImages([]Image) error
	// CleanupVolumes deletes a list of volumes
	CleanupVolumes([]Volume) error
	// CleanupSnapshots delete a list of snapshots
	CleanupSnapshots([]Snapshot) error
	// CleanupBuckets deletes the specified buckets
	CleanupBuckets([]Bucket) error
}

ResourceManager is used to manage the different resources on a CSP. It can be used to get e.g. all instances for all accounts in AWS.

func NewManager

func NewManager(c CSP, accounts ...string) (ResourceManager, error)

NewManager will build a new resource manager for the specified CSP

type Snapshot

type Snapshot interface {
	Resource
	Encrypted() bool
	InUse() bool
	SizeGB() int64
}

Snapshot composes the Resource interface, and describe a snapshot in any CSP.

type Volume

type Volume interface {
	Resource
	SizeGB() int64
	Attached() bool
	Encrypted() bool
	VolumeType() string
}

Volume composes the Resource interface, and describe a volume in any CSP.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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