cloud

package
v0.22.0 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotImplemented = errors.New("cloud: not implemented")

ErrNotImplemented is the error returned if a method is not implemented.

Functions

func Register

func Register(name ProviderName, factory Factory)

Register registers a cloud provider factory by name.

The cloud MUST have a name: lower case and one word.

Types

type Bucket added in v0.0.10

type Bucket struct {
	Name   string
	Region string
}

Describes a bucket.

type Compute added in v0.0.16

type Compute interface {
	// DescribeRegions returns a list of regions.
	DescribeRegions(ctx context.Context) ([]*Region, error)

	// DescribeZones returns a list of availability zones within a region.
	DescribeZones(ctx context.Context) ([]*Zone, error)

	// DescribeVPCs returns a list of VPCs within a region.
	DescribeVPCs(ctx context.Context) ([]*VPC, error)

	// DescribeSubnets returns a list of subnets within a VPC.
	DescribeSubnets(ctx context.Context, vpcID string) ([]*Subnet, error)

	// DescribeInstances returns a list of instances.
	DescribeInstances(ctx context.Context, filters ...*Filter) ([]*Instance, error)
}

Compute defines the interface of the Compute Services API.

type Factory

type Factory func(options ...ProviderOption) (Provider, error)

Factory is a function that returns a Provider interface. An error is returned if the cloud provider fails to initialize, nil otherwise.

func GetFactory

func GetFactory(name ProviderName) (Factory, error)

GetFactory returns a factory of cloud provider by name.

type Filter added in v0.0.16

type Filter struct {
	Name   string
	Values []string
}

Filter represents a name and value pair that is used to return a more specific list of results from a describe operation.

type IAM added in v0.0.16

type IAM interface {
	// GetInstanceProfile returns an instance profile by name.
	GetInstanceProfile(ctx context.Context, profileName string) (*InstanceProfile, error)

	// AttachRolePolicy attaches the specified policy to the specified IAM role.
	AttachRolePolicy(ctx context.Context, roleName, policyARN string) error
}

type Instance added in v0.0.16

type Instance struct {
	ID              string
	Name            string
	InstanceProfile *InstanceProfile
}

Describes an instance.

type InstanceProfile added in v0.0.16

type InstanceProfile struct {
	ID    string
	Name  string
	ARN   string
	Roles []*Role
}

Describes an IAM instance profile.

type Provider added in v0.0.16

type Provider interface {
	// Name returns the cloud provider name.
	Name() ProviderName

	// TODO(liran): Remove.
	Session(region, profile string) (interface{}, error)

	// Compute returns an instance of Compute interface.
	Compute() Compute

	// Storage returns an instance of Storage interface.
	Storage() Storage

	// IAM returns an instance of IAM interface.
	IAM() IAM
}

Interface defines the interface that should be implemented by a cloud provider.

func GetInstance

func GetInstance(name ProviderName, options ...ProviderOption) (Provider, error)

GetInstance returns an instance of cloud provider by name.

type ProviderName

type ProviderName string

ProviderName represents the name of a cloud provider.

type ProviderOption added in v0.0.10

type ProviderOption func(*ProviderOptions)

ProviderOption allows specifying various settings configurable by the provider.

func WithProfile added in v0.0.10

func WithProfile(profile string) ProviderOption

WithProfile specifies credentials profile to use.

func WithRegion added in v0.0.10

func WithRegion(region string) ProviderOption

WithRegion specifies the region to use.

type ProviderOptions added in v0.0.10

type ProviderOptions struct {
	// Credentials profile.
	Profile string

	// Region name.
	Region string

	// DryRun configures the provider to print the actions that would be executed,
	// without executing them.
	DryRun bool
}

func DefaultProviderOptions added in v0.0.10

func DefaultProviderOptions() *ProviderOptions

DefaultProviderOptions returns the default provider options.

type Region

type Region struct {
	Name string
}

Describes a region.

type Role added in v0.0.16

type Role struct {
	ID   string
	Name string
	ARN  string
}

Describes an IAM role.

type Storage added in v0.0.16

type Storage interface {
	// GetBucket returns a bucket by name.
	GetBucket(ctx context.Context, bucket string) (*Bucket, error)

	// CreateBucket creates a new bucket.
	CreateBucket(ctx context.Context, bucket string) (*Bucket, error)
}

Storage defines the interface of the Storage Services API.

type Subnet

type Subnet struct {
	ID   string
	Name string
}

Describes a subnet.

type VPC

type VPC struct {
	ID   string
	Name string
}

Describes a VPC.

type Zone

type Zone struct {
	ID   string
	Name string
}

Describes a zone.

Directories

Path Synopsis
aws

Jump to

Keyboard shortcuts

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