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 s3fsMounter struct {
|
||||
bucket *s3.Bucket
|
||||
meta *s3.FSMeta
|
||||
url string
|
||||
region string
|
||||
pwFileContent string
|
||||
|
@ -19,9 +20,9 @@ const (
|
|||
s3fsCmd = "s3fs"
|
||||
)
|
||||
|
||||
func newS3fsMounter(b *s3.Bucket, cfg *s3.Config) (Mounter, error) {
|
||||
func newS3fsMounter(meta *s3.FSMeta, cfg *s3.Config) (Mounter, error) {
|
||||
return &s3fsMounter{
|
||||
bucket: b,
|
||||
meta: meta,
|
||||
url: cfg.Endpoint,
|
||||
region: cfg.Region,
|
||||
pwFileContent: cfg.AccessKeyID + ":" + cfg.SecretAccessKey,
|
||||
|
@ -41,8 +42,8 @@ func (s3fs *s3fsMounter) Mount(source string, target string) error {
|
|||
return err
|
||||
}
|
||||
args := []string{
|
||||
fmt.Sprintf("%s:/%s", s3fs.bucket.Name, s3fs.bucket.FSPath),
|
||||
fmt.Sprintf("%s", target),
|
||||
fmt.Sprintf("%s:/%s", s3fs.meta.BucketName, path.Join(s3fs.meta.Prefix, s3fs.meta.FSPath)),
|
||||
target,
|
||||
"-o", "use_path_request_style",
|
||||
"-o", fmt.Sprintf("url=%s", s3fs.url),
|
||||
"-o", fmt.Sprintf("endpoint=%s", s3fs.region),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue