@@ -90,13 +90,10 @@ func (s *storageClassesSearcher) Search(namespace string, conditions *params.Con
|
|||||||
r := make([]interface{}, 0)
|
r := make([]interface{}, 0)
|
||||||
for _, i := range result {
|
for _, i := range result {
|
||||||
count := s.countPersistentVolumeClaims(i.Name)
|
count := s.countPersistentVolumeClaims(i.Name)
|
||||||
isSnapshotAllow := s.isSnapshotAllowed(i.Provisioner)
|
|
||||||
if i.Annotations == nil {
|
if i.Annotations == nil {
|
||||||
i.Annotations = make(map[string]string)
|
i.Annotations = make(map[string]string)
|
||||||
i.Annotations["kubesphere.io/pvc-count"] = string(count)
|
|
||||||
i.Annotations["kubesphere.io/allow-snapshot"] = strconv.FormatBool(isSnapshotAllow)
|
|
||||||
}
|
}
|
||||||
|
i.Annotations["kubesphere.io/pvc-count"] = strconv.Itoa(count)
|
||||||
r = append(r, i)
|
r = append(r, i)
|
||||||
}
|
}
|
||||||
return r, nil
|
return r, nil
|
||||||
@@ -117,20 +114,3 @@ func (s *storageClassesSearcher) countPersistentVolumeClaims(name string) int {
|
|||||||
|
|
||||||
return count
|
return count
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *storageClassesSearcher) isSnapshotAllowed(provisioner string) bool {
|
|
||||||
if len(provisioner) == 0 {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
volumeSnapshotClasses, err := s.snapshotInformers.Snapshot().V1beta1().VolumeSnapshotClasses().Lister().List(labels.Everything())
|
|
||||||
if err != nil {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
for _, volumeSnapshotClass := range volumeSnapshotClasses {
|
|
||||||
if volumeSnapshotClass.Driver == provisioner {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user