gcecloudprovider

package
v1.2.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2020 License: Apache-2.0 Imports: 27 Imported by: 3

Documentation

Index

Constants

View Source
const (
	DiskSizeGb = 10
	Timestamp  = "2018-09-05T15:17:08.270-07:00"
	BasePath   = "https://www.googleapis.com/compute/v1/projects/"
)
View Source
const (
	TokenURL = "https://accounts.google.com/o/oauth2/token"

	GCEComputeAPIEndpoint      = "https://www.googleapis.com/compute/v1/"
	GCEComputeBetaAPIEndpoint  = "https://www.googleapis.com/compute/beta/"
	GCEComputeAlphaAPIEndpoint = "https://www.googleapis.com/compute/alpha/"
)

Variables

This section is empty.

Functions

func IsGCEError

func IsGCEError(err error, reason string) bool

isGCEError returns true if given error is a googleapi.Error with given reason (e.g. "resourceInUseByAnotherResource")

func IsGCEInvalidError added in v0.7.0

func IsGCEInvalidError(err error) bool

IsInvalidError returns true if the error is a googleapi.Error with invalid reason

func IsGCENotFoundError added in v0.6.0

func IsGCENotFoundError(err error) bool

IsGCENotFoundError returns true if the error is a googleapi.Error with notFound reason

func NewAltTokenSource added in v0.5.0

func NewAltTokenSource(tokenURL, tokenBody string) oauth2.TokenSource

NewAltTokenSource constructs a new alternate token source for generating tokens.

func ValidateDiskParameters added in v0.7.0

func ValidateDiskParameters(disk *CloudDisk, params common.DiskParameters) error

ValidateDiskParameters takes a CloudDisk and returns true if the parameters specified validly describe the disk provided, and false otherwise.

Types

type AltTokenSource added in v0.5.0

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

AltTokenSource is the structure holding the data for the functionality needed to generates tokens

func (*AltTokenSource) Token added in v0.5.0

func (a *AltTokenSource) Token() (*oauth2.Token, error)

Token returns a token which may be used for authentication

type CloudDisk

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

func CloudDiskFromBeta added in v1.0.3

func CloudDiskFromBeta(disk *computebeta.Disk) *CloudDisk

func CloudDiskFromV1 added in v1.0.3

func CloudDiskFromV1(disk *computev1.Disk) *CloudDisk

func (*CloudDisk) GetKMSKeyName added in v0.7.0

func (d *CloudDisk) GetKMSKeyName() string

func (*CloudDisk) GetKind

func (d *CloudDisk) GetKind() string

func (*CloudDisk) GetMultiWriter added in v1.0.0

func (d *CloudDisk) GetMultiWriter() bool

func (*CloudDisk) GetName

func (d *CloudDisk) GetName() string

func (*CloudDisk) GetPDType added in v0.7.0

func (d *CloudDisk) GetPDType() string

GetPDType returns the type of the PD, which is stored as a url like projects/project/zones/zone/diskTypes/pd-standard. The returned type is not validated, it is just passed verbatium from GCP.

func (d *CloudDisk) GetSelfLink() string

func (*CloudDisk) GetSizeGb

func (d *CloudDisk) GetSizeGb() int64

func (*CloudDisk) GetSnapshotId added in v0.3.0

func (d *CloudDisk) GetSnapshotId() string

func (*CloudDisk) GetStatus added in v1.0.0

func (d *CloudDisk) GetStatus() string

func (*CloudDisk) GetUsers

func (d *CloudDisk) GetUsers() []string

func (*CloudDisk) GetZone

func (d *CloudDisk) GetZone() string

func (*CloudDisk) LocationType added in v1.0.3

func (d *CloudDisk) LocationType() meta.KeyType

type CloudDiskType

type CloudDiskType string

type CloudProvider

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

func CreateCloudProvider

func CreateCloudProvider(ctx context.Context, vendorVersion string, configPath string) (*CloudProvider, error)

func (*CloudProvider) AttachDisk

func (cloud *CloudProvider) AttachDisk(ctx context.Context, volKey *meta.Key, readWrite, diskType, instanceZone, instanceName string) error

func (*CloudProvider) CreateSnapshot

func (cloud *CloudProvider) CreateSnapshot(ctx context.Context, volKey *meta.Key, snapshotName string) (*computev1.Snapshot, error)

