add function annotation

This commit is contained in:
wnxn
2018-06-08 17:42:31 +08:00
parent 0ef5506251
commit e75c5ffa5b

View File

@@ -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 &&