Commit 360d9bfe authored by Cyrill Troxler's avatar Cyrill Troxler
Browse files

Rename credentials to config

parent f16c868b
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -40,14 +40,14 @@ var (
func main() {
	flag.Parse()

	cr := &s3.Credentials{
	cfg := &s3.Config{
		AccessKeyID:     *accessKeyID,
		SecretAccessKey: *secretAccessKey,
		Endpoint:        *s3endpoint,
		Region:          *region,
	}

	driver, err := s3.NewS3(*nodeID, *endpoint, cr)
	driver, err := s3.NewS3(*nodeID, *endpoint, cfg)
	if err != nil {
		log.Fatal(err)
	}
+2 −2
Original line number Diff line number Diff line
package s3

// Credentials holds s3 credentials and parameters
type Credentials struct {
// Config holds values to configure the driver
type Config struct {
	AccessKeyID     string
	SecretAccessKey string
	Region          string
+7 −7
Original line number Diff line number Diff line
@@ -11,11 +11,11 @@ import (

const defaultRegion = "us-east-1"

func goofysMount(bucket string, cr *Credentials, targetPath string) error {
	cfg := &goofys.Config{
func goofysMount(bucket string, cfg *Config, targetPath string) error {
	goofysCfg := &goofys.Config{
		MountPoint: targetPath,
		Endpoint:   cr.Endpoint,
		Region:     cr.Region,
		Endpoint:   cfg.Endpoint,
		Region:     cfg.Region,
		DirMode:    0755,
		FileMode:   0644,
		MountOptions: map[string]string{
@@ -25,10 +25,10 @@ func goofysMount(bucket string, cr *Credentials, targetPath string) error {
	if cfg.Endpoint != "" {
		cfg.Region = defaultRegion
	}
	os.Setenv("AWS_ACCESS_KEY_ID", cr.AccessKeyID)
	os.Setenv("AWS_SECRET_ACCESS_KEY", cr.SecretAccessKey)
	os.Setenv("AWS_ACCESS_KEY_ID", cfg.AccessKeyID)
	os.Setenv("AWS_SECRET_ACCESS_KEY", cfg.SecretAccessKey)

	_, _, err := goofys.Mount(context.Background(), bucket, cfg)
	_, _, err := goofys.Mount(context.Background(), bucket, goofysCfg)

	if err != nil {
		return fmt.Errorf("Error mounting via goofys: %s", err)
+2 −2
Original line number Diff line number Diff line
@@ -87,11 +87,11 @@ func (ns *nodeServer) NodePublishVolume(ctx context.Context, req *csi.NodePublis

	mounter, exists := attrib[mounterKey]
	if !exists || mounter == s3fsMounter {
		if err := s3fsMount(volumeID, ns.s3.cr, targetPath); err != nil {
		if err := s3fsMount(volumeID, ns.s3.cfg, targetPath); err != nil {
			return nil, err
		}
	} else if mounter == goofysMounter {
		if err := goofysMount(volumeID, ns.s3.cr, targetPath); err != nil {
		if err := goofysMount(volumeID, ns.s3.cfg, targetPath); err != nil {
			return nil, err
		}
	} else {
+6 −6
Original line number Diff line number Diff line
@@ -13,7 +13,7 @@ const (
)

type s3Client struct {
	cr    *Credentials
	cfg   *Config
	minio *minio.Client
}

@@ -21,11 +21,11 @@ type bucketMetadata struct {
	CapacityBytes int64
}

func newS3Client(cr *Credentials) (*s3Client, error) {
func newS3Client(cfg *Config) (*s3Client, error) {
	var client = &s3Client{}

	client.cr = cr
	u, err := url.Parse(client.cr.Endpoint)
	client.cfg = cfg
	u, err := url.Parse(client.cfg.Endpoint)
	if err != nil {
		return nil, err
	}
@@ -34,7 +34,7 @@ func newS3Client(cr *Credentials) (*s3Client, error) {
	if u.Port() != "" {
		endpoint = u.Hostname() + ":" + u.Port()
	}
	minioClient, err := minio.New(endpoint, client.cr.AccessKeyID, client.cr.SecretAccessKey, ssl)
	minioClient, err := minio.New(endpoint, client.cfg.AccessKeyID, client.cfg.SecretAccessKey, ssl)
	if err != nil {
		return nil, err
	}
@@ -47,7 +47,7 @@ func (client *s3Client) bucketExists(bucketName string) (bool, error) {
}

func (client *s3Client) createBucket(bucketName string) error {
	return client.minio.MakeBucket(bucketName, client.cr.Region)
	return client.minio.MakeBucket(bucketName, client.cfg.Region)
}

func (client *s3Client) removeBucket(bucketName string) error {
Loading