Use volume ID as a prefix if the bucket is fixed in the storage class
With this, each volume will get its own prefix within the bucket if it is configured in the storage class. This also ensures backwards compatibility with older volumes that have been created in earlier versions of csi-s3.
This commit is contained in:
parent
1b154cd051
commit
9ee2e2c977
17 changed files with 195 additions and 117 deletions
pkg/mounter
|
@ -3,13 +3,14 @@ package mounter
|
|||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
|
||||
"github.com/ctrox/csi-s3/pkg/s3"
|
||||
)
|
||||
|
||||
// Implements Mounter
|
||||
type rcloneMounter struct {
|
||||
bucket *s3.Bucket
|
||||
meta *s3.FSMeta
|
||||
url string
|
||||
region string
|
||||
accessKeyID string
|
||||
|
@ -20,9 +21,9 @@ const (
|
|||
rcloneCmd = "rclone"
|
||||
)
|
||||
|
||||
func newRcloneMounter(b *s3.Bucket, cfg *s3.Config) (Mounter, error) {
|
||||
func newRcloneMounter(meta *s3.FSMeta, cfg *s3.Config) (Mounter, error) {
|
||||
return &rcloneMounter{
|
||||
bucket: b,
|
||||
meta: meta,
|
||||
url: cfg.Endpoint,
|
||||
region: cfg.Region,
|
||||
accessKeyID: cfg.AccessKeyID,
|
||||
|
@ -41,7 +42,7 @@ func (rclone *rcloneMounter) Unstage(stageTarget string) error {
|
|||
func (rclone *rcloneMounter) Mount(source string, target string) error {
|
||||
args := []string{
|
||||
"mount",
|
||||
fmt.Sprintf(":s3:%s/%s", rclone.bucket.Name, rclone.bucket.FSPath),
|
||||
fmt.Sprintf(":s3:%s", path.Join(rclone.meta.BucketName, rclone.meta.Prefix, rclone.meta.FSPath)),
|
||||
fmt.Sprintf("%s", target),
|
||||
"--daemon",
|
||||
"--s3-provider=AWS",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue