Documentation ¶
Index ¶
- Constants
- Variables
- func IsGCEError(err error, reason string) bool
- func IsGCEInvalidError(err error) bool
- func IsGCENotFoundError(err error) bool
- func KmsKeyEqual(fetchedKMSKey, storageClassKMSKey string) bool
- func NewAltTokenSource(tokenURL, tokenBody string) oauth2.TokenSource
- func ValidateDiskParameters(disk *CloudDisk, params common.DiskParameters) error
- type AltTokenSource
- type CloudDisk
- func (d *CloudDisk) GetImageId() string
- func (d *CloudDisk) GetKMSKeyName() string
- func (d *CloudDisk) GetKind() string
- func (d *CloudDisk) GetMultiWriter() bool
- func (d *CloudDisk) GetName() string
- func (d *CloudDisk) GetPDType() string
- func (d *CloudDisk) GetSelfLink() string
- func (d *CloudDisk) GetSizeGb() int64
- func (d *CloudDisk) GetSnapshotId() string
- func (d *CloudDisk) GetSourceDiskId() string
- func (d *CloudDisk) GetStatus() string
- func (d *CloudDisk) GetUsers() []string
- func (d *CloudDisk) GetZone() string
- func (d *CloudDisk) LocationType() meta.KeyType
- type CloudDiskType
- type CloudProvider
- func (cloud *CloudProvider) AttachDisk(ctx context.Context, project string, volKey *meta.Key, ...) error
- func (cloud *CloudProvider) CreateImage(ctx context.Context, project string, volKey *meta.Key, imageName string, ...) (*computev1.Image, error)
- func (cloud *CloudProvider) CreateSnapshot(ctx context.Context, project string, volKey *meta.Key, snapshotName string, ...) (*computev1.Snapshot, error)
- func (cloud *CloudProvider) DeleteDisk(ctx context.Context, project string, volKey *meta.Key) error
- func (cloud *CloudProvider) DeleteImage(ctx context.Context, project, imageName string) error
- func (cloud *CloudProvider) DeleteSnapshot(ctx context.Context, project, snapshotName string) error
- func (cloud *CloudProvider) DetachDisk(ctx context.Context, project, deviceName, instanceZone, instanceName string) error
- func (cloud *CloudProvider) GetDefaultProject() string
- func (cloud *CloudProvider) GetDefaultZone() string
- func (cloud *CloudProvider) GetDisk(ctx context.Context, project string, key *meta.Key, ...) (*CloudDisk, error)
- func (cloud *CloudProvider) GetDiskSourceURI(project string, volKey *meta.Key) string
- func (cloud *CloudProvider) GetDiskTypeURI(project string, volKey *meta.Key, diskType string) string
- func (cloud *CloudProvider) GetImage(ctx context.Context, project, imageName string) (*computev1.Image, error)
- func (cloud *CloudProvider) GetInstanceOrError(ctx context.Context, instanceZone, instanceName string) (*computev1.Instance, error)
- func (cloud *CloudProvider) GetReplicaZoneURI(project, zone string) string
- func (cloud *CloudProvider) GetSnapshot(ctx context.Context, project, snapshotName string) (*computev1.Snapshot, error)
- func (cloud *CloudProvider) InsertDisk(ctx context.Context, project string, volKey *meta.Key, ...) error
- func (cloud *CloudProvider) ListDisks(ctx context.Context) ([]*computev1.Disk, string, error)
- func (cloud *CloudProvider) ListImages(ctx context.Context, filter string) ([]*computev1.Image, string, error)
- func (cloud *CloudProvider) ListSnapshots(ctx context.Context, filter string) ([]*computev1.Snapshot, string, error)
- func (cloud *CloudProvider) ListZones(ctx context.Context, region string) ([]string, error)
- func (cloud *CloudProvider) RepairUnderspecifiedVolumeKey(ctx context.Context, project string, volumeKey *meta.Key) (string, *meta.Key, error)
- func (cloud *CloudProvider) ResizeDisk(ctx context.Context, project string, volKey *meta.Key, requestBytes int64) (int64, error)
- func (cloud *CloudProvider) ValidateExistingDisk(ctx context.Context, resp *CloudDisk, params common.DiskParameters, ...) error
- func (cloud *CloudProvider) WaitForAttach(ctx context.Context, project string, volKey *meta.Key, ...) error
- type ConfigFile
- type ConfigGlobal
- type FakeBlockingCloudProvider
- func (cloud *FakeBlockingCloudProvider) AttachDisk(ctx context.Context, project string, volKey *meta.Key, ...) error
- func (cloud *FakeBlockingCloudProvider) CreateImage(ctx context.Context, project string, volKey *meta.Key, imageName string, ...) (*computev1.Image, error)
- func (cloud *FakeBlockingCloudProvider) CreateSnapshot(ctx context.Context, project string, volKey *meta.Key, snapshotName string, ...) (*computev1.Snapshot, error)
- func (cloud *FakeBlockingCloudProvider) DetachDisk(ctx context.Context, project, deviceName, instanceZone, instanceName string) error
- type FakeCloudProvider
- func (cloud *FakeCloudProvider) AttachDisk(ctx context.Context, project string, volKey *meta.Key, ...) error
- func (cloud *FakeCloudProvider) CreateImage(ctx context.Context, project string, volKey *meta.Key, imageName string, ...) (*computev1.Image, error)
- func (cloud *FakeCloudProvider) CreateSnapshot(ctx context.Context, project string, volKey *meta.Key, snapshotName string, ...) (*computev1.Snapshot, error)
- func (cloud *FakeCloudProvider) DeleteDisk(ctx context.Context, project string, volKey *meta.Key) error
- func (cloud *FakeCloudProvider) DeleteImage(ctx context.Context, project, imageName string) error
- func (cloud *FakeCloudProvider) DeleteSnapshot(ctx context.Context, project, snapshotName string) error
- func (cloud *FakeCloudProvider) DetachDisk(ctx context.Context, project, deviceName, instanceZone, instanceName string) error
- func (cloud *FakeCloudProvider) GetDefaultProject() string
- func (cloud *FakeCloudProvider) GetDefaultZone() string
- func (cloud *FakeCloudProvider) GetDisk(ctx context.Context, project string, volKey *meta.Key, api GCEAPIVersion) (*CloudDisk, error)
- func (cloud *FakeCloudProvider) GetDiskSourceURI(project string, volKey *meta.Key) string
- func (cloud *FakeCloudProvider) GetDiskTypeURI(project string, volKey *meta.Key, diskType string) string
- func (cloud *FakeCloudProvider) GetImage(ctx context.Context, project, imageName string) (*computev1.Image, error)
- func (cloud *FakeCloudProvider) GetInstanceOrError(ctx context.Context, instanceZone, instanceName string) (*computev1.Instance, error)
- func (cloud *FakeCloudProvider) GetReplicaZoneURI(project, zone string) string
- func (cloud *FakeCloudProvider) GetSnapshot(ctx context.Context, project, snapshotName string) (*computev1.Snapshot, error)
- func (cloud *FakeCloudProvider) InsertDisk(ctx context.Context, project string, volKey *meta.Key, ...) error
- func (cloud *FakeCloudProvider) InsertInstance(instance *computev1.Instance, instanceZone, instanceName string)
- func (cloud *FakeCloudProvider) ListDisks(ctx context.Context) ([]*computev1.Disk, string, error)
- func (cloud *FakeCloudProvider) ListImages(ctx context.Context, filter string) ([]*computev1.Image, string, error)
- func (cloud *FakeCloudProvider) ListSnapshots(ctx context.Context, filter string) ([]*computev1.Snapshot, string, error)
- func (cloud *FakeCloudProvider) ListZones(ctx context.Context, region string) ([]string, error)
- func (cloud *FakeCloudProvider) RepairUnderspecifiedVolumeKey(ctx context.Context, project string, volumeKey *meta.Key) (string, *meta.Key, error)
- func (cloud *FakeCloudProvider) ResizeDisk(ctx context.Context, project string, volKey *meta.Key, requestBytes int64) (int64, error)
- func (cloud *FakeCloudProvider) UpdateDiskStatus(s string)
- func (cloud *FakeCloudProvider) ValidateExistingDisk(ctx context.Context, resp *CloudDisk, params common.DiskParameters, ...) error
- func (cloud *FakeCloudProvider) ValidateExistingSnapshot(resp *computev1.Snapshot, volKey *meta.Key) error
- func (cloud *FakeCloudProvider) WaitForAttach(ctx context.Context, project string, volKey *meta.Key, ...) error
- type GCEAPIVersion
- type GCECompute
- type Signal
Constants ¶
const ( DiskSizeGb = 10 Timestamp = "2018-09-05T15:17:08.270-07:00" BasePath = "https://www.googleapis.com/compute/v1/" )
const (
TokenURL = "https://accounts.google.com/o/oauth2/token"
)
Variables ¶
var AttachDiskBackoff = wait.Backoff{ Duration: 5 * time.Second, Factor: 0.0, Jitter: 0.0, Steps: 24, Cap: 0}
AttachDiskBackoff is backoff used to wait for AttachDisk to complete. Default values are similar to Poll every 5 seconds with 2 minute timeout.
var WaitForOpBackoff = wait.Backoff{ Duration: 3 * time.Second, Factor: 0.0, Jitter: 0.0, Steps: 100, Cap: 0}
WaitForOpBackoff is backoff used to wait for Global, Regional or Zonal operation to complete. Default values are similar to Poll every 3 seconds with 5 minute timeout.
Functions ¶
func IsGCEError ¶
isGCEError returns true if given error is a googleapi.Error with given reason (e.g. "resourceInUseByAnotherResource")
func IsGCEInvalidError ¶ added in v0.7.0
IsInvalidError returns true if the error is a googleapi.Error with invalid reason
func IsGCENotFoundError ¶ added in v0.6.0
IsGCENotFoundError returns true if the error is a googleapi.Error with notFound reason
func KmsKeyEqual ¶ added in v1.6.0
kmsKeyEqual returns true if fetchedKMSKey and storageClassKMSKey refer to the same key. fetchedKMSKey - key returned by the server
example: projects/{0}/locations/{1}/keyRings/{2}/cryptoKeys/{3}/cryptoKeyVersions/{4}
storageClassKMSKey - key as provided by the client
example: projects/{0}/locations/{1}/keyRings/{2}/cryptoKeys/{3}
cryptoKeyVersions should be disregarded if the rest of the key is identical.
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
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 (*CloudDisk) GetImageId ¶ added in v1.5.1
func (*CloudDisk) GetKMSKeyName ¶ added in v0.7.0
func (*CloudDisk) GetMultiWriter ¶ added in v1.0.0
func (*CloudDisk) GetPDType ¶ added in v0.7.0
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 (*CloudDisk) GetSelfLink ¶
func (*CloudDisk) GetSnapshotId ¶ added in v0.3.0
func (*CloudDisk) GetSourceDiskId ¶ added in v1.4.0
func (*CloudDisk) LocationType ¶ added in v1.0.3
type CloudDiskType ¶
type CloudDiskType string
type CloudProvider ¶
type CloudProvider struct {
// contains filtered or unexported fields
}
func CreateCloudProvider ¶
func (*CloudProvider) AttachDisk ¶
func (*CloudProvider) CreateImage ¶ added in v1.5.0
func (*CloudProvider) CreateSnapshot ¶
func (*CloudProvider) DeleteDisk ¶
func (*CloudProvider) DeleteImage ¶ added in v1.5.0
func (cloud *CloudProvider) DeleteImage(ctx context.Context, project, imageName string) error
func (*CloudProvider) DeleteSnapshot ¶
func (cloud *CloudProvider) DeleteSnapshot(ctx context.Context, project, snapshotName string) error
func (*CloudProvider) DetachDisk ¶
func (cloud *CloudProvider) DetachDisk(ctx context.Context, project, 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, project string, key *meta.Key, gceAPIVersion GCEAPIVersion) (*CloudDisk, error)
func (*CloudProvider) GetDiskSourceURI ¶
func (cloud *CloudProvider) GetDiskSourceURI(project string, volKey *meta.Key) string
func (*CloudProvider) GetDiskTypeURI ¶
func (*CloudProvider) GetInstanceOrError ¶
func (*CloudProvider) GetReplicaZoneURI ¶
func (cloud *CloudProvider) GetReplicaZoneURI(project, zone string) string
func (*CloudProvider) GetSnapshot ¶
func (*CloudProvider) InsertDisk ¶
func (*CloudProvider) ListDisks ¶ added in v0.7.0
ListDisks lists disks based on maxEntries and pageToken only in the project and region that the driver is running in.
func (*CloudProvider) ListImages ¶ added in v1.5.0
func (*CloudProvider) ListSnapshots ¶
func (*CloudProvider) RepairUnderspecifiedVolumeKey ¶
func (cloud *CloudProvider) RepairUnderspecifiedVolumeKey(ctx context.Context, project string, volumeKey *meta.Key) (string, *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, project string, 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 ¶
type ConfigFile ¶ added in v0.5.0
type ConfigFile struct {
Global ConfigGlobal `gcfg:"global"`
}
type ConfigGlobal ¶ added in v0.5.0
type FakeBlockingCloudProvider ¶ added in v0.6.0
type FakeBlockingCloudProvider struct { *FakeCloudProvider ReadyToExecute chan chan Signal }
func (*FakeBlockingCloudProvider) AttachDisk ¶ added in v1.7.0
func (*FakeBlockingCloudProvider) CreateImage ¶ added in v1.5.0
func (*FakeBlockingCloudProvider) CreateSnapshot ¶ added in v0.6.0
func (cloud *FakeBlockingCloudProvider) CreateSnapshot(ctx context.Context, project string, volKey *meta.Key, snapshotName string, snapshotParams common.SnapshotParameters) (*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.
func (*FakeBlockingCloudProvider) DetachDisk ¶ added in v1.7.0
func (cloud *FakeBlockingCloudProvider) DetachDisk(ctx context.Context, project, deviceName, instanceZone, instanceName string) error
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 (*FakeCloudProvider) CreateImage ¶ added in v1.5.0
func (*FakeCloudProvider) CreateSnapshot ¶
func (*FakeCloudProvider) DeleteDisk ¶
func (*FakeCloudProvider) DeleteImage ¶ added in v1.5.0
func (cloud *FakeCloudProvider) DeleteImage(ctx context.Context, project, imageName string) error
func (*FakeCloudProvider) DeleteSnapshot ¶
func (cloud *FakeCloudProvider) DeleteSnapshot(ctx context.Context, project, snapshotName string) error
Snapshot Methods
func (*FakeCloudProvider) DetachDisk ¶
func (cloud *FakeCloudProvider) DetachDisk(ctx context.Context, project, 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, project string, volKey *meta.Key, api GCEAPIVersion) (*CloudDisk, error)
Disk Methods
func (*FakeCloudProvider) GetDiskSourceURI ¶
func (cloud *FakeCloudProvider) GetDiskSourceURI(project string, volKey *meta.Key) string
func (*FakeCloudProvider) GetDiskTypeURI ¶
func (*FakeCloudProvider) GetInstanceOrError ¶
func (*FakeCloudProvider) GetReplicaZoneURI ¶
func (cloud *FakeCloudProvider) GetReplicaZoneURI(project, zone string) string
Regional Disk Methods
func (*FakeCloudProvider) GetSnapshot ¶
func (cloud *FakeCloudProvider) GetSnapshot(ctx context.Context, project, snapshotName string) (*computev1.Snapshot, error)
Snapshot Methods
func (*FakeCloudProvider) InsertDisk ¶
func (*FakeCloudProvider) InsertInstance ¶
func (cloud *FakeCloudProvider) InsertInstance(instance *computev1.Instance, instanceZone, instanceName string)
Instance Methods
func (*FakeCloudProvider) ListImages ¶ added in v1.5.0
func (*FakeCloudProvider) ListSnapshots ¶
func (*FakeCloudProvider) RepairUnderspecifiedVolumeKey ¶
func (*FakeCloudProvider) ResizeDisk ¶ added in v0.6.0
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 (*FakeCloudProvider) WaitForAttach ¶
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, project string, volumeKey *meta.Key, gceAPIVersion GCEAPIVersion) (*CloudDisk, error) RepairUnderspecifiedVolumeKey(ctx context.Context, project string, volumeKey *meta.Key) (string, *meta.Key, error) ValidateExistingDisk(ctx context.Context, disk *CloudDisk, params common.DiskParameters, reqBytes, limBytes int64, multiWriter bool) error InsertDisk(ctx context.Context, project string, volKey *meta.Key, params common.DiskParameters, capBytes int64, capacityRange *csi.CapacityRange, replicaZones []string, snapshotID string, volumeContentSourceVolumeID string, multiWriter bool) error DeleteDisk(ctx context.Context, project string, volumeKey *meta.Key) error AttachDisk(ctx context.Context, project string, volKey *meta.Key, readWrite, diskType, instanceZone, instanceName string) error DetachDisk(ctx context.Context, project, deviceName, instanceZone, instanceName string) error GetDiskSourceURI(project string, volKey *meta.Key) string GetDiskTypeURI(project string, volKey *meta.Key, diskType string) string WaitForAttach(ctx context.Context, project string, volKey *meta.Key, instanceZone, instanceName string) error ResizeDisk(ctx context.Context, project string, volKey *meta.Key, requestBytes int64) (int64, error) ListDisks(ctx context.Context) ([]*computev1.Disk, string, error) // Regional Disk Methods GetReplicaZoneURI(project string, 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) ([]*computev1.Snapshot, string, error) GetSnapshot(ctx context.Context, project, snapshotName string) (*computev1.Snapshot, error) CreateSnapshot(ctx context.Context, project string, volKey *meta.Key, snapshotName string, snapshotParams common.SnapshotParameters) (*computev1.Snapshot, error) DeleteSnapshot(ctx context.Context, project, snapshotName string) error ListImages(ctx context.Context, filter string) ([]*computev1.Image, string, error) GetImage(ctx context.Context, project, imageName string) (*computev1.Image, error) CreateImage(ctx context.Context, project string, volKey *meta.Key, imageName string, snapshotParams common.SnapshotParameters) (*computev1.Image, error) DeleteImage(ctx context.Context, project, imageName string) error }