Skip to content

Commit

Permalink
Merge pull request #1 from viveksinghggits/fix-default-sc
Browse files Browse the repository at this point in the history
Fix PVC creation if SC is not specified
  • Loading branch information
viveksinghggits authored Nov 3, 2024
2 parents e184f33 + ec2dc56 commit f34ad57
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions cmd/create_pvc.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func (o *CreatePVCOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args
}

func (o *CreatePVCOptions) createPVCObject() *corev1.PersistentVolumeClaim {
return &corev1.PersistentVolumeClaim{
pvc := &corev1.PersistentVolumeClaim{
ObjectMeta: metav1.ObjectMeta{
Name: o.Name,
Namespace: o.Namespace,
Expand All @@ -107,12 +107,17 @@ func (o *CreatePVCOptions) createPVCObject() *corev1.PersistentVolumeClaim {
"storage": resource.MustParse(fmt.Sprintf("%sGi", o.Size)),
},
},
StorageClassName: &o.StorageClass,
AccessModes: []corev1.PersistentVolumeAccessMode{
corev1.ReadWriteOnce,
},
},
}

if o.StorageClass != "" {
pvc.Spec.StorageClassName = &o.StorageClass
}

return pvc
}

func (o *CreatePVCOptions) Run() error {
Expand Down

0 comments on commit f34ad57

Please sign in to comment.