From 559b408e9ea94856e9f48189c59e54c3f8975863 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 18 Jul 2024 18:00:01 +0000 Subject: [PATCH 1/2] fix(deps): bump github.com/linode/linodego from 1.36.0 to 1.37.0 Bumps [github.com/linode/linodego](https://github.com/linode/linodego) from 1.36.0 to 1.37.0. - [Release notes](https://github.com/linode/linodego/releases) - [Commits](https://github.com/linode/linodego/compare/v1.36.0...v1.37.0) --- updated-dependencies: - dependency-name: github.com/linode/linodego dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 6 +++--- go.sum | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index 68a1a62..d665a3c 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ toolchain go1.22.3 require ( github.com/go-resty/resty/v2 v2.13.1 github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.1.0 - github.com/linode/linodego v1.36.0 + github.com/linode/linodego v1.37.0 go.opentelemetry.io/contrib/exporters/autoexport v0.53.0 go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.53.0 go.opentelemetry.io/otel v1.28.0 @@ -48,8 +48,8 @@ require ( go.opentelemetry.io/otel/log v0.4.0 // indirect go.opentelemetry.io/otel/sdk/log v0.4.0 // indirect go.opentelemetry.io/proto/otlp v1.3.1 // indirect - golang.org/x/net v0.26.0 // indirect - golang.org/x/sys v0.21.0 // indirect + golang.org/x/net v0.27.0 // indirect + golang.org/x/sys v0.22.0 // indirect golang.org/x/text v0.16.0 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20240701130421-f6361c86f094 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240701130421-f6361c86f094 // indirect diff --git a/go.sum b/go.sum index 2f781fd..e7a7d4c 100644 --- a/go.sum +++ b/go.sum @@ -25,8 +25,8 @@ github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 h1:bkypFPDjIYGfCYD5mRBvpqxfYX1 github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0/go.mod h1:P+Lt/0by1T8bfcF3z737NnSbmxQAppXMRziHUxPOC8k= github.com/jarcoal/httpmock v1.3.1 h1:iUx3whfZWVf3jT01hQTO/Eo5sAYtB2/rqaUuOtpInww= github.com/jarcoal/httpmock v1.3.1/go.mod h1:3yb8rc4BI7TCBhFY8ng0gjuLKJNquuDNiPaZjnENuYg= -github.com/linode/linodego v1.36.0 h1:AeFkL3cNtiirEiS9gxzNUUaZafFHhNvVpeyuokmKTu8= -github.com/linode/linodego v1.36.0/go.mod h1:7MDOCz/DXckUEByLaXEwVBn6yHuvjoT7zVhp9Tr9OS0= +github.com/linode/linodego v1.37.0 h1:B/2Spzv9jYXzKA+p+GD8fVCNJ7Wuw6P91ZDD9eCkkso= +github.com/linode/linodego v1.37.0/go.mod h1:L7GXKFD3PoN2xSEtFc04wIXP5WK65O10jYQx0PQISWQ= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= @@ -103,8 +103,8 @@ golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= -golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ= -golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE= +golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= +golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= golang.org/x/oauth2 v0.21.0 h1:tsimM75w1tF/uws5rbeHzIWxEqElMehnc+iW793zsZs= golang.org/x/oauth2 v0.21.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -119,8 +119,8 @@ golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= -golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= +golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= From bbbb8f85a5fb9da401d1bbed92b95c6749aac0ab Mon Sep 17 00:00:00 2001 From: Mateusz Urbanek Date: Tue, 23 Jul 2024 09:52:03 +0200 Subject: [PATCH 2/2] fix!: replace deprecated cluster with region Signed-off-by: Mateusz Urbanek --- examples/example.BucketClass.yaml | 2 +- pkg/linodeclient/stubclient/stubclient.go | 20 ++--- .../stubclient/stubclient_test.go | 82 +++++++++---------- .../stubclient/stubclientoption.go | 6 +- pkg/servers/provisioner/consts.go | 2 +- pkg/servers/provisioner/provisioner.go | 48 +++++------ pkg/servers/provisioner/provisioner_test.go | 10 +-- .../provisionerintegration_test.go | 2 +- pkg/servers/provisioner/utils.go | 10 +-- 9 files changed, 91 insertions(+), 91 deletions(-) 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,