Documentation ¶
Index ¶
- Constants
- Variables
- type Cloud
- type Disk
- type DiskOptions
- type EC2
- type EC2Metadata
- type FakeCloudProvider
- func (c *FakeCloudProvider) AttachDisk(ctx context.Context, volumeID, nodeID string) (string, error)
- func (c *FakeCloudProvider) CreateDisk(ctx context.Context, volumeName string, diskOptions *DiskOptions) (*Disk, error)
- func (c *FakeCloudProvider) CreateSnapshot(ctx context.Context, volumeID string, snapshotOptions *SnapshotOptions) (snapshot *Snapshot, err error)
- func (c *FakeCloudProvider) DeleteDisk(ctx context.Context, volumeID string) (bool, error)
- func (c *FakeCloudProvider) DeleteSnapshot(ctx context.Context, snapshotID string) (success bool, err error)
- func (c *FakeCloudProvider) DetachDisk(ctx context.Context, volumeID, nodeID string) error
- func (c *FakeCloudProvider) GetDiskByID(ctx context.Context, volumeID string) (*Disk, error)
- func (c *FakeCloudProvider) GetDiskByName(ctx context.Context, name string, capacityBytes int64) (*Disk, error)
- func (c *FakeCloudProvider) GetMetadata() MetadataService
- func (c *FakeCloudProvider) GetSnapshotByName(ctx context.Context, name string) (snapshot *Snapshot, err error)
- func (c *FakeCloudProvider) IsExistInstance(ctx context.Context, nodeID string) bool
- func (c *FakeCloudProvider) WaitForAttachmentState(ctx context.Context, volumeID, state string) error
- type MetadataService
- type Snapshot
- type SnapshotOptions
Constants ¶
const ( // VolumeTypeIO1 represents a provisioned IOPS SSD type of volume. VolumeTypeIO1 = "io1" // VolumeTypeGP2 represents a general purpose SSD type of volume. VolumeTypeGP2 = "gp2" // VolumeTypeSC1 represents a cold HDD (sc1) type of volume. VolumeTypeSC1 = "sc1" // VolumeTypeST1 represents a throughput-optimized HDD type of volume. VolumeTypeST1 = "st1" )
AWS volume types
const ( // MinTotalIOPS represents the minimum Input Output per second. MinTotalIOPS = 100 // MaxTotalIOPS represents the maximum Input Output per second. MaxTotalIOPS = 20000 )
AWS provisioning limits. Source: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/EBSVolumeTypes.html
const ( // DefaultVolumeSize represents the default volume size. DefaultVolumeSize int64 = 100 * util.GiB // DefaultVolumeType specifies which storage to use for newly created Volumes. DefaultVolumeType = VolumeTypeGP2 )
Defaults
const ( // VolumeNameTagKey is the key value that refers to the volume's name. VolumeNameTagKey = "CSIVolumeName" // SnapshotNameTagKey is the key value that refers to the snapshot's name. SnapshotNameTagKey = "CSIVolumeSnapshotName" )
Tags
Variables ¶
var ( // ErrMultiDisks is an error that is returned when multiple // disks are found with the same volume name. ErrMultiDisks = errors.New("Multiple disks with same name") // ErrDiskExistsDiffSize is an error that is returned if a disk with a given // name, but different size, is found. ErrDiskExistsDiffSize = errors.New("There is already a disk with same name and different size") // ErrNotFound is returned when a resource is not found. ErrNotFound = errors.New("Resource was not found") // ErrAlreadyExists is returned when a resource is already existent. ErrAlreadyExists = errors.New("Resource already exists") )
var (
ValidVolumeTypes = []string{VolumeTypeIO1, VolumeTypeGP2, VolumeTypeSC1, VolumeTypeST1}
)
Functions ¶
This section is empty.
Types ¶
type Cloud ¶
type Cloud interface { GetMetadata() MetadataService CreateDisk(ctx context.Context, volumeName string, diskOptions *DiskOptions) (disk *Disk, err error) DeleteDisk(ctx context.Context, volumeID string) (success bool, err error) AttachDisk(ctx context.Context, volumeID string, nodeID string) (devicePath string, err error) DetachDisk(ctx context.Context, volumeID string, nodeID string) (err error) WaitForAttachmentState(ctx context.Context, volumeID, state string) error GetDiskByName(ctx context.Context, name string, capacityBytes int64) (disk *Disk, err error) GetDiskByID(ctx context.Context, volumeID string) (disk *Disk, err error) IsExistInstance(ctx context.Context, nodeID string) (success bool) CreateSnapshot(ctx context.Context, volumeID string, snapshotOptions *SnapshotOptions) (snapshot *Snapshot, err error) DeleteSnapshot(ctx context.Context, snapshotID string) (success bool, err error) GetSnapshotByName(ctx context.Context, name string) (snapshot *Snapshot, err error) }
func NewCloud ¶
NewCloud returns a new instance of AWS cloud Pass in nil metadata to use an auto created EC2Metadata service It panics if session is invalid
func NewCloudWithMetadata ¶ added in v0.2.0
func NewCloudWithMetadata(metadata MetadataService) (Cloud, error)
type DiskOptions ¶
type DiskOptions struct { CapacityBytes int64 Tags map[string]string VolumeType string IOPSPerGB int AvailabilityZone string Encrypted bool // KmsKeyID represents a fully qualified resource name to the key to use for encryption. // example: arn:aws:kms:us-east-1:012345678910:key/abcd1234-a123-456a-a12b-a123b4cd56ef KmsKeyID string SnapshotID string }
DiskOptions represents parameters to create an EBS volume
type EC2 ¶
type EC2 interface { DescribeVolumesWithContext(ctx aws.Context, input *ec2.DescribeVolumesInput, opts ...request.Option) (*ec2.DescribeVolumesOutput, error) CreateVolumeWithContext(ctx aws.Context, input *ec2.CreateVolumeInput, opts ...request.Option) (*ec2.Volume, error) DeleteVolumeWithContext(ctx aws.Context, input *ec2.DeleteVolumeInput, opts ...request.Option) (*ec2.DeleteVolumeOutput, error) DetachVolumeWithContext(ctx aws.Context, input *ec2.DetachVolumeInput, opts ...request.Option) (*ec2.VolumeAttachment, error) AttachVolumeWithContext(ctx aws.Context, input *ec2.AttachVolumeInput, opts ...request.Option) (*ec2.VolumeAttachment, error) DescribeInstancesWithContext(ctx aws.Context, input *ec2.DescribeInstancesInput, opts ...request.Option) (*ec2.DescribeInstancesOutput, error) CreateSnapshotWithContext(ctx aws.Context, input *ec2.CreateSnapshotInput, opts ...request.Option) (*ec2.Snapshot, error) DeleteSnapshotWithContext(ctx aws.Context, input *ec2.DeleteSnapshotInput, opts ...request.Option) (*ec2.DeleteSnapshotOutput, error) DescribeSnapshotsWithContext(ctx aws.Context, input *ec2.DescribeSnapshotsInput, opts ...request.Option) (*ec2.DescribeSnapshotsOutput, error) }
EC2 abstracts aws.EC2 to facilitate its mocking. See https://docs.aws.amazon.com/sdk-for-go/api/service/ec2/ for details
type EC2Metadata ¶
type EC2Metadata interface { Available() bool GetInstanceIdentityDocument() (ec2metadata.EC2InstanceIdentityDocument, error) }
type FakeCloudProvider ¶
type FakeCloudProvider struct {
// contains filtered or unexported fields
}
func NewFakeCloudProvider ¶
func NewFakeCloudProvider() *FakeCloudProvider
func (*FakeCloudProvider) AttachDisk ¶
func (*FakeCloudProvider) CreateDisk ¶
func (c *FakeCloudProvider) CreateDisk(ctx context.Context, volumeName string, diskOptions *DiskOptions) (*Disk, error)
func (*FakeCloudProvider) CreateSnapshot ¶ added in v0.3.0
func (c *FakeCloudProvider) CreateSnapshot(ctx context.Context, volumeID string, snapshotOptions *SnapshotOptions) (snapshot *Snapshot, err error)
func (*FakeCloudProvider) DeleteDisk ¶
func (*FakeCloudProvider) DeleteSnapshot ¶ added in v0.3.0
func (*FakeCloudProvider) DetachDisk ¶
func (c *FakeCloudProvider) DetachDisk(ctx context.Context, volumeID, nodeID string) error
func (*FakeCloudProvider) GetDiskByID ¶
func (*FakeCloudProvider) GetDiskByName ¶
func (*FakeCloudProvider) GetMetadata ¶
func (c *FakeCloudProvider) GetMetadata() MetadataService
func (*FakeCloudProvider) GetSnapshotByName ¶ added in v0.3.0
func (*FakeCloudProvider) IsExistInstance ¶
func (c *FakeCloudProvider) IsExistInstance(ctx context.Context, nodeID string) bool
func (*FakeCloudProvider) WaitForAttachmentState ¶ added in v0.2.0
func (c *FakeCloudProvider) WaitForAttachmentState(ctx context.Context, volumeID, state string) error
type MetadataService ¶
type MetadataService interface { GetInstanceID() string GetRegion() string GetAvailabilityZone() string }
MetadataService represents AWS metadata service.
func NewMetadataService ¶
func NewMetadataService(svc EC2Metadata) (MetadataService, error)
NewMetadataService returns a new MetadataServiceImplementation.
type Snapshot ¶ added in v0.3.0
type Snapshot struct { SnapshotID string SourceVolumeID string Size int64 CreationTime time.Time ReadyToUse bool }
Snapshot represents an EBS volume snapshot
type SnapshotOptions ¶ added in v0.3.0
SnapshotOptions represents parameters to create an EBS volume