type persistentVolumeOrderedIndex … func newPersistentVolumeOrderedIndex() persistentVolumeOrderedIndex { … } // accessModesIndexFunc is an indexing function that returns a persistent // volume's AccessModes as a string func accessModesIndexFunc(obj interface{ … } // listByAccessModes returns all volumes with the given set of // AccessModeTypes. The list is unsorted! func (pvIndex *persistentVolumeOrderedIndex) listByAccessModes(modes []v1.PersistentVolumeAccessMode) ([]*v1.PersistentVolume, error) { … } // find returns the nearest PV from the ordered list or nil if a match is not found func (pvIndex *persistentVolumeOrderedIndex) findByClaim(claim *v1.PersistentVolumeClaim, delayBinding bool) (*v1.PersistentVolume, error) { … } // findBestMatchForClaim is a convenience method that finds a volume by the claim's AccessModes and requests for Storage func (pvIndex *persistentVolumeOrderedIndex) findBestMatchForClaim(claim *v1.PersistentVolumeClaim, delayBinding bool) (*v1.PersistentVolume, error) { … } // allPossibleMatchingAccessModes returns an array of AccessMode arrays that // can satisfy a user's requested modes. // // see comments in the Find func above regarding indexing. // // allPossibleMatchingAccessModes gets all stringified accessmodes from the // index and returns all those that contain at least all of the requested // mode. // // For example, assume the index contains 2 types of PVs where the stringified // accessmodes are: // // "RWO,ROX" -- some number of GCEPDs // "RWO,ROX,RWX" -- some number of NFS volumes // // A request for RWO could be satisfied by both sets of indexed volumes, so // allPossibleMatchingAccessModes returns: // // [][]v1.PersistentVolumeAccessMode { // []v1.PersistentVolumeAccessMode { // v1.ReadWriteOnce, v1.ReadOnlyMany, // }, // []v1.PersistentVolumeAccessMode { // v1.ReadWriteOnce, v1.ReadOnlyMany, v1.ReadWriteMany, // }, // } // // A request for RWX can be satisfied by only one set of indexed volumes, so // the return is: // // [][]v1.PersistentVolumeAccessMode { // []v1.PersistentVolumeAccessMode { // v1.ReadWriteOnce, v1.ReadOnlyMany, v1.ReadWriteMany, // }, // } // // This func returns modes with ascending levels of modes to give the user // what is closest to what they actually asked for. func (pvIndex *persistentVolumeOrderedIndex) allPossibleMatchingAccessModes(requestedModes []v1.PersistentVolumeAccessMode) [][]v1.PersistentVolumeAccessMode { … } type byAccessModes … func (c byAccessModes) Less(i, j int) bool { … } func (c byAccessModes) Swap(i, j int) { … } func (c byAccessModes) Len() int { … } func claimToClaimKey(claim *v1.PersistentVolumeClaim) string { … } func claimrefToClaimKey(claimref *v1.ObjectReference) string { … }