cloud

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2023 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PollCheckInterval specifies the interval to check if the resource is ready;
	// this needs to be shorter than the timeout.
	PollCheckInterval = 15 * time.Second
	// PollCheckTimeout specifies the time limit for polling the describe API for a completed create/update operation.
	PollCheckTimeout = 15 * time.Minute
)

Polling

View Source
const (
	FilesystemPrefix = "fs"
	VolumePrefix     = "fsvol"
)

Prefixes used to parse the volume id.

Variables

View Source
var (
	ErrAlreadyExists = errors.New("resource already exists with the given name and different parameters")
	ErrInvalidInput  = errors.New("invalid input")
	ErrMultipleFound = errors.New("multiple resource found with the given ID")
	ErrNotFound      = errors.New("resource could not be found using the respective ID")
)

Errors

View Source
var DefaultEC2MetadataClient = func() (EC2Metadata, error) {
	sess := session.Must(session.NewSession(&aws.Config{}))
	svc := ec2metadata.New(sess)
	return svc, nil
}
View Source
var DefaultKubernetesAPIClient = func() (kubernetes.Interface, error) {

	config, err := rest.InClusterConfig()
	if err != nil {
		return nil, err
	}

	clientset, err := kubernetes.NewForConfig(config)
	if err != nil {
		return nil, err
	}
	return clientset, nil
}

Functions

func CollapseCreateFileSystemParameters

func CollapseCreateFileSystemParameters(parameters map[string]string) error

func CollapseCreateVolumeParameters

func CollapseCreateVolumeParameters(parameters map[string]string) error

func CollapseDeleteFileSystemParameters

func CollapseDeleteFileSystemParameters(parameters map[string]string) error

func CollapseDeleteVolumeParameters

func CollapseDeleteVolumeParameters(parameters map[string]string) error

func ValidateDeleteFileSystemParameters

func ValidateDeleteFileSystemParameters(parameters map[string]string) error

ValidateDeleteFileSystemParameters is used in CreateVolume to remove all delete parameters from the parameters map, and ensure they are valid. Parameters should be unique map containing only delete parameters without the OnDeletion suffix This method expects there to be no remaining delete parameters and errors if there are any Verifies parameters are valid in accordance to the API to prevent unknown errors from occurring during DeleteVolume

func ValidateDeleteVolumeParameters

func ValidateDeleteVolumeParameters(parameters map[string]string) error

ValidateDeleteVolumeParameters is used in CreateVolume to remove all delete parameters from the parameters map, and ensure they are valid. Parameters should be unique map containing only delete parameters without the OnDeletion suffix This method expects there to be no remaining delete parameters and errors if there are any Verifies parameters are valid in accordance to the API to prevent unknown errors from occurring during DeleteVolume

Types

type Cloud

type Cloud interface {
	CreateFileSystem(ctx context.Context, parameters map[string]string) (*FileSystem, error)
	ResizeFileSystem(ctx context.Context, fileSystemId string, newSizeGiB int64) (*int64, error)
	DeleteFileSystem(ctx context.Context, parameters map[string]string) error
	DescribeFileSystem(ctx context.Context, fileSystemId string) (*FileSystem, error)
	WaitForFileSystemAvailable(ctx context.Context, fileSystemId string) error
	WaitForFileSystemResize(ctx context.Context, fileSystemId string, resizeGiB int64) error
	CreateVolume(ctx context.Context, parameters map[string]string) (*Volume, error)
	DeleteVolume(ctx context.Context, parameters map[string]string) error
	DescribeVolume(ctx context.Context, volumeId string) (*Volume, error)
	WaitForVolumeAvailable(ctx context.Context, volumeId string) error
	WaitForVolumeResize(ctx context.Context, volumeId string, resizeGiB int64) error
	CreateSnapshot(ctx context.Context, options map[string]string) (*Snapshot, error)
	DeleteSnapshot(ctx context.Context, parameters map[string]string) error
	DescribeSnapshot(ctx context.Context, snapshotId string) (*Snapshot, error)
	WaitForSnapshotAvailable(ctx context.Context, snapshotId string) error
	GetDeleteParameters(ctx context.Context, id string) (map[string]string, error)
	GetVolumeId(ctx context.Context, volumeId string) (string, error)
}

func NewCloud

func NewCloud(region string) (Cloud, error)

NewCloud returns a new instance of AWS cloud It panics if session is invalid

type EC2Metadata

type EC2Metadata interface {
	Available() bool
	// EC2 instance metadata endpoints: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html
	GetMetadata(string) (string, error)
	GetInstanceIdentityDocument() (ec2metadata.EC2InstanceIdentityDocument, error)
}

type EC2MetadataClient

type EC2MetadataClient func() (EC2Metadata, error)

type FSx

FSx abstracts FSx client to facilitate its mocking. See https://docs.aws.amazon.com/sdk-for-go/api/service/fsx/ for details

type FakeCloudProvider

type FakeCloudProvider struct {
	// contains filtered or unexported fields
}

func NewFakeCloudProvider

func NewFakeCloudProvider() *FakeCloudProvider

func (*FakeCloudProvider) CreateFileSystem

