From 7bb4406d4e46d247542236184c71bbfe06ec4420 Mon Sep 17 00:00:00 2001 From: Mike Tougeron Date: Wed, 9 Feb 2022 12:21:06 -0800 Subject: [PATCH] Fix the path to the VolumeHandle field --- kubernetes.go | 4 ++-- main.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/kubernetes.go b/kubernetes.go index b305ac2..817c4d8 100644 --- a/kubernetes.go +++ b/kubernetes.go @@ -50,7 +50,7 @@ const ( regexpAWSVolumeID = `^aws:\/\/\w{2}-\w{4,9}-\d\w\/(vol-\w+)$` ) -func buildClient(kubeconfig string, kubeContext string) (*kubernetes.Clientset, error) { +func BuildClient(kubeconfig string, kubeContext string) (*kubernetes.Clientset, error) { config, err := rest.InClusterConfig() if err != nil { if kubeconfig == "" { @@ -258,7 +258,7 @@ func processPersistentVolumeClaim(pvc *corev1.PersistentVolumeClaim) (string, ma log.Errorf("cannot get volume.beta.kubernetes.io/storage-provisioner annotation") return "", nil, errors.New("cannot get volume.beta.kubernetes.io/storage-provisioner annotation") } else if provisionedBy == "ebs.csi.aws.com" { - volumeID = pv.Spec.CSI.VolumeHandle + volumeID = pv.Spec.PersistentVolumeSource.CSI.VolumeHandle } else if provisionedBy == "kubernetes.io/aws-ebs" { volumeID = parseAWSVolumeID(pv.Spec.PersistentVolumeSource.AWSElasticBlockStore.VolumeID) } diff --git a/main.go b/main.go index b1f1484..bea4fe1 100644 --- a/main.go +++ b/main.go @@ -161,7 +161,7 @@ func main() { os.Exit(1) } - k8sClient, err = buildClient(kubeconfig, kubeContext) + k8sClient, err = BuildClient(kubeconfig, kubeContext) if err != nil { log.Fatalln("Unable to create kubernetes client", err) os.Exit(1)