diff --git a/examples/example.BucketClass.yaml b/examples/example.BucketClass.yaml index 35e91af..9fd08fb 100644 --- a/examples/example.BucketClass.yaml +++ b/examples/example.BucketClass.yaml @@ -5,6 +5,6 @@ metadata: driverName: objectstorage.cosi.linode.com deletionPolicy: Delete parameters: - cosi.linode.com/v1/region: us-east-1 + cosi.linode.com/v1/region: us-east cosi.linode.com/v1/acl: private cosi.linode.com/v1/cors: disabled diff --git a/pkg/linodeclient/stubclient/stubclient.go b/pkg/linodeclient/stubclient/stubclient.go index 2c78185..ae852a0 100644 --- a/pkg/linodeclient/stubclient/stubclient.go +++ b/pkg/linodeclient/stubclient/stubclient.go @@ -91,7 +91,7 @@ func (c *Client) CreateObjectStorageBucket(ctx context.Context, opt linodego.Obj return nil, err } - key := fmt.Sprintf("%s/%s", opt.Cluster, opt.Label) + key := fmt.Sprintf("%s/%s", opt.Region, opt.Label) bucket, ok := c.objectStorageBuckets[key] if ok { @@ -106,7 +106,7 @@ func (c *Client) CreateObjectStorageBucket(ctx context.Context, opt linodego.Obj bucket = &linodego.ObjectStorageBucket{ Label: opt.Label, - Cluster: opt.Cluster, + Region: opt.Region, Hostname: fmt.Sprintf("%s.linodeobjects.com", opt.Label), } c.objectStorageBuckets[key] = bucket @@ -126,12 +126,12 @@ func (c *Client) CreateObjectStorageBucket(ctx context.Context, opt linodego.Obj } // GetObjectStorageBucket is a stub function that stubs the behavior of GetObjectStorageBucket call from linodego.Client. -func (c *Client) GetObjectStorageBucket(ctx context.Context, clusterID, label string) (*linodego.ObjectStorageBucket, error) { +func (c *Client) GetObjectStorageBucket(ctx context.Context, region, label string) (*linodego.ObjectStorageBucket, error) { if err := handleForcedFailure(ctx); err != nil { return nil, err } - key := fmt.Sprintf("%s/%s", clusterID, label) + key := fmt.Sprintf("%s/%s", region, label) obj, ok := c.objectStorageBuckets[key] if ok { @@ -144,12 +144,12 @@ func (c *Client) GetObjectStorageBucket(ctx context.Context, clusterID, label st } // DeleteObjectStorageBucket is a stub function that stubs the behavior of DeleteObjectStorageBucket call from linodego.Client. -func (c *Client) DeleteObjectStorageBucket(ctx context.Context, clusterID, label string) error { +func (c *Client) DeleteObjectStorageBucket(ctx context.Context, region, label string) error { if err := handleForcedFailure(ctx); err != nil { return err } - key := fmt.Sprintf("%s/%s", clusterID, label) + key := fmt.Sprintf("%s/%s", region, label) bucket, ok := c.objectStorageBuckets[key] @@ -169,12 +169,12 @@ func (c *Client) DeleteObjectStorageBucket(ctx context.Context, clusterID, label } // GetObjectStorageBucketAccess is a stub function that stubs the behavior of GetObjectStorageBucketAccess call from linodego.Client. -func (c *Client) GetObjectStorageBucketAccess(ctx context.Context, clusterID, label string) (*linodego.ObjectStorageBucketAccess, error) { +func (c *Client) GetObjectStorageBucketAccess(ctx context.Context, region, label string) (*linodego.ObjectStorageBucketAccess, error) { if err := handleForcedFailure(ctx); err != nil { return nil, err } - key := fmt.Sprintf("%s/%s", clusterID, label) + key := fmt.Sprintf("%s/%s", region, label) obj, ok := c.objectStorageBucketAccesses[key] if ok { @@ -187,12 +187,12 @@ func (c *Client) GetObjectStorageBucketAccess(ctx context.Context, clusterID, la } // UpdateObjectStorageBucketAccess is a stub function that stubs the behavior of UpdateObjectStorageBucketAccess call from linodego.Client. -func (c *Client) UpdateObjectStorageBucketAccess(ctx context.Context, clusterID, label string, opt linodego.ObjectStorageBucketUpdateAccessOptions) error { +func (c *Client) UpdateObjectStorageBucketAccess(ctx context.Context, region, label string, opt linodego.ObjectStorageBucketUpdateAccessOptions) error { if err := handleForcedFailure(ctx); err != nil { return err } - key := fmt.Sprintf("%s/%s", clusterID, label) + key := fmt.Sprintf("%s/%s", region, label) access, ok := c.objectStorageBucketAccesses[key] if !ok { diff --git a/pkg/linodeclient/stubclient/stubclient_test.go b/pkg/linodeclient/stubclient/stubclient_test.go index efcb804..db7f9ff 100644 --- a/pkg/linodeclient/stubclient/stubclient_test.go +++ b/pkg/linodeclient/stubclient/stubclient_test.go @@ -30,7 +30,7 @@ import ( var ( testBucket = &linodego.ObjectStorageBucket{ Label: "test-label", - Cluster: "test-cluster", + Region: "test-region", Hostname: "test-label.linodeobjects.com", Objects: 0, Size: 0, @@ -43,7 +43,7 @@ var ( testKeyBucketAccessList = []linodego.ObjectStorageKeyBucketAccess{ { - Cluster: "test-cluster", + Region: "test-region", BucketName: "test-label", Permissions: "test-permissions", }, @@ -85,7 +85,7 @@ func TestNew(t *testing.T) { { testName: "bucket accesses input", input: []stubclient.Option{ - stubclient.WithBucketAccess(testBucketAccess, testBucket.Cluster, testBucket.Label), + stubclient.WithBucketAccess(testBucketAccess, testBucket.Region, testBucket.Label), }, }, { @@ -98,7 +98,7 @@ func TestNew(t *testing.T) { testName: "mixed input", input: []stubclient.Option{ stubclient.WithBucket(testBucket), - stubclient.WithBucketAccess(testBucketAccess, testBucket.Cluster, testBucket.Label), + stubclient.WithBucketAccess(testBucketAccess, testBucket.Region, testBucket.Label), stubclient.WithKey(testKey), }, }, @@ -131,9 +131,9 @@ func TestCreateObjectStorageBucket(t *testing.T) { testName: "valid input", client: stubclient.New(), opts: linodego.ObjectStorageBucketCreateOptions{ - Cluster: testBucket.Cluster, - Label: testBucket.Label, - ACL: linodego.ACLPrivate, + Region: testBucket.Region, + Label: testBucket.Label, + ACL: linodego.ACLPrivate, }, expectedError: nil, expectedValue: testBucket, @@ -142,9 +142,9 @@ func TestCreateObjectStorageBucket(t *testing.T) { testName: "duplicated", client: stubclient.New(stubclient.WithBucket(testBucket)), opts: linodego.ObjectStorageBucketCreateOptions{ - Cluster: testBucket.Cluster, - Label: testBucket.Label, - ACL: linodego.ACLPrivate, + Region: testBucket.Region, + Label: testBucket.Label, + ACL: linodego.ACLPrivate, }, expectedError: nil, expectedValue: testBucket, @@ -153,7 +153,7 @@ func TestCreateObjectStorageBucket(t *testing.T) { testName: "with CORS", client: stubclient.New(), opts: linodego.ObjectStorageBucketCreateOptions{ - Cluster: testBucket.Cluster, + Region: testBucket.Region, Label: testBucket.Label, ACL: linodego.ACLPrivate, CorsEnabled: &testBool, @@ -165,9 +165,9 @@ func TestCreateObjectStorageBucket(t *testing.T) { testName: "invalid ACL", client: stubclient.New(), opts: linodego.ObjectStorageBucketCreateOptions{ - Cluster: testBucket.Cluster, - Label: testBucket.Label, - ACL: "invalid-acl", + Region: testBucket.Region, + Label: testBucket.Label, + ACL: "invalid-acl", }, expectedError: &linodego.Error{Code: http.StatusBadRequest}, expectedValue: nil, @@ -226,7 +226,7 @@ func TestGetObjectStorageBucket(t *testing.T) { testName string ctx context.Context //nolint:containedctx client linodeclient.Client - clusterID string + region string label string expectedValue *linodego.ObjectStorageBucket expectedError error @@ -234,7 +234,7 @@ func TestGetObjectStorageBucket(t *testing.T) { { testName: "valid input", client: stubclient.New(stubclient.WithBucket(testBucket)), - clusterID: testBucket.Cluster, + region: testBucket.Region, label: testBucket.Label, expectedValue: testBucket, expectedError: nil, @@ -242,7 +242,7 @@ func TestGetObjectStorageBucket(t *testing.T) { { testName: "non existent bucket", client: stubclient.New(), - clusterID: "non-existent-cluster", + region: "non-existent-region", label: "non-existent-label", expectedValue: nil, expectedError: &linodego.Error{Code: http.StatusNotFound}, @@ -280,7 +280,7 @@ func TestGetObjectStorageBucket(t *testing.T) { ctx, cancel := testutils.ContextFromT(tc.ctx, t) defer cancel() - actual, err := tc.client.GetObjectStorageBucket(ctx, tc.clusterID, tc.label) + actual, err := tc.client.GetObjectStorageBucket(ctx, tc.region, tc.label) if !errors.Is(err, tc.expectedError) { t.Errorf("expected error: %v, but got: %v", tc.expectedError, err) } @@ -301,34 +301,34 @@ func TestDeleteObjectStorageBucket(t *testing.T) { testName string ctx context.Context //nolint:containedctx client linodeclient.Client - clusterID string + region string label string expectedError error }{ { testName: "valid input", client: stubclient.New(stubclient.WithBucket(testBucket)), - clusterID: testBucket.Cluster, + region: testBucket.Region, label: testBucket.Label, expectedError: nil, }, { testName: "non existent bucket", client: stubclient.New(), - clusterID: testBucket.Cluster, + region: testBucket.Region, label: testBucket.Label, expectedError: &linodego.Error{Code: http.StatusNotFound}, }, { testName: "non empty bucket", client: stubclient.New(stubclient.WithBucket(&linodego.ObjectStorageBucket{ - Cluster: testBucket.Cluster, + Region: testBucket.Region, Label: testBucket.Label, Hostname: testBucket.Hostname, Objects: 10, Size: 102310, })), - clusterID: testBucket.Cluster, + region: testBucket.Region, label: testBucket.Label, expectedError: &linodego.Error{Code: http.StatusBadRequest}, }, @@ -365,7 +365,7 @@ func TestDeleteObjectStorageBucket(t *testing.T) { ctx, cancel := testutils.ContextFromT(tc.ctx, t) defer cancel() - err := tc.client.DeleteObjectStorageBucket(ctx, tc.clusterID, tc.label) + err := tc.client.DeleteObjectStorageBucket(ctx, tc.region, tc.label) if !errors.Is(err, tc.expectedError) { t.Errorf("expected error: %v, but got: %v", tc.expectedError, err) } @@ -380,7 +380,7 @@ func TestGetObjectStorageBucketAccess(t *testing.T) { testName string ctx context.Context //nolint:containedctx client linodeclient.Client - clusterID string + region string label string expectedValue *linodego.ObjectStorageBucketAccess expectedError error @@ -388,9 +388,9 @@ func TestGetObjectStorageBucketAccess(t *testing.T) { { testName: "valid input", client: stubclient.New( - stubclient.WithBucketAccess(testBucketAccess, testBucket.Cluster, testBucket.Label), + stubclient.WithBucketAccess(testBucketAccess, testBucket.Region, testBucket.Label), ), - clusterID: testBucket.Cluster, + region: testBucket.Region, label: testBucket.Label, expectedValue: testBucketAccess, expectedError: nil, @@ -398,7 +398,7 @@ func TestGetObjectStorageBucketAccess(t *testing.T) { { testName: "non existent bucket", client: stubclient.New(), - clusterID: "non-existent-cluster", + region: "non-existent-region", label: "non-existent-label", expectedValue: nil, expectedError: &linodego.Error{Code: http.StatusNotFound}, @@ -436,7 +436,7 @@ func TestGetObjectStorageBucketAccess(t *testing.T) { ctx, cancel := testutils.ContextFromT(tc.ctx, t) defer cancel() - actual, err := tc.client.GetObjectStorageBucketAccess(ctx, tc.clusterID, tc.label) + actual, err := tc.client.GetObjectStorageBucketAccess(ctx, tc.region, tc.label) if !errors.Is(err, tc.expectedError) { t.Errorf("expected error: %v, but got: %v", tc.expectedError, err) } @@ -457,7 +457,7 @@ func TestUpdateObjectStorageBucketAccess(t *testing.T) { testName string ctx context.Context //nolint:containedctx client linodeclient.Client - clusterID string + region string label string opts linodego.ObjectStorageBucketUpdateAccessOptions expectedError error @@ -465,10 +465,10 @@ func TestUpdateObjectStorageBucketAccess(t *testing.T) { { testName: "valid input", client: stubclient.New( - stubclient.WithBucketAccess(testBucketAccess, testBucket.Cluster, testBucket.Label), + stubclient.WithBucketAccess(testBucketAccess, testBucket.Region, testBucket.Label), ), - clusterID: testBucket.Cluster, - label: testBucket.Label, + region: testBucket.Region, + label: testBucket.Label, opts: linodego.ObjectStorageBucketUpdateAccessOptions{ ACL: testBucketAccess.ACL, }, @@ -477,10 +477,10 @@ func TestUpdateObjectStorageBucketAccess(t *testing.T) { { testName: "with CORS", client: stubclient.New( - stubclient.WithBucketAccess(testBucketAccess, testBucket.Cluster, testBucket.Label), + stubclient.WithBucketAccess(testBucketAccess, testBucket.Region, testBucket.Label), ), - clusterID: testBucket.Cluster, - label: testBucket.Label, + region: testBucket.Region, + label: testBucket.Label, opts: linodego.ObjectStorageBucketUpdateAccessOptions{ ACL: testBucketAccess.ACL, CorsEnabled: &testBool, @@ -490,10 +490,10 @@ func TestUpdateObjectStorageBucketAccess(t *testing.T) { { testName: "invalid ACL", client: stubclient.New( - stubclient.WithBucketAccess(testBucketAccess, testBucket.Cluster, testBucket.Label), + stubclient.WithBucketAccess(testBucketAccess, testBucket.Region, testBucket.Label), ), - clusterID: testBucket.Cluster, - label: testBucket.Label, + region: testBucket.Region, + label: testBucket.Label, opts: linodego.ObjectStorageBucketUpdateAccessOptions{ ACL: "invalid-acl", }, @@ -502,7 +502,7 @@ func TestUpdateObjectStorageBucketAccess(t *testing.T) { { testName: "non existent input", client: stubclient.New(), - clusterID: "non-existent-cluster", + region: "non-existent-region", label: "non-existent-label", opts: linodego.ObjectStorageBucketUpdateAccessOptions{}, expectedError: linodego.Error{Code: http.StatusNotFound}, @@ -540,7 +540,7 @@ func TestUpdateObjectStorageBucketAccess(t *testing.T) { ctx, cancel := testutils.ContextFromT(tc.ctx, t) defer cancel() - err := tc.client.UpdateObjectStorageBucketAccess(ctx, tc.clusterID, tc.label, tc.opts) + err := tc.client.UpdateObjectStorageBucketAccess(ctx, tc.region, tc.label, tc.opts) if !errors.Is(err, tc.expectedError) { t.Errorf("expected error: %v, but got: %v", tc.expectedError, err) } diff --git a/pkg/linodeclient/stubclient/stubclientoption.go b/pkg/linodeclient/stubclient/stubclientoption.go index d80b6ae..8e3e9e9 100644 --- a/pkg/linodeclient/stubclient/stubclientoption.go +++ b/pkg/linodeclient/stubclient/stubclientoption.go @@ -26,7 +26,7 @@ type Option func(c *Client) // WithBucket is an option to configure the stub client with an Object Storage bucket. func WithBucket(bucket *linodego.ObjectStorageBucket) Option { return func(c *Client) { - id := fmt.Sprintf("%s/%s", bucket.Cluster, bucket.Label) + id := fmt.Sprintf("%s/%s", bucket.Region, bucket.Label) c.objectStorageBuckets[id] = bucket } } @@ -40,9 +40,9 @@ func WithKey(key *linodego.ObjectStorageKey) Option { } // WithBucketAccess is an option to configure the stub client with Object Storage bucket access. -func WithBucketAccess(bucketAccess *linodego.ObjectStorageBucketAccess, cluster, label string) Option { +func WithBucketAccess(bucketAccess *linodego.ObjectStorageBucketAccess, region, label string) Option { return func(c *Client) { - id := fmt.Sprintf("%s/%s", cluster, label) + id := fmt.Sprintf("%s/%s", region, label) c.objectStorageBucketAccesses[id] = bucketAccess } } diff --git a/pkg/servers/provisioner/consts.go b/pkg/servers/provisioner/consts.go index e06ca50..b2bfc40 100644 --- a/pkg/servers/provisioner/consts.go +++ b/pkg/servers/provisioner/consts.go @@ -70,7 +70,7 @@ var ( const ( KeyBucketID = "bucket.id" KeyBucketLabel = "bucket.label" - KeyBucketCluster = "bucket.cluster" + KeyBucketRegion = "bucket.region" KeyBucketCreationTimestamp = "bucket.created_at" KeyBucketACL = "bucket.acl" KeyBucketCORS = "bucket.cors_enabled" diff --git a/pkg/servers/provisioner/provisioner.go b/pkg/servers/provisioner/provisioner.go index 6b3809f..1347a86 100644 --- a/pkg/servers/provisioner/provisioner.go +++ b/pkg/servers/provisioner/provisioner.go @@ -77,7 +77,7 @@ func (s *Server) DriverCreateBucket(ctx context.Context, req *cosi.DriverCreateB defer span.End() label := req.GetName() - cluster := req.GetParameters()[ParamRegion] + region := req.GetParameters()[ParamRegion] cors := ParamCORSValue(req.GetParameters()[ParamCORS]) acl := linodego.ObjectStorageACL(req.GetParameters()[ParamACL]) @@ -86,24 +86,24 @@ func (s *Server) DriverCreateBucket(ctx context.Context, req *cosi.DriverCreateB } log := s.logAttr( - slog.String(KeyBucketCluster, cluster), + slog.String(KeyBucketRegion, region), slog.String(KeyBucketLabel, label), ).WithGroup("DriverCreateBucket") span.SetAttributes( - attribute.String(KeyBucketCluster, cluster), + attribute.String(KeyBucketRegion, region), attribute.String(KeyBucketLabel, label), ) log.InfoContext(ctx, "bucket creation initiated") - if cluster == "" { + if region == "" { log.ErrorContext(ctx, "required parameter was not provided in the request", "error", ErrMissingRegion) return nil, tracing.Error(span, codes.InvalidArgument, ErrMissingRegion) } - bucket, err := s.client.GetObjectStorageBucket(ctx, cluster, label) + bucket, err := s.client.GetObjectStorageBucket(ctx, region, label) if err != nil { if !errors.Is(err, ErrNotFound) { log.ErrorContext(ctx, "failed to check if bucket exists", "error", err) @@ -111,7 +111,7 @@ func (s *Server) DriverCreateBucket(ctx context.Context, req *cosi.DriverCreateB } opts := linodego.ObjectStorageBucketCreateOptions{ - Cluster: cluster, + Region: region, Label: label, ACL: acl, CorsEnabled: cors.BoolP(), @@ -128,16 +128,16 @@ func (s *Server) DriverCreateBucket(ctx context.Context, req *cosi.DriverCreateB log.InfoContext(ctx, "bucket created") return &cosi.DriverCreateBucketResponse{ - BucketId: bucket.Cluster + "/" + bucket.Label, - BucketInfo: bucketInfo(bucket.Cluster), + BucketId: bucket.Region + "/" + bucket.Label, + BucketInfo: bucketInfo(bucket.Region), }, tracing.Error(span, codes.OK, nil, "bucket created") } log.DebugContext(ctx, "bucket found, checking bucket access", - KeyBucketCreationTimestamp, bucket.Cluster, + KeyBucketCreationTimestamp, bucket.Region, ) - access, err := s.client.GetObjectStorageBucketAccess(ctx, cluster, label) + access, err := s.client.GetObjectStorageBucketAccess(ctx, region, label) if err != nil { log.ErrorContext(ctx, "failed to check bucket access", "error", err) return nil, tracing.Error(span, codes.Internal, fmt.Errorf("failed to check bucket access: %w", err)) @@ -155,8 +155,8 @@ func (s *Server) DriverCreateBucket(ctx context.Context, req *cosi.DriverCreateB log.InfoContext(ctx, "bucket exists") return &cosi.DriverCreateBucketResponse{ - BucketId: bucket.Cluster + "/" + bucket.Label, - BucketInfo: bucketInfo(bucket.Cluster), + BucketId: bucket.Region + "/" + bucket.Label, + BucketInfo: bucketInfo(bucket.Region), }, tracing.Error(span, codes.OK, nil, "bucket exists") } @@ -168,23 +168,23 @@ func (s *Server) DriverDeleteBucket(ctx context.Context, req *cosi.DriverDeleteB ctx, span := s.init(ctx, "DriverDeleteBucket") defer span.End() - cluster, label := parseBucketID(req.GetBucketId()) + region, label := parseBucketID(req.GetBucketId()) log := s.logAttr( slog.String(KeyBucketID, req.GetBucketId()), - slog.String(KeyBucketCluster, cluster), + slog.String(KeyBucketRegion, region), slog.String(KeyBucketLabel, label), ).WithGroup("DriverDeleteBucket") span.SetAttributes( attribute.String(KeyBucketID, req.GetBucketId()), - attribute.String(KeyBucketCluster, cluster), + attribute.String(KeyBucketRegion, region), attribute.String(KeyBucketLabel, label), ) log.InfoContext(ctx, "bucket deletion initiated") - err := s.client.DeleteObjectStorageBucket(ctx, cluster, label) + err := s.client.DeleteObjectStorageBucket(ctx, region, label) if err == nil || errors.Is(err, ErrNotFound) { log.InfoContext(ctx, "bucket deleted") return &cosi.DriverDeleteBucketResponse{}, tracing.Error(span, codes.OK, err, "bucket deleted") @@ -205,7 +205,7 @@ func (s *Server) DriverGrantBucketAccess(ctx context.Context, req *cosi.DriverGr ctx, span := s.init(ctx, "DriverGrantBucketAccess") defer span.End() - cluster, label := parseBucketID(req.GetBucketId()) + region, label := parseBucketID(req.GetBucketId()) name := req.GetName() auth := req.GetAuthenticationType() perms := ParamPermissionsValue(req.GetParameters()[ParamPermissions]) @@ -216,7 +216,7 @@ func (s *Server) DriverGrantBucketAccess(ctx context.Context, req *cosi.DriverGr log := s.logAttr( slog.String(KeyBucketID, req.GetBucketId()), - slog.String(KeyBucketCluster, cluster), + slog.String(KeyBucketRegion, region), slog.String(KeyBucketLabel, label), slog.String(KeyBucketAccessName, name), slog.Any(KeyBucketAccessAuth, auth), @@ -225,7 +225,7 @@ func (s *Server) DriverGrantBucketAccess(ctx context.Context, req *cosi.DriverGr span.SetAttributes( attribute.String(KeyBucketID, req.GetBucketId()), - attribute.String(KeyBucketCluster, cluster), + attribute.String(KeyBucketRegion, region), attribute.String(KeyBucketLabel, label), attribute.String(KeyBucketAccessName, name), attribute.String(KeyBucketAccessAuth, auth.String()), @@ -246,7 +246,7 @@ func (s *Server) DriverGrantBucketAccess(ctx context.Context, req *cosi.DriverGr Label: name, BucketAccess: &[]linodego.ObjectStorageKeyBucketAccess{ { - Cluster: cluster, + Region: region, BucketName: label, Permissions: string(perms), }, @@ -265,7 +265,7 @@ func (s *Server) DriverGrantBucketAccess(ctx context.Context, req *cosi.DriverGr return &cosi.DriverGrantBucketAccessResponse{ AccountId: fmt.Sprintf("%d", key.ID), - Credentials: credentials(cluster, label, key.AccessKey, key.SecretKey), + Credentials: credentials(region, label, key.AccessKey, key.SecretKey), }, tracing.Error(span, codes.OK, nil) } @@ -276,13 +276,13 @@ func (s *Server) DriverRevokeBucketAccess(ctx context.Context, req *cosi.DriverR ctx, span := s.init(ctx, "DriverRevokeBucketAccess") defer span.End() - cluster, label := parseBucketID(req.GetBucketId()) + region, label := parseBucketID(req.GetBucketId()) id, err := strconv.Atoi(req.GetAccountId()) log := s.logAttr( slog.String(KeyBucketID, req.GetBucketId()), slog.String(KeyBucketAccessIDRaw, req.GetBucketId()), - slog.String(KeyBucketCluster, cluster), + slog.String(KeyBucketRegion, region), slog.String(KeyBucketLabel, label), slog.Int(KeyBucketAccessID, id), ).WithGroup("DriverRevokeBucketAccess") @@ -290,7 +290,7 @@ func (s *Server) DriverRevokeBucketAccess(ctx context.Context, req *cosi.DriverR span.SetAttributes( attribute.String(KeyBucketID, req.GetBucketId()), attribute.String(KeyBucketAccessIDRaw, req.GetBucketId()), - attribute.String(KeyBucketCluster, cluster), + attribute.String(KeyBucketRegion, region), attribute.String(KeyBucketLabel, label), attribute.Int(KeyBucketAccessID, id), ) diff --git a/pkg/servers/provisioner/provisioner_test.go b/pkg/servers/provisioner/provisioner_test.go index aef1302..3e14f29 100644 --- a/pkg/servers/provisioner/provisioner_test.go +++ b/pkg/servers/provisioner/provisioner_test.go @@ -41,8 +41,8 @@ const ( var ( defaultLinodegoBucket = &linodego.ObjectStorageBucket{ - Label: testBucketName, - Cluster: testRegion, + Label: testBucketName, + Region: testRegion, } defaultLinodegoBucketAccess = &linodego.ObjectStorageBucketAccess{ ACL: linodego.ACLPrivate, @@ -104,7 +104,7 @@ func TestDriverCreateBucket(t *testing.T) { testName: "bucket exists", client: stubclient.New( stubclient.WithBucket(defaultLinodegoBucket), - stubclient.WithBucketAccess(defaultLinodegoBucketAccess, defaultLinodegoBucket.Cluster, defaultLinodegoBucket.Label), + stubclient.WithBucketAccess(defaultLinodegoBucketAccess, defaultLinodegoBucket.Region, defaultLinodegoBucket.Label), ), request: &cosi.DriverCreateBucketRequest{ Name: testBucketName, @@ -278,7 +278,7 @@ func TestDriverGrantBucketAccess(t *testing.T) { } if !reflect.DeepEqual(tc.expectedResponse, actual) { - t.Errorf("call %d: expected credentials to be deeply equal\n> expected: %#+v,\n> got: %#+v", + t.Errorf("call %d: expected buckets to be deeply equal\n> expected: %#+v,\n> got: %#+v", i, tc.expectedResponse, actual) @@ -301,7 +301,7 @@ func TestDriverRevokeBucketAccess(t *testing.T) { testName: "base", client: stubclient.New( stubclient.WithBucket(defaultLinodegoBucket), - stubclient.WithBucketAccess(defaultLinodegoBucketAccess, defaultLinodegoBucket.Cluster, defaultLinodegoBucket.Label), + stubclient.WithBucketAccess(defaultLinodegoBucketAccess, defaultLinodegoBucket.Region, defaultLinodegoBucket.Label), ), request: &cosi.DriverRevokeBucketAccessRequest{ BucketId: testBucketID, diff --git a/pkg/servers/provisioner/provisionerintegration_test.go b/pkg/servers/provisioner/provisionerintegration_test.go index 6801b48..9f31c9d 100644 --- a/pkg/servers/provisioner/provisionerintegration_test.go +++ b/pkg/servers/provisioner/provisionerintegration_test.go @@ -96,7 +96,7 @@ func (s *suite) DriverCreateBucket(t *testing.T) { req := &cosi.DriverCreateBucketRequest{ Name: "integration", Parameters: map[string]string{ - provisioner.ParamRegion: "us-east-1", + provisioner.ParamRegion: "us-east", provisioner.ParamACL: "private", provisioner.ParamCORS: string(provisioner.ParamCORSValueEnabled), }, diff --git a/pkg/servers/provisioner/utils.go b/pkg/servers/provisioner/utils.go index dbf4963..11e0303 100644 --- a/pkg/servers/provisioner/utils.go +++ b/pkg/servers/provisioner/utils.go @@ -21,7 +21,7 @@ import ( cosi "sigs.k8s.io/container-object-storage-interface-spec" ) -func parseBucketID(id string) (cluster string, label string) { +func parseBucketID(id string) (region string, label string) { chunks := 2 s := strings.SplitN(id, "/", chunks) @@ -29,22 +29,22 @@ func parseBucketID(id string) (cluster string, label string) { return s[0], s[1] } -func bucketInfo(cluster string) *cosi.Protocol { +func bucketInfo(region string) *cosi.Protocol { return &cosi.Protocol{ Type: &cosi.Protocol_S3{ S3: &cosi.S3{ - Region: cluster, + Region: region, SignatureVersion: cosi.S3SignatureVersion_S3V4, }, }, } } -func credentials(cluster, label, accessKey, secretKey string) map[string]*cosi.CredentialDetails { +func credentials(region, label, accessKey, secretKey string) map[string]*cosi.CredentialDetails { return map[string]*cosi.CredentialDetails{ S3: { Secrets: map[string]string{ - S3Region: cluster, + S3Region: region, S3Endpoint: fmt.Sprintf("%s.linodeobjects.com", label), S3SecretAccessKeyID: accessKey, S3SecretAccessSecretKey: secretKey,