Skip to content

Commit

Permalink
Merge pull request #40 from mtougeron/fix-attribute-path
Browse files Browse the repository at this point in the history
Fix the path to the VolumeHandle field
  • Loading branch information
mtougeron authored Feb 9, 2022
2 parents c54c9bc + 7bb4406 commit cfb1345
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 == "" {
Expand Down Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit cfb1345

Please sign in to comment.