Skip to content

Commit

Permalink
COSI-39: add-default-case-for-service
Browse files Browse the repository at this point in the history
  • Loading branch information
anurag4DSB committed Dec 6, 2024
1 parent de19b1f commit 32be7c3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/driver/provisioner_server_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,9 @@ func initializeObjectStorageClient(ctx context.Context, clientset kubernetes.Int
return nil, nil, status.Error(codes.Internal, "failed to initialize IAM client")
}
klog.V(3).InfoS("Successfully initialized IAM client", "endpoint", storageClientParameters.Endpoint)

Check warning on line 179 in pkg/driver/provisioner_server_impl.go

View check run for this annotation

Codecov / codecov/patch

pkg/driver/provisioner_server_impl.go#L173-L179

Added lines #L173 - L179 were not covered by tests
default:
klog.ErrorS(nil, "Unsupported object storage provider service", "service", service)
return nil, nil, status.Error(codes.Internal, "unsupported object storage provider service")
}
return client, storageClientParameters, nil
}
Expand Down
13 changes: 13 additions & 0 deletions pkg/driver/provisioner_server_impl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,19 @@ var _ = Describe("initializeObjectStorageClient", Ordered, func() {
Expect(s3Params.Region).To(Equal("us-west-2"))
})

It("should return InvalidArgument error for unsupported object storage provider service", func() {
_, err := clientset.CoreV1().Secrets("test-namespace").Create(ctx, secret, metav1.CreateOptions{})
Expect(err).To(BeNil())

client, params, err := driver.InitializeClient(ctx, clientset, parameters, "UnsupportedService")

Expect(client).To(BeNil())
Expect(params).To(BeNil())
Expect(err).To(HaveOccurred())
Expect(status.Code(err)).To(Equal(codes.Internal))
Expect(err.Error()).To(ContainSubstring("unsupported object storage provider service"))
})

It("should return error when FetchSecretInformation fails", func() {
delete(parameters, "objectStorageSecretName")

Expand Down

0 comments on commit 32be7c3

Please sign in to comment.