Skip to content

Commit

Permalink
feat: add version response for provider (#466)
Browse files Browse the repository at this point in the history
Signed-off-by: Anish Ramasekar <anish.ramasekar@gmail.com>
  • Loading branch information
aramase committed Apr 13, 2021
1 parent 6470ab6 commit 72a2c0b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
7 changes: 6 additions & 1 deletion pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"os"

"github.com/Azure/secrets-store-csi-driver-provider-azure/pkg/provider"
"github.com/Azure/secrets-store-csi-driver-provider-azure/pkg/version"

"golang.org/x/net/context"
"google.golang.org/grpc"
Expand Down Expand Up @@ -63,7 +64,11 @@ func (s *CSIDriverProviderServer) Mount(ctx context.Context, req *v1alpha1.Mount
}

func (s *CSIDriverProviderServer) Version(ctx context.Context, req *v1alpha1.VersionRequest) (*v1alpha1.VersionResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method Version not implemented")
return &v1alpha1.VersionResponse{
Version: "v1alpha1",
RuntimeVersion: version.BuildVersion,
RuntimeName: "secrets-store-csi-driver-provider-azure",
}, nil
}

func (s *CSIDriverProviderServer) Check(ctx context.Context, in *grpc_health_v1.HealthCheckRequest) (*grpc_health_v1.HealthCheckResponse, error) {
Expand Down
17 changes: 14 additions & 3 deletions pkg/server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ package server

import (
"context"
"reflect"
"testing"

"github.com/Azure/secrets-store-csi-driver-provider-azure/pkg/version"
"sigs.k8s.io/secrets-store-csi-driver/provider/v1alpha1"
)

Expand Down Expand Up @@ -57,8 +59,17 @@ func TestMount(t *testing.T) {

func TestVersion(t *testing.T) {
testServer := &CSIDriverProviderServer{}
_, err := testServer.Version(context.TODO(), &v1alpha1.VersionRequest{})
if err == nil {
t.Fatalf("expected error to not be nil")
version.BuildVersion = "test"
resp, err := testServer.Version(context.TODO(), &v1alpha1.VersionRequest{})
if err != nil {
t.Fatalf("expected error to be nil")
}
expectedVersionResponse := &v1alpha1.VersionResponse{
Version: "v1alpha1",
RuntimeVersion: "test",
RuntimeName: "secrets-store-csi-driver-provider-azure",
}
if !reflect.DeepEqual(resp, expectedVersionResponse) {
t.Fatalf("expected resp: %v, got: %v", expectedVersionResponse, resp)
}
}

0 comments on commit 72a2c0b

Please sign in to comment.