Skip to content

Commit

Permalink
pb-4467: Added support for passing sse type in the native CSI backup …
Browse files Browse the repository at this point in the history
…path.
  • Loading branch information
sivakumar subraani authored and siva-portworx committed Sep 30, 2023
1 parent b128c17 commit 8fb30a7
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion drivers/volume/csi/csi.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"path/filepath"
"strings"

"github.com/aws/aws-sdk-go/service/s3/s3manager"
kSnapshotv1 "github.com/kubernetes-csi/external-snapshotter/client/v4/apis/volumesnapshot/v1"
kSnapshotv1beta1 "github.com/kubernetes-csi/external-snapshotter/client/v4/apis/volumesnapshot/v1beta1"
kSnapshotClient "github.com/kubernetes-csi/external-snapshotter/client/v4/clientset/versioned"
Expand All @@ -27,6 +28,7 @@ import (
"github.com/portworx/sched-ops/k8s/core"
storkops "github.com/portworx/sched-ops/k8s/stork"
"github.com/sirupsen/logrus"
"gocloud.dev/blob"
"gocloud.dev/gcerrors"
v1 "k8s.io/api/core/v1"
storagev1 "k8s.io/api/storage/v1"
Expand Down Expand Up @@ -576,8 +578,23 @@ func (c *csi) uploadObject(
}
}

var options blob.WriterOptions
if backupLocation.Location.S3Config != nil {
sseType := backupLocation.Location.S3Config.SSE
if len(sseType) != 0 {
beforeWrite := func(asFunc func(interface{}) bool) error {
var input *s3manager.UploadInput
if asFunc(&input) {
input.ServerSideEncryption = &sseType
}
return nil
}
options = blob.WriterOptions{BeforeWrite: beforeWrite}
}
}

objectPath := controllers.GetObjectPath(backup)
writer, err := bucket.NewWriter(context.TODO(), filepath.Join(objectPath, objectName), nil)
writer, err := bucket.NewWriter(context.TODO(), filepath.Join(objectPath, objectName), &options)
if err != nil {
return err
}
Expand Down

0 comments on commit 8fb30a7

Please sign in to comment.