func (c *FakeCloudProvider) CreateFileSystem(ctx context.Context, parameters map[string]string) (*FileSystem, error)

func (*FakeCloudProvider) CreateSnapshot

func (c *FakeCloudProvider) CreateSnapshot(ctx context.Context, parameters map[string]string) (snapshot *Snapshot, err error)

func (*FakeCloudProvider) CreateVolume

func (c *FakeCloudProvider) CreateVolume(ctx context.Context, parameters map[string]string) (*Volume, error)

func (*FakeCloudProvider) DeleteFileSystem

func (c *FakeCloudProvider) DeleteFileSystem(ctx context.Context, parameters map[string]string) error

func (*FakeCloudProvider) DeleteSnapshot

func (c *FakeCloudProvider) DeleteSnapshot(ctx context.Context, parameters map[string]string) (err error)

func (*FakeCloudProvider) DeleteVolume

func (c *FakeCloudProvider) DeleteVolume(ctx context.Context, parameters map[string]string) (err error)

func (*FakeCloudProvider) DescribeFileSystem

func (c *FakeCloudProvider) DescribeFileSystem(ctx context.Context, filesystemId string) (*FileSystem, error)

func (*FakeCloudProvider) DescribeSnapshot

func (c *FakeCloudProvider) DescribeSnapshot(ctx context.Context, snapshotId string) (*Snapshot, error)

func (*FakeCloudProvider) DescribeVolume

func (c *FakeCloudProvider) DescribeVolume(ctx context.Context, volumeId string) (*Volume, error)

func (*FakeCloudProvider) GetDeleteParameters

func (c *FakeCloudProvider) GetDeleteParameters(ctx context.Context, id string) (map[string]string, error)

func (*FakeCloudProvider) GetMetadata

func (c *FakeCloudProvider) GetMetadata() MetadataService

func (*FakeCloudProvider) GetVolumeId

func (c *FakeCloudProvider) GetVolumeId(ctx context.Context, volumeId string) (string, error)

func (*FakeCloudProvider) ResizeFileSystem

func (c *FakeCloudProvider) ResizeFileSystem(ctx context.Context, fileSystemId string, newSizeGiB int64) (*int64, error)

func (*FakeCloudProvider) WaitForFileSystemAvailable

func (c *FakeCloudProvider) WaitForFileSystemAvailable(ctx context.Context, fileSystemId string) error

func (*FakeCloudProvider) WaitForFileSystemResize

func (c *FakeCloudProvider) WaitForFileSystemResize(ctx context.Context, fileSystemId string, newSizeGiB int64) error

func (*FakeCloudProvider) WaitForSnapshotAvailable

func (c *FakeCloudProvider) WaitForSnapshotAvailable(ctx context.Context, snapshotId string) error

func (*FakeCloudProvider) WaitForVolumeAvailable

func (c *FakeCloudProvider) WaitForVolumeAvailable(ctx context.Context, volumeId string) error

func (*FakeCloudProvider) WaitForVolumeResize

func (c *FakeCloudProvider) WaitForVolumeResize(ctx context.Context, volumeId string, newSizeGiB int64) error

type FileSystem

type FileSystem struct {
	DnsName         string
	FileSystemId    string
	StorageCapacity int64
}

FileSystem represents an OpenZFS filesystem

type KubernetesAPIClient

type KubernetesAPIClient func() (kubernetes.Interface, error)

type Metadata

type Metadata struct {
	InstanceID       string
	InstanceType     string
	Region           string
	AvailabilityZone string
}

func EC2MetadataInstanceInfo

func EC2MetadataInstanceInfo(svc EC2Metadata, regionFromSession string) (*Metadata, error)

func KubernetesAPIInstanceInfo

func KubernetesAPIInstanceInfo(clientset kubernetes.Interface) (*Metadata, error)

func (*Metadata) GetAvailabilityZone

func (m *Metadata) GetAvailabilityZone() string

GetAvailabilityZone returns the Availability Zone which the instance is in.

func (*Metadata) GetInstanceID

func (m *Metadata) GetInstanceID() string

GetInstanceID returns the instance identification.

func (*Metadata) GetInstanceType

func (m *Metadata) GetInstanceType() string

GetInstanceType returns the instance type.

func (*Metadata) GetRegion

func (m *Metadata) GetRegion() string

GetRegion returns the Region Zone which the instance is in.

type MetadataService

type MetadataService interface {
	GetInstanceID() string
	GetInstanceType() string
	GetRegion() string
	GetAvailabilityZone() string
}

MetadataService represents AWS metadata service.

func NewMetadataService

func NewMetadataService(ec2MetadataClient EC2MetadataClient, k8sAPIClient KubernetesAPIClient, region string) (MetadataService, error)

NewMetadataService returns a new MetadataServiceImplementation.

type Snapshot

type Snapshot struct {
	SnapshotID     string
	SourceVolumeID string
	ResourceARN    string
	CreationTime   time.Time
}

Snapshot represents an OpenZFS volume snapshot

type Volume

type Volume struct {
	FileSystemId string
	VolumeId     string
	VolumePath   string
}

Volume represents an OpenZFS volume

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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