func (*CloudProvider) DeleteDisk

func (cloud *CloudProvider) DeleteDisk(ctx context.Context, volKey *meta.Key) error

func (*CloudProvider) DeleteSnapshot

func (cloud *CloudProvider) DeleteSnapshot(ctx context.Context, snapshotName string) error

func (*CloudProvider) DetachDisk

func (cloud *CloudProvider) DetachDisk(ctx context.Context, deviceName, instanceZone, instanceName string) error

func (*CloudProvider) GetDefaultProject added in v0.7.0

func (cloud *CloudProvider) GetDefaultProject() string

GetDefaultProject returns the project that was used to instantiate this GCE client.

func (*CloudProvider) GetDefaultZone added in v0.7.0

func (cloud *CloudProvider) GetDefaultZone() string

GetDefaultZone returns the zone that was used to instantiate this GCE client.

func (*CloudProvider) GetDisk

func (cloud *CloudProvider) GetDisk(ctx context.Context, key *meta.Key, gceAPIVersion GCEAPIVersion) (*CloudDisk, error)

func (*CloudProvider) GetDiskSourceURI

func (cloud *CloudProvider) GetDiskSourceURI(volKey *meta.Key) string

func (*CloudProvider) GetDiskTypeURI

func (cloud *CloudProvider) GetDiskTypeURI(volKey *meta.Key, diskType string) string

func (*CloudProvider) GetInstanceOrError

func (cloud *CloudProvider) GetInstanceOrError(ctx context.Context, instanceZone, instanceName string) (*computev1.Instance, error)

func (*CloudProvider) GetReplicaZoneURI

func (cloud *CloudProvider) GetReplicaZoneURI(zone string) string

func (*CloudProvider) GetSnapshot

func (cloud *CloudProvider) GetSnapshot(ctx context.Context, snapshotName string) (*computev1.Snapshot, error)

func (*CloudProvider) InsertDisk

func (cloud *CloudProvider) InsertDisk(ctx context.Context, volKey *meta.Key, params common.DiskParameters, capBytes int64, capacityRange *csi.CapacityRange, replicaZones []string, snapshotID string, multiWriter bool) error

func (*CloudProvider) ListDisks added in v0.7.0

func (cloud *CloudProvider) ListDisks(ctx context.Context, maxEntries int64, pageToken string) ([]*computev1.Disk, string, error)

ListDisks lists disks based on maxEntries and pageToken only in the project and zone that the driver is running in.

func (*CloudProvider) ListSnapshots

func (cloud *CloudProvider) ListSnapshots(ctx context.Context, filter string, maxEntries int64, pageToken string) ([]*computev1.Snapshot, string, error)

func (*CloudProvider) ListZones

func (cloud *CloudProvider) ListZones(ctx context.Context, region string) ([]string, error)

func (*CloudProvider) RepairUnderspecifiedVolumeKey

func (cloud *CloudProvider) RepairUnderspecifiedVolumeKey(ctx context.Context, volumeKey *meta.Key) (*meta.Key, error)

RepairUnderspecifiedVolumeKey will query the cloud provider and check each zone for the disk specified by the volume key and return a volume key with a correct zone

func (*CloudProvider) ResizeDisk added in v0.6.0

func (cloud *CloudProvider) ResizeDisk(ctx context.Context, volKey *meta.Key, requestBytes int64) (int64, error)

