add function annotation
This commit is contained in:
@@ -13,13 +13,13 @@ type PodListByPvc struct {
|
||||
Pods []v12.Pod `json:"pods"`
|
||||
}
|
||||
|
||||
// List pods of a specific persistent volume claims
|
||||
func GetPodListByPvc(pvc string, ns string) (res []v12.Pod, err error) {
|
||||
cli := client.NewK8sClient()
|
||||
podList, err := cli.CoreV1().Pods(ns).List(v1.ListOptions{})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for _, pod := range podList.Items {
|
||||
if IsPvcInPod(pod, pvc) == true {
|
||||
res = append(res, pod)
|
||||
@@ -28,6 +28,7 @@ func GetPodListByPvc(pvc string, ns string) (res []v12.Pod, err error) {
|
||||
return res, nil
|
||||
}
|
||||
|
||||
// Check if the persistent volume claim is related to the pod
|
||||
func IsPvcInPod(pod v12.Pod, pvcname string) bool {
|
||||
for _, v := range pod.Spec.Volumes {
|
||||
if v.VolumeSource.PersistentVolumeClaim != nil &&
|
||||
|
||||
Reference in New Issue
Block a user