Skip to content

Commit

Permalink
setting Unknown bucket type
Browse files Browse the repository at this point in the history
  • Loading branch information
Tulsishah committed May 15, 2024
1 parent 499890a commit 7c1f491
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions internal/storage/gcs/bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type BucketTypes int
const (
NonHierarchical BucketTypes = iota
Hierarchical
Unknown
)

// Bucket represents a GCS bucket, pre-bound with a bucket name and necessary
Expand Down
2 changes: 1 addition & 1 deletion internal/storage/mock_control_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func mockGetBucketType(controlClient *MockStorageControlClient, bucketName strin
}, nil...)

if err != nil {
return gcs.NonHierarchical
return gcs.Unknown
}

if stoargeLayout.GetHierarchicalNamespace() != nil && stoargeLayout.GetHierarchicalNamespace().Enabled {
Expand Down
3 changes: 2 additions & 1 deletion internal/storage/storage_handle.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,10 @@ func getBucketType(controlClient *control.StorageControlClient, bucketName strin
RequestId: "",
}, callOptions...)

// In case bucket does not exist, set type unknown instead of panic.
if err != nil {
log.Printf("GetStorageLayout: %v", err)
return gcs.NonHierarchical
return gcs.Unknown
}

if stoargeLayout.HierarchicalNamespace != nil && stoargeLayout.GetHierarchicalNamespace().Enabled {
Expand Down
2 changes: 1 addition & 1 deletion internal/storage/storage_handle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,5 +332,5 @@ func (testSuite *StorageHandleTest) TestGetBucketTypeWithError() {
Return(x, errors.New("mocked error"))

bucketType := mockGetBucketType(testSuite.mockClient, TestBucketName)
assert.Equal(testSuite.T(), gcs.NonHierarchical, bucketType, "Expected NonHierarchical when there's an error")
assert.Equal(testSuite.T(), gcs.Unknown, bucketType, "Expected Unknown when there's an error")
}

0 comments on commit 7c1f491

Please sign in to comment.