const GCEPDDriverName … const GCEPDInTreePluginName … const GCEPDTopologyKey … const volIDZonalFmt … const volIDRegionalFmt … const volIDProjectValue … const volIDRegionalityValue … const volIDZoneValue … const volIDDiskNameValue … const volIDTotalElements … const nodeIDFmt … const UnspecifiedValue … var _ … type gcePersistentDiskCSITranslator … // NewGCEPersistentDiskCSITranslator returns a new instance of gcePersistentDiskTranslator func NewGCEPersistentDiskCSITranslator() InTreePlugin { … } func generateToplogySelectors(key string, values []string) []v1.TopologySelectorTerm { … } // TranslateInTreeStorageClassToCSI translates InTree GCE storage class parameters to CSI storage class func (g *gcePersistentDiskCSITranslator) TranslateInTreeStorageClassToCSI(logger klog.Logger, sc *storage.StorageClass) (*storage.StorageClass, error) { … } // backwardCompatibleAccessModes translates all instances of ReadWriteMany // access mode from the in-tree plugin to ReadWriteOnce. This is because in-tree // plugin never supported ReadWriteMany but also did not validate or enforce // this access mode for pre-provisioned volumes. The GCE PD CSI Driver validates // and enforces (fails) ReadWriteMany. Therefore we treat all in-tree // ReadWriteMany as ReadWriteOnce volumes to not break legacy volumes. It also // takes [ReadWriteOnce, ReadOnlyMany] and makes it ReadWriteOnce. This is // because the in-tree plugin does not enforce access modes and just attaches // the disk in ReadWriteOnce mode; however, the CSI external-attacher will fail // this combination because technically [ReadWriteOnce, ReadOnlyMany] is not // supportable on an attached volume // See: https://github.com/kubernetes-csi/external-attacher/issues/153 func backwardCompatibleAccessModes(ams []v1.PersistentVolumeAccessMode) []v1.PersistentVolumeAccessMode { … } // TranslateInTreeInlineVolumeToCSI takes a Volume with GCEPersistentDisk set from in-tree // and converts the GCEPersistentDisk source to a CSIPersistentVolumeSource func (g *gcePersistentDiskCSITranslator) TranslateInTreeInlineVolumeToCSI(logger klog.Logger, volume *v1.Volume, podNamespace string) (*v1.PersistentVolume, error) { … } // TranslateInTreePVToCSI takes a PV with GCEPersistentDisk set from in-tree // and converts the GCEPersistentDisk source to a CSIPersistentVolumeSource func (g *gcePersistentDiskCSITranslator) TranslateInTreePVToCSI(logger klog.Logger, pv *v1.PersistentVolume) (*v1.PersistentVolume, error) { … } // TranslateCSIPVToInTree takes a PV with CSIPersistentVolumeSource set and // translates the GCE PD CSI source to a GCEPersistentDisk source. func (g *gcePersistentDiskCSITranslator) TranslateCSIPVToInTree(pv *v1.PersistentVolume) (*v1.PersistentVolume, error) { … } // CanSupport tests whether the plugin supports a given persistent volume // specification from the API. The spec pointer should be considered // const. func (g *gcePersistentDiskCSITranslator) CanSupport(pv *v1.PersistentVolume) bool { … } // CanSupportInline tests whether the plugin supports a given inline volume // specification from the API. The spec pointer should be considered // const. func (g *gcePersistentDiskCSITranslator) CanSupportInline(volume *v1.Volume) bool { … } // GetInTreePluginName returns the name of the intree plugin driver func (g *gcePersistentDiskCSITranslator) GetInTreePluginName() string { … } // GetCSIPluginName returns the name of the CSI plugin func (g *gcePersistentDiskCSITranslator) GetCSIPluginName() string { … } // RepairVolumeHandle returns a fully specified volume handle by inferring // project, zone/region from the node ID if the volume handle has UNSPECIFIED // sections func (g *gcePersistentDiskCSITranslator) RepairVolumeHandle(volumeHandle, nodeID string) (string, error) { … } func pdNameFromVolumeID(id string) (string, error) { … } // TODO: Replace this with the imported one from GCE PD CSI Driver when // the driver removes all k8s/k8s dependencies func gceGetRegionFromZones(zones []string) (string, error) { … }