Documentation ¶
Index ¶
- Constants
- func BytesToGbRoundDown(bytes int64) int64
- func BytesToGbRoundUp(bytes int64) int64
- func CodeForError(sourceError error) codes.Code
- func ConvertLabelsStringToMap(labels string) (map[string]string, error)
- func ConvertMiStringToInt64(str string) (int64, error)
- func ConvertStringToAvailabilityClass(str string) (string, error)
- func ConvertStringToBool(str string) (bool, error)
- func ConvertStringToInt64(str string) (int64, error)
- func ConvertTagsStringToMap(tags string) (map[string]string, error)
- func CreateNodeID(project, zone, name string) string
- func CreateZonalVolumeID(project, zone, name string) string
- func GbToBytes(Gb int64) int64
- func GenerateUnderspecifiedVolumeID(diskName string, isZonal bool) string
- func GetDeviceName(volKey *meta.Key) (string, error)
- func GetRegionFromZones(zones []string) (string, error)
- func KeyToVolumeID(volKey *meta.Key, project string) (string, error)
- func LoggedError(msg string, err error) error
- func NewCombinedError(msg string, errs []error) error
- func NewLimiter(limit, burst int, emptyBucket bool) *rate.Limiter
- func NodeIDToZoneAndName(id string) (string, string, error)
- func ParseMachineType(machineTypeUrl string) (string, error)
- func ParseZoneFromURI(zoneURI string) (string, error)
- func ProcessStorageLocations(storageLocations string) ([]string, error)
- func SnapshotIDToProjectKey(id string) (string, string, string, error)
- func StoragePoolZones(storagePools []StoragePool) ([]string, error)
- func UnorderedSlicesEqual(slice1 []string, slice2 []string) bool
- func ValidateSnapshotType(snapshotType string) error
- func VolumeIDToKey(id string) (string, *meta.Key, error)
- func VolumeIdAsMultiZone(volumeId string) (string, error)
- type DiskParameters
- type ModifyVolumeParameters
- type ParameterProcessor
- type SnapshotParameters
- type StoragePool
- type TemporaryError
- type VolumeLocks
Constants ¶
const ( // Keys for Topology. This key will be shared amongst drivers from GCP TopologyKeyZone = "topology.gke.io/zone" // VolumeAttributes for Partition VolumeAttributePartition = "partition" UnspecifiedValue = "UNSPECIFIED" // Keyword indicating a 'multi-zone' volumeHandle. Replaces "zones" in the volumeHandle: // eg: projects/{project}/zones/multi-zone/disks/{name} vs. // projects/{project}/zones/{zone}/disks/{name} MultiZoneValue = "multi-zone" // Label that is set on a disk when it is used by a 'multi-zone' VolumeHandle MultiZoneLabel = "goog-gke-multi-zone" )
const ( // Parameters for StorageClass ParameterKeyType = "type" ParameterKeyReplicationType = "replication-type" ParameterKeyDiskEncryptionKmsKey = "disk-encryption-kms-key" ParameterKeyLabels = "labels" ParameterKeyProvisionedIOPSOnCreate = "provisioned-iops-on-create" ParameterKeyProvisionedThroughputOnCreate = "provisioned-throughput-on-create" ParameterAvailabilityClass = "availability-class" ParameterKeyEnableConfidentialCompute = "enable-confidential-storage" ParameterKeyStoragePools = "storage-pools" ParameterKeyResourceTags = "resource-tags" ParameterKeyEnableMultiZoneProvisioning = "enable-multi-zone-provisioning" // Parameters for VolumeSnapshotClass ParameterKeyStorageLocations = "storage-locations" ParameterKeySnapshotType = "snapshot-type" ParameterKeyImageFamily = "image-family" DiskSnapshotType = "snapshots" DiskImageType = "images" // Parameters for AvailabilityClass ParameterNoAvailabilityClass = "none" ParameterRegionalHardFailoverClass = "regional-hard-failover" // Keys for PV and PVC parameters as reported by external-provisioner ParameterKeyPVCName = "csi.storage.k8s.io/pvc/name" ParameterKeyPVCNamespace = "csi.storage.k8s.io/pvc/namespace" ParameterKeyPVName = "csi.storage.k8s.io/pv/name" // Keys for Snapshot and SnapshotContent parameters as reported by external-snapshotter ParameterKeyVolumeSnapshotName = "csi.storage.k8s.io/volumesnapshot/name" ParameterKeyVolumeSnapshotNamespace = "csi.storage.k8s.io/volumesnapshot/namespace" ParameterKeyVolumeSnapshotContentName = "csi.storage.k8s.io/volumesnapshotcontent/name" )
const (
VolumeOperationAlreadyExistsFmt = "An operation with the given Volume ID %s already exists"
)
Variables ¶
This section is empty.
Functions ¶
func BytesToGbRoundDown ¶ added in v1.0.3
func BytesToGbRoundUp ¶ added in v1.0.3
func CodeForError ¶ added in v1.7.10
CodeForError returns the grpc error code that maps to the http error code for the passed in user googleapi error or context error. Returns codes.Internal if the given error is not a googleapi error caused by the user. userErrorCodeMap is used for encoding most errors.
func ConvertLabelsStringToMap ¶ added in v1.0.3
ConvertLabelsStringToMap converts the labels from string to map example: "key1=value1,key2=value2" gets converted into {"key1": "value1", "key2": "value2"} See https://cloud.google.com/compute/docs/labeling-resources#label_format for details.
func ConvertMiStringToInt64 ¶ added in v1.8.7
ConvertMiStringToInt64 converts a GiB string to int64
func ConvertStringToAvailabilityClass ¶ added in v1.10.3
ConvertStringToAvailabilityClass converts a string to an availability class string.
func ConvertStringToBool ¶ added in v1.9.8
ConvertStringToBool converts a string to a boolean.
func ConvertStringToInt64 ¶ added in v1.7.10
ConvertStringToInt64 converts a string to int64
func ConvertTagsStringToMap ¶ added in v1.14.0
ConvertTagsStringToMap converts the tags from string to Tag slice example: "parent_id1/tag_key1/tag_value1,parent_id2/tag_key2/tag_value2" gets converted into {"parent_id1/tag_key1":"tag_value1", "parent_id2/tag_key2":"tag_value2"} See https://cloud.google.com/resource-manager/docs/tags/tags-overview, https://cloud.google.com/resource-manager/docs/tags/tags-creating-and-managing for details
func CreateNodeID ¶
func CreateZonalVolumeID ¶ added in v0.6.0
func GetRegionFromZones ¶
func KeyToVolumeID ¶ added in v0.6.0
func LoggedError ¶ added in v1.7.10
func NewCombinedError ¶ added in v1.14.0
NewCombinedError tries to return an appropriate wrapped error that captures useful information as an error code If there are multiple errors, it extracts the first "retryable" error as interpreted by the CSI sidecar.
func NewLimiter ¶ added in v1.14.0
NewLimiter returns a token bucket based request rate limiter after initializing the passed values for limit, burst (or token bucket) size. If opted for emptyBucket all initial tokens are reserved for the first burst.
func ParseMachineType ¶ added in v1.7.9
ParseMachineType returns an extracted machineType from a URL, or empty if not found. machineTypeUrl: Full or partial URL of the machine type resource, in the format:
zones/zone/machineTypes/machine-type
func ParseZoneFromURI ¶ added in v1.14.0
func ProcessStorageLocations ¶ added in v1.0.3
ProcessStorageLocations trims and normalizes storage location to lower letters.
func SnapshotIDToProjectKey ¶ added in v1.0.3
func StoragePoolZones ¶ added in v1.13.0
func StoragePoolZones(storagePools []StoragePool) ([]string, error)
StoragePoolZones returns the unique zones of the given storage pool resource names. Returns an error if multiple storage pools in 1 zone are found.
func UnorderedSlicesEqual ¶ added in v1.13.0
func ValidateSnapshotType ¶ added in v1.5.0
ValidateSnapshotType validates the type
func VolumeIdAsMultiZone ¶ added in v1.13.1
Types ¶
type DiskParameters ¶ added in v0.7.0
type DiskParameters struct { // Values: pd-standard, pd-balanced, pd-ssd, or any other PD disk type. Not validated. // Default: pd-standard DiskType string // Values: "none", regional-pd // Default: "none" ReplicationType string // Values: {string} // Default: "" DiskEncryptionKMSKey string // Values: {map[string]string} // Default: "" Tags map[string]string // Values: {map[string]string} // Default: "" Labels map[string]string // Values: {int64} // Default: none ProvisionedIOPSOnCreate int64 // Values: {int64} // Default: none ProvisionedThroughputOnCreate int64 // Values: {bool} // Default: false EnableConfidentialCompute bool // Default: false ForceAttach bool // Values: {[]string} // Default: "" StoragePools []StoragePool // Values: {map[string]string} // Default: "" ResourceTags map[string]string // Values: {bool} // Default: false MultiZoneProvisioning bool }
DiskParameters contains normalized and defaulted disk parameters
type ModifyVolumeParameters ¶ added in v1.15.0
func ExtractModifyVolumeParameters ¶ added in v1.15.0
func ExtractModifyVolumeParameters(parameters map[string]string) (ModifyVolumeParameters, error)
type ParameterProcessor ¶ added in v1.14.0
func (*ParameterProcessor) ExtractAndDefaultParameters ¶ added in v1.14.0
func (pp *ParameterProcessor) ExtractAndDefaultParameters(parameters map[string]string, extraVolumeLabels map[string]string, extraTags map[string]string) (DiskParameters, error)
ExtractAndDefaultParameters will take the relevant parameters from a map and put them into a well defined struct making sure to default unspecified fields. extraVolumeLabels are added as labels; if there are also labels specified in parameters, any matching extraVolumeLabels will be overridden.
type SnapshotParameters ¶ added in v1.0.3
type SnapshotParameters struct { StorageLocations []string SnapshotType string ImageFamily string Tags map[string]string Labels map[string]string ResourceTags map[string]string }
SnapshotParameters contains normalized and defaulted parameters for snapshots
func ExtractAndDefaultSnapshotParameters ¶ added in v1.0.3
type StoragePool ¶ added in v1.13.0
func ParseStoragePools ¶ added in v1.13.0
func ParseStoragePools(storagePools string) ([]StoragePool, error)
ParseStoragePools returns an error if none of the given storagePools (delimited by a comma) are in the format projects/project/zones/zone/storagePools/storagePool.
func StoragePoolInZone ¶ added in v1.13.0
func StoragePoolInZone(storagePools []StoragePool, zone string) *StoragePool
type TemporaryError ¶ added in v1.12.11
type TemporaryError struct {
// contains filtered or unexported fields
}
TemporaryError wraps an error with a temporary error code. It implements the error interface. Do not return TemporaryError directly from CSI Spec API calls, as CSI Spec API calls MUST return a standard gRPC status. If TemporaryErrors are returned from helper functions within a CSI Spec API method, make sure the outer CSI Spec API method returns a standard gRPC status. (e.g. LoggedError(tempErr) )
func NewTemporaryError ¶ added in v1.12.11
func NewTemporaryError(code codes.Code, err error) *TemporaryError
func (*TemporaryError) Error ¶ added in v1.12.11
func (te *TemporaryError) Error() string
Error returns a readable representation of the TemporaryError.
func (*TemporaryError) GRPCStatus ¶ added in v1.12.11
func (te *TemporaryError) GRPCStatus() *status.Status
GRPCStatus extracts the underlying gRPC Status error. This method is necessary to fulfill the grpcstatus interface described in https://pkg.go.dev/google.golang.org/grpc/status#FromError. FromError is used in CodeForError to get existing error codes from status errors.
func (*TemporaryError) Unwrap ¶ added in v1.12.11
func (te *TemporaryError) Unwrap() error
Unwrap extracts the original error.
type VolumeLocks ¶ added in v0.6.0
type VolumeLocks struct {
// contains filtered or unexported fields
}
VolumeLocks implements a map with atomic operations. It stores a set of all volume IDs with an ongoing operation.
func NewVolumeLocks ¶ added in v0.6.0
func NewVolumeLocks() *VolumeLocks
func (*VolumeLocks) Release ¶ added in v0.6.0
func (vl *VolumeLocks) Release(volumeID string)
func (*VolumeLocks) TryAcquire ¶ added in v0.6.0
func (vl *VolumeLocks) TryAcquire(volumeID string) bool
TryAcquire tries to acquire the lock for operating on volumeID and returns true if successful. If another operation is already using volumeID, returns false.