ResizeDisk takes in the requested disk size in bytes and returns the resized size in Gi TODO(#461) The whole driver could benefit from standardized usage of the k8s.io/apimachinery/quantity package for better size handling

func (*CloudProvider) ValidateExistingDisk

func (cloud *CloudProvider) ValidateExistingDisk(ctx context.Context, resp *CloudDisk, params common.DiskParameters, reqBytes, limBytes int64, multiWriter bool) error

func (*CloudProvider) WaitForAttach

func (cloud *CloudProvider) WaitForAttach(ctx context.Context, volKey *meta.Key, instanceZone, instanceName string) error

type ConfigFile added in v0.5.0

type ConfigFile struct {
	Global ConfigGlobal `gcfg:"global"`
}

type ConfigGlobal added in v0.5.0

type ConfigGlobal struct {
	TokenURL  string `gcfg:"token-url"`
	TokenBody string `gcfg:"token-body"`
	ProjectId string `gcfg:"project-id"`
	Zone      string `gcfg:"zone"`
}

type FakeBlockingCloudProvider added in v0.6.0

type FakeBlockingCloudProvider struct {
	*FakeCloudProvider
	ReadyToExecute chan chan struct{}
}

func (*FakeBlockingCloudProvider) CreateSnapshot added in v0.6.0

func (cloud *FakeBlockingCloudProvider) CreateSnapshot(ctx context.Context, volKey *meta.Key, snapshotName string) (*computev1.Snapshot, error)

FakeBlockingCloudProvider's method adds functionality to finely control the order of execution of CreateSnapshot calls. Upon starting a CreateSnapshot, it passes a chan 'executeCreateSnapshot' into readyToExecute, then blocks on executeCreateSnapshot. The test calling this function can block on readyToExecute to ensure that the operation has started and allowed the CreateSnapshot to continue by passing a struct into executeCreateSnapshot.

type FakeCloudProvider

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

func CreateFakeCloudProvider added in v0.6.0

func CreateFakeCloudProvider(project, zone string, cloudDisks []*CloudDisk) (*FakeCloudProvider, error)

func (*FakeCloudProvider) AttachDisk

func (cloud *FakeCloudProvider) AttachDisk(ctx context.Context, volKey *meta.Key, readWrite, diskType, instanceZone, instanceName string) error

func (*FakeCloudProvider) CreateSnapshot

func (cloud *FakeCloudProvider) CreateSnapshot(ctx context.Context, volKey *meta.Key, snapshotName string) (*computev1.Snapshot, error)

func (*FakeCloudProvider) DeleteDisk

func (cloud *FakeCloudProvider) DeleteDisk(ctx context.Context, volKey *meta.Key) error

func (*FakeCloudProvider) DeleteSnapshot

func (cloud *FakeCloudProvider) DeleteSnapshot(ctx context.Context, snapshotName string) error

Snapshot Methods

func (*FakeCloudProvider) DetachDisk

func (cloud *FakeCloudProvider) DetachDisk(ctx context.Context, deviceName, instanceZone, instanceName string) error

func (*FakeCloudProvider) GetDefaultProject added in v0.7.0

func (cloud *FakeCloudProvider) GetDefaultProject() string

func (*FakeCloudProvider) GetDefaultZone added in v0.7.0

func (cloud *FakeCloudProvider) GetDefaultZone() string

func (*FakeCloudProvider) GetDisk

func (cloud *FakeCloudProvider) GetDisk(ctx context.Context, volKey *meta.Key, api GCEAPIVersion) (*CloudDisk, error)

Disk Methods

func (*FakeCloudProvider) GetDiskSourceURI

func (cloud *FakeCloudProvider) GetDiskSourceURI(volKey *meta.Key) string

func (*FakeCloudProvider) GetDiskTypeURI

func (cloud *FakeCloudProvider) GetDiskTypeURI(volKey *meta.Key, diskType string) string

func (*FakeCloudProvider) GetInstanceOrError

func (cloud *FakeCloudProvider) GetInstanceOrError(ctx context.Context, instanceZone, instanceName string) (*computev1.Instance, error)

func (*FakeCloudProvider) GetReplicaZoneURI

func (cloud *FakeCloudProvider) GetReplicaZoneURI(zone string) string

Regional Disk Methods

func (*FakeCloudProvider) GetSnapshot

func (cloud *FakeCloudProvider) GetSnapshot(ctx context.Context, snapshotName string) (*computev1.Snapshot, error)

Snapshot Methods

func (*FakeCloudProvider) InsertDisk

func (cloud *FakeCloudProvider) InsertDisk(ctx context.Context, volKey *meta.Key, params common.DiskParameters, capBytes int64, capacityRange *csi.CapacityRange, replicaZones []string, snapshotID string, multiWriter bool) error

func (*FakeCloudProvider) InsertInstance

func (cloud *FakeCloudProvider) InsertInstance(instance *computev1.Instance, instanceZone, instanceName string)

Instance Methods

func (*FakeCloudProvider) ListDisks added in v0.7.0

func (cloud *FakeCloudProvider) ListDisks(ctx context.Context, maxEntries int64, pageToken string) ([]*computev1.Disk, string, error)

func (*FakeCloudProvider) ListSnapshots

func (cloud *FakeCloudProvider) ListSnapshots(ctx context.Context, filter string, maxEntries int64, pageToken string) ([]*computev1.Snapshot, string, error)

func (*FakeCloudProvider) ListZones

func (cloud *FakeCloudProvider) ListZones(ctx context.Context, region string) ([]string, error)

func (*FakeCloudProvider) RepairUnderspecifiedVolumeKey

func (cloud *FakeCloudProvider) RepairUnderspecifiedVolumeKey(ctx context.Context, volumeKey *meta.Key) (*meta.Key, error)

func (*FakeCloudProvider) ResizeDisk added in v0.6.0

func (cloud *FakeCloudProvider) ResizeDisk(ctx context.Context, volKey *meta.Key, requestBytes int64) (int64, error)

func (*FakeCloudProvider) UpdateDiskStatus added in v1.0.0

func (cloud *FakeCloudProvider) UpdateDiskStatus(s string)

func (*FakeCloudProvider) ValidateExistingDisk

func (cloud *FakeCloudProvider) ValidateExistingDisk(ctx context.Context, resp *CloudDisk, params common.DiskParameters, reqBytes, limBytes int64, multiWriter bool) error

func (*FakeCloudProvider) ValidateExistingSnapshot

func (cloud *FakeCloudProvider) ValidateExistingSnapshot(resp *computev1.Snapshot, volKey *meta.Key) error

func (*FakeCloudProvider) WaitForAttach

func (cloud *FakeCloudProvider) WaitForAttach(ctx context.Context, volKey *meta.Key, instanceZone, instanceName string) error

type GCEAPIVersion added in v1.0.0

type GCEAPIVersion string
const (
	// V1 key type
	GCEAPIVersionV1 GCEAPIVersion = "v1"
	// Alpha key type
	GCEAPIVersionBeta GCEAPIVersion = "beta"
)

type GCECompute

type GCECompute interface {
	// Metadata information
	GetDefaultProject() string
	GetDefaultZone() string
	// Disk Methods
	GetDisk(ctx context.Context, volumeKey *meta.Key, gceAPIVersion GCEAPIVersion) (*CloudDisk, error)
	RepairUnderspecifiedVolumeKey(ctx context.Context, volumeKey *meta.Key) (*meta.Key, error)
	ValidateExistingDisk(ctx context.Context, disk *CloudDisk, params common.DiskParameters, reqBytes, limBytes int64, multiWriter bool) error
	InsertDisk(ctx context.Context, volKey *meta.Key, params common.DiskParameters, capBytes int64, capacityRange *csi.CapacityRange, replicaZones []string, snapshotID string, multiWriter bool) error
	DeleteDisk(ctx context.Context, volumeKey *meta.Key) error
	AttachDisk(ctx context.Context, volKey *meta.Key, readWrite, diskType, instanceZone, instanceName string) error
	DetachDisk(ctx context.Context, deviceName string, instanceZone, instanceName string) error
	GetDiskSourceURI(volKey *meta.Key) string
	GetDiskTypeURI(volKey *meta.Key, diskType string) string
	WaitForAttach(ctx context.Context, volKey *meta.Key, instanceZone, instanceName string) error
	ResizeDisk(ctx context.Context, volKey *meta.Key, requestBytes int64) (int64, error)
	ListDisks(ctx context.Context, maxEntries int64, pageToken string) ([]*computev1.Disk, string, error)
	// Regional Disk Methods
	GetReplicaZoneURI(zone string) string
	// Instance Methods
	GetInstanceOrError(ctx context.Context, instanceZone, instanceName string) (*computev1.Instance, error)
	// Zone Methods
	ListZones(ctx context.Context, region string) ([]string, error)
	ListSnapshots(ctx context.Context, filter string, maxEntries int64, pageToken string) ([]*computev1.Snapshot, string, error)
	GetSnapshot(ctx context.Context, snapshotName string) (*computev1.Snapshot, error)
	CreateSnapshot(ctx context.Context, volKey *meta.Key, snapshotName string) (*computev1.Snapshot, error)
	DeleteSnapshot(ctx context.Context, snapshotName string) error
}

Jump to

Keyboard shortcuts

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