diff --git a/main.go b/main.go index 375a95f..442e645 100644 --- a/main.go +++ b/main.go @@ -52,12 +52,11 @@ func main() { }, UpdateFunc: func(_, obj interface{}) { pvc, ok := obj.(*corev1.PersistentVolumeClaim) - owner := pvc.OwnerReferences - if !ok || pvc.DeletionTimestamp == nil || owner == nil { + if !ok || pvc.DeletionTimestamp == nil || pvc.OwnerReferences == nil { return } - if owner[0].APIVersion == "tekton.dev/v1alpha1" && - owner[0].Kind == "PipelineRun" { + if pvc.OwnerReferences[0].APIVersion == "tekton.dev/v1alpha1" && + pvc.OwnerReferences[0].Kind == "PipelineRun" { pvs := cl.CoreV1().PersistentVolumes() pv, err := pvs.Get(pvc.Spec.VolumeName, metav1.GetOptions{}) if err != nil {