From 40964143cdbb961915337b9254a32d645f37958a Mon Sep 17 00:00:00 2001 From: Mauricio Poppe Date: Sat, 5 Jun 2021 18:58:51 +0000 Subject: [PATCH 1/4] Changes in the filesystem v1beta2 API --- .../csi-proxy/client/api/filesystem/v1beta2/api.pb.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/vendor/github.com/kubernetes-csi/csi-proxy/client/api/filesystem/v1beta2/api.pb.go b/vendor/github.com/kubernetes-csi/csi-proxy/client/api/filesystem/v1beta2/api.pb.go index 0219d023..d1c3a914 100644 --- a/vendor/github.com/kubernetes-csi/csi-proxy/client/api/filesystem/v1beta2/api.pb.go +++ b/vendor/github.com/kubernetes-csi/csi-proxy/client/api/filesystem/v1beta2/api.pb.go @@ -8,13 +8,14 @@ package v1beta2 import ( context "context" + reflect "reflect" + sync "sync" + grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" ) const ( From 981b1356ce8e7954347a0e8a72dfa079f48b10f3 Mon Sep 17 00:00:00 2001 From: Mauricio Poppe Date: Sat, 5 Jun 2021 19:00:28 +0000 Subject: [PATCH 2/4] filesystem v1beta2 api changes --- client/api/filesystem/v1beta2/api.pb.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/client/api/filesystem/v1beta2/api.pb.go b/client/api/filesystem/v1beta2/api.pb.go index 0219d023..d1c3a914 100644 --- a/client/api/filesystem/v1beta2/api.pb.go +++ b/client/api/filesystem/v1beta2/api.pb.go @@ -8,13 +8,14 @@ package v1beta2 import ( context "context" + reflect "reflect" + sync "sync" + grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" ) const ( From b3984d65102d49597feb5e0e54b5f0740290e2b5 Mon Sep 17 00:00:00 2001 From: Mauricio Poppe Date: Wed, 2 Jun 2021 23:57:39 +0000 Subject: [PATCH 3/4] Updates in the SMB v1beta2 API --- client/api/smb/v1beta2/api.pb.go | 77 +++++++----------- client/api/smb/v1beta2/api.proto | 8 +- integrationtests/smb_test.go | 78 ++----------------- integrationtests/smb_v1alpha1_test.go | 73 +++++++++++++++++ integrationtests/smb_v1beta1_test.go | 73 +++++++++++++++++ integrationtests/smb_v1beta2_test.go | 73 +++++++++++++++++ internal/os/smb/api.go | 23 ++++-- internal/server/smb/internal/types.go | 4 +- .../internal/v1alpha1/conversion_generated.go | 4 - .../internal/v1beta1/conversion_generated.go | 4 - .../internal/v1beta2/conversion_generated.go | 4 - internal/server/smb/server.go | 20 +++-- internal/server/smb/server_test.go | 7 +- .../client/api/smb/v1beta2/api.pb.go | 77 +++++++----------- .../client/api/smb/v1beta2/api.proto | 8 +- vendor/modules.txt | 2 + 16 files changed, 317 insertions(+), 218 deletions(-) create mode 100644 integrationtests/smb_v1alpha1_test.go create mode 100644 integrationtests/smb_v1beta1_test.go create mode 100644 integrationtests/smb_v1beta2_test.go diff --git a/client/api/smb/v1beta2/api.pb.go b/client/api/smb/v1beta2/api.pb.go index ce2f6b07..a7afd5ea 100644 --- a/client/api/smb/v1beta2/api.pb.go +++ b/client/api/smb/v1beta2/api.pb.go @@ -111,10 +111,6 @@ type NewSmbGlobalMappingResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - - // Windows error code - // Success is represented as 0 - Error string `protobuf:"bytes,1,opt,name=error,proto3" json:"error,omitempty"` } func (x *NewSmbGlobalMappingResponse) Reset() { @@ -149,13 +145,6 @@ func (*NewSmbGlobalMappingResponse) Descriptor() ([]byte, []int) { return file_github_com_kubernetes_csi_csi_proxy_client_api_smb_v1beta2_api_proto_rawDescGZIP(), []int{1} } -func (x *NewSmbGlobalMappingResponse) GetError() string { - if x != nil { - return x.Error - } - return "" -} - type RemoveSmbGlobalMappingRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -216,10 +205,6 @@ type RemoveSmbGlobalMappingResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - - // Windows error code - // Success is represented as 0 - Error string `protobuf:"bytes,1,opt,name=error,proto3" json:"error,omitempty"` } func (x *RemoveSmbGlobalMappingResponse) Reset() { @@ -254,13 +239,6 @@ func (*RemoveSmbGlobalMappingResponse) Descriptor() ([]byte, []int) { return file_github_com_kubernetes_csi_csi_proxy_client_api_smb_v1beta2_api_proto_rawDescGZIP(), []int{3} } -func (x *RemoveSmbGlobalMappingResponse) GetError() string { - if x != nil { - return x.Error - } - return "" -} - var File_github_com_kubernetes_csi_csi_proxy_client_api_smb_v1beta2_api_proto protoreflect.FileDescriptor var file_github_com_kubernetes_csi_csi_proxy_client_api_smb_v1beta2_api_proto_rawDesc = []byte{ @@ -278,36 +256,33 @@ var file_github_com_kubernetes_csi_csi_proxy_client_api_smb_v1beta2_api_proto_ra 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x61, - 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x22, 0x33, 0x0a, 0x1b, 0x4e, 0x65, 0x77, 0x53, 0x6d, 0x62, + 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x22, 0x1d, 0x0a, 0x1b, 0x4e, 0x65, 0x77, 0x53, 0x6d, 0x62, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x4d, 0x61, 0x70, 0x70, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0x40, 0x0a, 0x1d, 0x52, - 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x53, 0x6d, 0x62, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x4d, 0x61, - 0x70, 0x70, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1f, 0x0a, 0x0b, - 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x0a, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x50, 0x61, 0x74, 0x68, 0x22, 0x36, 0x0a, - 0x1e, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x53, 0x6d, 0x62, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, - 0x4d, 0x61, 0x70, 0x70, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, - 0x14, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, - 0x65, 0x72, 0x72, 0x6f, 0x72, 0x32, 0xd6, 0x01, 0x0a, 0x03, 0x53, 0x6d, 0x62, 0x12, 0x62, 0x0a, - 0x13, 0x4e, 0x65, 0x77, 0x53, 0x6d, 0x62, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x4d, 0x61, 0x70, - 0x70, 0x69, 0x6e, 0x67, 0x12, 0x23, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x32, 0x2e, 0x4e, - 0x65, 0x77, 0x53, 0x6d, 0x62, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x4d, 0x61, 0x70, 0x70, 0x69, - 0x6e, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x24, 0x2e, 0x76, 0x31, 0x62, 0x65, - 0x74, 0x61, 0x32, 0x2e, 0x4e, 0x65, 0x77, 0x53, 0x6d, 0x62, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, - 0x4d, 0x61, 0x70, 0x70, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, - 0x00, 0x12, 0x6b, 0x0a, 0x16, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x53, 0x6d, 0x62, 0x47, 0x6c, - 0x6f, 0x62, 0x61, 0x6c, 0x4d, 0x61, 0x70, 0x70, 0x69, 0x6e, 0x67, 0x12, 0x26, 0x2e, 0x76, 0x31, - 0x62, 0x65, 0x74, 0x61, 0x32, 0x2e, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x53, 0x6d, 0x62, 0x47, - 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x4d, 0x61, 0x70, 0x70, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x27, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x32, 0x2e, 0x52, 0x65, - 0x6d, 0x6f, 0x76, 0x65, 0x53, 0x6d, 0x62, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x4d, 0x61, 0x70, - 0x70, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x3c, - 0x5a, 0x3a, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6b, 0x75, 0x62, - 0x65, 0x72, 0x6e, 0x65, 0x74, 0x65, 0x73, 0x2d, 0x63, 0x73, 0x69, 0x2f, 0x63, 0x73, 0x69, 0x2d, - 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2f, 0x61, 0x70, 0x69, - 0x2f, 0x73, 0x6d, 0x62, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x32, 0x62, 0x06, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x33, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x40, 0x0a, 0x1d, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x53, + 0x6d, 0x62, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x4d, 0x61, 0x70, 0x70, 0x69, 0x6e, 0x67, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1f, 0x0a, 0x0b, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, + 0x5f, 0x70, 0x61, 0x74, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x72, 0x65, 0x6d, + 0x6f, 0x74, 0x65, 0x50, 0x61, 0x74, 0x68, 0x22, 0x20, 0x0a, 0x1e, 0x52, 0x65, 0x6d, 0x6f, 0x76, + 0x65, 0x53, 0x6d, 0x62, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x4d, 0x61, 0x70, 0x70, 0x69, 0x6e, + 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0xd6, 0x01, 0x0a, 0x03, 0x53, 0x6d, + 0x62, 0x12, 0x62, 0x0a, 0x13, 0x4e, 0x65, 0x77, 0x53, 0x6d, 0x62, 0x47, 0x6c, 0x6f, 0x62, 0x61, + 0x6c, 0x4d, 0x61, 0x70, 0x70, 0x69, 0x6e, 0x67, 0x12, 0x23, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, + 0x61, 0x32, 0x2e, 0x4e, 0x65, 0x77, 0x53, 0x6d, 0x62, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x4d, + 0x61, 0x70, 0x70, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x24, 0x2e, + 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x32, 0x2e, 0x4e, 0x65, 0x77, 0x53, 0x6d, 0x62, 0x47, 0x6c, + 0x6f, 0x62, 0x61, 0x6c, 0x4d, 0x61, 0x70, 0x70, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x6b, 0x0a, 0x16, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x53, + 0x6d, 0x62, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x4d, 0x61, 0x70, 0x70, 0x69, 0x6e, 0x67, 0x12, + 0x26, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x32, 0x2e, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, + 0x53, 0x6d, 0x62, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x4d, 0x61, 0x70, 0x70, 0x69, 0x6e, 0x67, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x27, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, + 0x32, 0x2e, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x53, 0x6d, 0x62, 0x47, 0x6c, 0x6f, 0x62, 0x61, + 0x6c, 0x4d, 0x61, 0x70, 0x70, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x22, 0x00, 0x42, 0x3c, 0x5a, 0x3a, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, + 0x2f, 0x6b, 0x75, 0x62, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x65, 0x73, 0x2d, 0x63, 0x73, 0x69, 0x2f, + 0x63, 0x73, 0x69, 0x2d, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, + 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x73, 0x6d, 0x62, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x32, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/client/api/smb/v1beta2/api.proto b/client/api/smb/v1beta2/api.proto index b30e69bf..9e4fe249 100644 --- a/client/api/smb/v1beta2/api.proto +++ b/client/api/smb/v1beta2/api.proto @@ -35,9 +35,7 @@ message NewSmbGlobalMappingRequest { } message NewSmbGlobalMappingResponse { - // Windows error code - // Success is represented as 0 - string error = 1; + // Intentionally empty. } @@ -55,7 +53,5 @@ message RemoveSmbGlobalMappingRequest { } message RemoveSmbGlobalMappingResponse { - // Windows error code - // Success is represented as 0 - string error = 1; + // Intentionally empty. } diff --git a/integrationtests/smb_test.go b/integrationtests/smb_test.go index b279ac8d..0d8b9241 100644 --- a/integrationtests/smb_test.go +++ b/integrationtests/smb_test.go @@ -1,7 +1,6 @@ package integrationtests import ( - "context" "fmt" "io/ioutil" "math/rand" @@ -11,11 +10,6 @@ import ( "time" "testing" - - "github.com/stretchr/testify/assert" - - "github.com/kubernetes-csi/csi-proxy/client/api/smb/v1beta2" - v1beta2client "github.com/kubernetes-csi/csi-proxy/client/groups/smb/v1beta2" ) const letterset = "abcdefghijklmnopqrstuvwxyz" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" @@ -129,69 +123,13 @@ func writeReadFile(path string) error { } func TestSmbAPIGroup(t *testing.T) { - t.Run("Smb positive", func(t *testing.T) { - client, err := v1beta2client.NewClient() - if err != nil { - t.Fatalf("Fail to get smb API group client %v", err) - } - defer client.Close() - - username := randomString(5) - password := randomString(10) + "!" - sharePath := fmt.Sprintf("C:\\smbshare%s", randomString(5)) - smbShare := randomString(6) - - localPath := fmt.Sprintf("C:\\localpath%s", randomString(5)) - - if err = setupUser(username, password); err != nil { - t.Fatalf("TestSmbAPIGroup %v", err) - } - defer removeUser(t, username) - - if err = setupSmbShare(smbShare, sharePath, username); err != nil { - t.Fatalf("TestSmbAPIGroup %v", err) - } - defer removeSmbShare(t, smbShare) - - hostname, err := os.Hostname() - assert.Nil(t, err) - - username = "domain\\" + username - remotePath := "\\\\" + hostname + "\\" + smbShare - // simulate Mount SMB operations around staging a volume on a node - mountSmbShareReq := &v1beta2.NewSmbGlobalMappingRequest{ - RemotePath: remotePath, - Username: username, - Password: password, - } - mountSmbShareRsp, err := client.NewSmbGlobalMapping(context.Background(), mountSmbShareReq) - if err != nil { - t.Fatalf("TestSmbAPIGroup %v", err) - } - if !assert.Equal(t, "", mountSmbShareRsp.Error) { - t.Fatalf("TestSmbAPIGroup %v", mountSmbShareRsp.Error) - } - - err = getSmbGlobalMapping(remotePath) - assert.Nil(t, err) - - err = writeReadFile(remotePath) - assert.Nil(t, err) - - unmountSmbShareReq := &v1beta2.RemoveSmbGlobalMappingRequest{ - RemotePath: remotePath, - } - unmountSmbShareRsp, err := client.RemoveSmbGlobalMapping(context.Background(), unmountSmbShareReq) - if err != nil { - t.Fatalf("TestSmbAPIGroup %v", err) - } - if !assert.Equal(t, "", unmountSmbShareRsp.Error) { - t.Fatalf("TestSmbAPIGroup %v", mountSmbShareRsp.Error) - } - err = getSmbGlobalMapping(remotePath) - assert.NotNil(t, err) - err = writeReadFile(localPath) - assert.NotNil(t, err) - + t.Run("v1alpha1SmbTests", func(t *testing.T) { + v1alpha1SmbTests(t) + }) + t.Run("v1beta1SmbTests", func(t *testing.T) { + v1beta1SmbTests(t) + }) + t.Run("v1beta2SmbTests", func(t *testing.T) { + v1beta2SmbTests(t) }) } diff --git a/integrationtests/smb_v1alpha1_test.go b/integrationtests/smb_v1alpha1_test.go new file mode 100644 index 00000000..3ea2b348 --- /dev/null +++ b/integrationtests/smb_v1alpha1_test.go @@ -0,0 +1,73 @@ +package integrationtests + +import ( + "context" + "fmt" + "os" + "testing" + + "github.com/kubernetes-csi/csi-proxy/client/api/smb/v1alpha1" + client "github.com/kubernetes-csi/csi-proxy/client/groups/smb/v1alpha1" + + "github.com/stretchr/testify/assert" +) + +func v1alpha1SmbTests(t *testing.T) { + client, err := client.NewClient() + if err != nil { + t.Fatalf("Fail to get smb API group client %v", err) + } + defer client.Close() + + username := randomString(5) + password := randomString(10) + "!" + sharePath := fmt.Sprintf("C:\\smbshare%s", randomString(5)) + smbShare := randomString(6) + + localPath := fmt.Sprintf("C:\\localpath%s", randomString(5)) + + if err = setupUser(username, password); err != nil { + t.Fatalf("TestSmbAPIGroup %v", err) + } + defer removeUser(t, username) + + if err = setupSmbShare(smbShare, sharePath, username); err != nil { + t.Fatalf("TestSmbAPIGroup %v", err) + } + defer removeSmbShare(t, smbShare) + + hostname, err := os.Hostname() + assert.Nil(t, err) + + username = "domain\\" + username + remotePath := "\\\\" + hostname + "\\" + smbShare + // simulate Mount SMB operations around staging a volume on a node + mountSmbShareReq := &v1alpha1.NewSmbGlobalMappingRequest{ + RemotePath: remotePath, + Username: username, + Password: password, + } + _, err = client.NewSmbGlobalMapping(context.Background(), mountSmbShareReq) + if err != nil { + t.Fatalf("TestSmbAPIGroup %v", err) + } + + err = getSmbGlobalMapping(remotePath) + assert.Nil(t, err) + + err = writeReadFile(remotePath) + assert.Nil(t, err) + + unmountSmbShareReq := &v1alpha1.RemoveSmbGlobalMappingRequest{ + RemotePath: remotePath, + } + _, err = client.RemoveSmbGlobalMapping(context.Background(), unmountSmbShareReq) + if err != nil { + t.Fatalf("TestSmbAPIGroup %v", err) + } + err = getSmbGlobalMapping(remotePath) + assert.NotNil(t, err) + err = writeReadFile(localPath) + assert.NotNil(t, err) + +} diff --git a/integrationtests/smb_v1beta1_test.go b/integrationtests/smb_v1beta1_test.go new file mode 100644 index 00000000..87f46ed7 --- /dev/null +++ b/integrationtests/smb_v1beta1_test.go @@ -0,0 +1,73 @@ +package integrationtests + +import ( + "context" + "fmt" + "os" + "testing" + + "github.com/kubernetes-csi/csi-proxy/client/api/smb/v1beta1" + client "github.com/kubernetes-csi/csi-proxy/client/groups/smb/v1beta1" + + "github.com/stretchr/testify/assert" +) + +func v1beta1SmbTests(t *testing.T) { + client, err := client.NewClient() + if err != nil { + t.Fatalf("Fail to get smb API group client %v", err) + } + defer client.Close() + + username := randomString(5) + password := randomString(10) + "!" + sharePath := fmt.Sprintf("C:\\smbshare%s", randomString(5)) + smbShare := randomString(6) + + localPath := fmt.Sprintf("C:\\localpath%s", randomString(5)) + + if err = setupUser(username, password); err != nil { + t.Fatalf("TestSmbAPIGroup %v", err) + } + defer removeUser(t, username) + + if err = setupSmbShare(smbShare, sharePath, username); err != nil { + t.Fatalf("TestSmbAPIGroup %v", err) + } + defer removeSmbShare(t, smbShare) + + hostname, err := os.Hostname() + assert.Nil(t, err) + + username = "domain\\" + username + remotePath := "\\\\" + hostname + "\\" + smbShare + // simulate Mount SMB operations around staging a volume on a node + mountSmbShareReq := &v1beta1.NewSmbGlobalMappingRequest{ + RemotePath: remotePath, + Username: username, + Password: password, + } + _, err = client.NewSmbGlobalMapping(context.Background(), mountSmbShareReq) + if err != nil { + t.Fatalf("TestSmbAPIGroup %v", err) + } + + err = getSmbGlobalMapping(remotePath) + assert.Nil(t, err) + + err = writeReadFile(remotePath) + assert.Nil(t, err) + + unmountSmbShareReq := &v1beta1.RemoveSmbGlobalMappingRequest{ + RemotePath: remotePath, + } + _, err = client.RemoveSmbGlobalMapping(context.Background(), unmountSmbShareReq) + if err != nil { + t.Fatalf("TestSmbAPIGroup %v", err) + } + err = getSmbGlobalMapping(remotePath) + assert.NotNil(t, err) + err = writeReadFile(localPath) + assert.NotNil(t, err) + +} diff --git a/integrationtests/smb_v1beta2_test.go b/integrationtests/smb_v1beta2_test.go new file mode 100644 index 00000000..a46caccc --- /dev/null +++ b/integrationtests/smb_v1beta2_test.go @@ -0,0 +1,73 @@ +package integrationtests + +import ( + "context" + "fmt" + "os" + "testing" + + "github.com/kubernetes-csi/csi-proxy/client/api/smb/v1beta2" + client "github.com/kubernetes-csi/csi-proxy/client/groups/smb/v1beta2" + + "github.com/stretchr/testify/assert" +) + +func v1beta2SmbTests(t *testing.T) { + client, err := client.NewClient() + if err != nil { + t.Fatalf("Fail to get smb API group client %v", err) + } + defer client.Close() + + username := randomString(5) + password := randomString(10) + "!" + sharePath := fmt.Sprintf("C:\\smbshare%s", randomString(5)) + smbShare := randomString(6) + + localPath := fmt.Sprintf("C:\\localpath%s", randomString(5)) + + if err = setupUser(username, password); err != nil { + t.Fatalf("TestSmbAPIGroup %v", err) + } + defer removeUser(t, username) + + if err = setupSmbShare(smbShare, sharePath, username); err != nil { + t.Fatalf("TestSmbAPIGroup %v", err) + } + defer removeSmbShare(t, smbShare) + + hostname, err := os.Hostname() + assert.Nil(t, err) + + username = "domain\\" + username + remotePath := "\\\\" + hostname + "\\" + smbShare + // simulate Mount SMB operations around staging a volume on a node + mountSmbShareReq := &v1beta2.NewSmbGlobalMappingRequest{ + RemotePath: remotePath, + Username: username, + Password: password, + } + _, err = client.NewSmbGlobalMapping(context.Background(), mountSmbShareReq) + if err != nil { + t.Fatalf("TestSmbAPIGroup %v", err) + } + + err = getSmbGlobalMapping(remotePath) + assert.Nil(t, err) + + err = writeReadFile(remotePath) + assert.Nil(t, err) + + unmountSmbShareReq := &v1beta2.RemoveSmbGlobalMappingRequest{ + RemotePath: remotePath, + } + _, err = client.RemoveSmbGlobalMapping(context.Background(), unmountSmbShareReq) + if err != nil { + t.Fatalf("TestSmbAPIGroup %v", err) + } + err = getSmbGlobalMapping(remotePath) + assert.NotNil(t, err) + err = writeReadFile(localPath) + assert.NotNil(t, err) + +} diff --git a/internal/os/smb/api.go b/internal/os/smb/api.go index c80519d1..3bec8eb0 100644 --- a/internal/os/smb/api.go +++ b/internal/os/smb/api.go @@ -7,13 +7,22 @@ import ( "strings" ) -type APIImplementor struct{} +type API interface { + IsSmbMapped(remotePath string) (bool, error) + NewSmbLink(remotePath, localPath string) error + NewSmbGlobalMapping(remotePath, username, password string) error + RemoveSmbGlobalMapping(remotePath string) error +} + +type SmbAPI struct{} + +var _ API = &SmbAPI{} -func New() APIImplementor { - return APIImplementor{} +func New() SmbAPI { + return SmbAPI{} } -func (APIImplementor) IsSmbMapped(remotePath string) (bool, error) { +func (SmbAPI) IsSmbMapped(remotePath string) (bool, error) { cmdLine := fmt.Sprintf(`$(Get-SmbGlobalMapping -RemotePath $Env:smbremotepath -ErrorAction Stop).Status `) cmd := exec.Command("powershell", "/c", cmdLine) cmd.Env = append(os.Environ(), @@ -37,7 +46,7 @@ func (APIImplementor) IsSmbMapped(remotePath string) (bool, error) { // Since os.Symlink is currently being used in working code paths, no attempt is made in // alpha to merge the paths. // TODO (for beta release): Merge the link paths - os.Symlink and Powershell link path. -func (APIImplementor) NewSmbLink(remotePath, localPath string) error { +func (SmbAPI) NewSmbLink(remotePath, localPath string) error { if !strings.HasSuffix(remotePath, "\\") { // Golang has issues resolving paths mapped to file shares if they do not end in a trailing \ @@ -59,7 +68,7 @@ func (APIImplementor) NewSmbLink(remotePath, localPath string) error { return nil } -func (APIImplementor) NewSmbGlobalMapping(remotePath, username, password string) error { +func (SmbAPI) NewSmbGlobalMapping(remotePath, username, password string) error { // use PowerShell Environment Variables to store user input string to prevent command line injection // https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_environment_variables?view=powershell-5.1 cmdLine := fmt.Sprintf(`$PWord = ConvertTo-SecureString -String $Env:smbpassword -AsPlainText -Force` + @@ -77,7 +86,7 @@ func (APIImplementor) NewSmbGlobalMapping(remotePath, username, password string) return nil } -func (APIImplementor) RemoveSmbGlobalMapping(remotePath string) error { +func (SmbAPI) RemoveSmbGlobalMapping(remotePath string) error { cmd := exec.Command("powershell", "/c", `Remove-SmbGlobalMapping -RemotePath $Env:smbremotepath -Force`) cmd.Env = append(os.Environ(), fmt.Sprintf("smbremotepath=%s", remotePath)) if output, err := cmd.CombinedOutput(); err != nil { diff --git a/internal/server/smb/internal/types.go b/internal/server/smb/internal/types.go index bf4dbc74..39d8a862 100644 --- a/internal/server/smb/internal/types.go +++ b/internal/server/smb/internal/types.go @@ -8,7 +8,7 @@ type NewSmbGlobalMappingRequest struct { } type NewSmbGlobalMappingResponse struct { - Error string + // Intentionally empty. } type RemoveSmbGlobalMappingRequest struct { @@ -16,5 +16,5 @@ type RemoveSmbGlobalMappingRequest struct { } type RemoveSmbGlobalMappingResponse struct { - Error string + // Intentionally empty. } diff --git a/internal/server/smb/internal/v1alpha1/conversion_generated.go b/internal/server/smb/internal/v1alpha1/conversion_generated.go index 48bf2e3e..1101e468 100644 --- a/internal/server/smb/internal/v1alpha1/conversion_generated.go +++ b/internal/server/smb/internal/v1alpha1/conversion_generated.go @@ -34,7 +34,6 @@ func Convert_internal_NewSmbGlobalMappingRequest_To_v1alpha1_NewSmbGlobalMapping } func autoConvert_v1alpha1_NewSmbGlobalMappingResponse_To_internal_NewSmbGlobalMappingResponse(in *v1alpha1.NewSmbGlobalMappingResponse, out *internal.NewSmbGlobalMappingResponse) error { - out.Error = in.Error return nil } @@ -44,7 +43,6 @@ func Convert_v1alpha1_NewSmbGlobalMappingResponse_To_internal_NewSmbGlobalMappin } func autoConvert_internal_NewSmbGlobalMappingResponse_To_v1alpha1_NewSmbGlobalMappingResponse(in *internal.NewSmbGlobalMappingResponse, out *v1alpha1.NewSmbGlobalMappingResponse) error { - out.Error = in.Error return nil } @@ -74,7 +72,6 @@ func Convert_internal_RemoveSmbGlobalMappingRequest_To_v1alpha1_RemoveSmbGlobalM } func autoConvert_v1alpha1_RemoveSmbGlobalMappingResponse_To_internal_RemoveSmbGlobalMappingResponse(in *v1alpha1.RemoveSmbGlobalMappingResponse, out *internal.RemoveSmbGlobalMappingResponse) error { - out.Error = in.Error return nil } @@ -84,7 +81,6 @@ func Convert_v1alpha1_RemoveSmbGlobalMappingResponse_To_internal_RemoveSmbGlobal } func autoConvert_internal_RemoveSmbGlobalMappingResponse_To_v1alpha1_RemoveSmbGlobalMappingResponse(in *internal.RemoveSmbGlobalMappingResponse, out *v1alpha1.RemoveSmbGlobalMappingResponse) error { - out.Error = in.Error return nil } diff --git a/internal/server/smb/internal/v1beta1/conversion_generated.go b/internal/server/smb/internal/v1beta1/conversion_generated.go index a0c8c01d..b348e524 100644 --- a/internal/server/smb/internal/v1beta1/conversion_generated.go +++ b/internal/server/smb/internal/v1beta1/conversion_generated.go @@ -34,7 +34,6 @@ func Convert_internal_NewSmbGlobalMappingRequest_To_v1beta1_NewSmbGlobalMappingR } func autoConvert_v1beta1_NewSmbGlobalMappingResponse_To_internal_NewSmbGlobalMappingResponse(in *v1beta1.NewSmbGlobalMappingResponse, out *internal.NewSmbGlobalMappingResponse) error { - out.Error = in.Error return nil } @@ -44,7 +43,6 @@ func Convert_v1beta1_NewSmbGlobalMappingResponse_To_internal_NewSmbGlobalMapping } func autoConvert_internal_NewSmbGlobalMappingResponse_To_v1beta1_NewSmbGlobalMappingResponse(in *internal.NewSmbGlobalMappingResponse, out *v1beta1.NewSmbGlobalMappingResponse) error { - out.Error = in.Error return nil } @@ -74,7 +72,6 @@ func Convert_internal_RemoveSmbGlobalMappingRequest_To_v1beta1_RemoveSmbGlobalMa } func autoConvert_v1beta1_RemoveSmbGlobalMappingResponse_To_internal_RemoveSmbGlobalMappingResponse(in *v1beta1.RemoveSmbGlobalMappingResponse, out *internal.RemoveSmbGlobalMappingResponse) error { - out.Error = in.Error return nil } @@ -84,7 +81,6 @@ func Convert_v1beta1_RemoveSmbGlobalMappingResponse_To_internal_RemoveSmbGlobalM } func autoConvert_internal_RemoveSmbGlobalMappingResponse_To_v1beta1_RemoveSmbGlobalMappingResponse(in *internal.RemoveSmbGlobalMappingResponse, out *v1beta1.RemoveSmbGlobalMappingResponse) error { - out.Error = in.Error return nil } diff --git a/internal/server/smb/internal/v1beta2/conversion_generated.go b/internal/server/smb/internal/v1beta2/conversion_generated.go index 0af3540b..0ccdb67b 100644 --- a/internal/server/smb/internal/v1beta2/conversion_generated.go +++ b/internal/server/smb/internal/v1beta2/conversion_generated.go @@ -34,7 +34,6 @@ func Convert_internal_NewSmbGlobalMappingRequest_To_v1beta2_NewSmbGlobalMappingR } func autoConvert_v1beta2_NewSmbGlobalMappingResponse_To_internal_NewSmbGlobalMappingResponse(in *v1beta2.NewSmbGlobalMappingResponse, out *internal.NewSmbGlobalMappingResponse) error { - out.Error = in.Error return nil } @@ -44,7 +43,6 @@ func Convert_v1beta2_NewSmbGlobalMappingResponse_To_internal_NewSmbGlobalMapping } func autoConvert_internal_NewSmbGlobalMappingResponse_To_v1beta2_NewSmbGlobalMappingResponse(in *internal.NewSmbGlobalMappingResponse, out *v1beta2.NewSmbGlobalMappingResponse) error { - out.Error = in.Error return nil } @@ -74,7 +72,6 @@ func Convert_internal_RemoveSmbGlobalMappingRequest_To_v1beta2_RemoveSmbGlobalMa } func autoConvert_v1beta2_RemoveSmbGlobalMappingResponse_To_internal_RemoveSmbGlobalMappingResponse(in *v1beta2.RemoveSmbGlobalMappingResponse, out *internal.RemoveSmbGlobalMappingResponse) error { - out.Error = in.Error return nil } @@ -84,7 +81,6 @@ func Convert_v1beta2_RemoveSmbGlobalMappingResponse_To_internal_RemoveSmbGlobalM } func autoConvert_internal_RemoveSmbGlobalMappingResponse_To_v1beta2_RemoveSmbGlobalMappingResponse(in *internal.RemoveSmbGlobalMappingResponse, out *v1beta2.RemoveSmbGlobalMappingResponse) error { - out.Error = in.Error return nil } diff --git a/internal/server/smb/server.go b/internal/server/smb/server.go index 380064bb..42445fbc 100644 --- a/internal/server/smb/server.go +++ b/internal/server/smb/server.go @@ -3,31 +3,29 @@ package smb import ( "context" "fmt" + "strings" + "github.com/kubernetes-csi/csi-proxy/client/apiversion" + "github.com/kubernetes-csi/csi-proxy/internal/os/smb" fsserver "github.com/kubernetes-csi/csi-proxy/internal/server/filesystem" "github.com/kubernetes-csi/csi-proxy/internal/server/smb/internal" "k8s.io/klog/v2" - "strings" ) type Server struct { - hostAPI API + hostAPI smb.API fsServer *fsserver.Server } -type API interface { - IsSmbMapped(remotePath string) (bool, error) - NewSmbLink(remotePath, localPath string) error - NewSmbGlobalMapping(remotePath, username, password string) error - RemoveSmbGlobalMapping(remotePath string) error -} +// check that Server implements the ServerInterface +var _ internal.ServerInterface = &Server{} func normalizeWindowsPath(path string) string { normalizedPath := strings.Replace(path, "/", "\\", -1) return normalizedPath } -func NewServer(hostAPI API, fsServer *fsserver.Server) (*Server, error) { +func NewServer(hostAPI smb.API, fsServer *fsserver.Server) (*Server, error) { return &Server{ hostAPI: hostAPI, fsServer: fsServer, @@ -35,7 +33,7 @@ func NewServer(hostAPI API, fsServer *fsserver.Server) (*Server, error) { } func (s *Server) NewSmbGlobalMapping(context context.Context, request *internal.NewSmbGlobalMappingRequest, version apiversion.Version) (*internal.NewSmbGlobalMappingResponse, error) { - klog.V(4).Infof("calling NewSmbGlobalMapping with remote path %q", request.RemotePath) + klog.V(2).Infof("calling NewSmbGlobalMapping with remote path %q", request.RemotePath) response := &internal.NewSmbGlobalMappingResponse{} remotePath := normalizeWindowsPath(request.RemotePath) localPath := request.LocalPath @@ -93,7 +91,7 @@ func (s *Server) NewSmbGlobalMapping(context context.Context, request *internal. } func (s *Server) RemoveSmbGlobalMapping(context context.Context, request *internal.RemoveSmbGlobalMappingRequest, version apiversion.Version) (*internal.RemoveSmbGlobalMappingResponse, error) { - klog.V(4).Infof("calling RemoveSmbGlobalMapping with remote path %q", request.RemotePath) + klog.V(2).Infof("calling RemoveSmbGlobalMapping with remote path %q", request.RemotePath) response := &internal.RemoveSmbGlobalMappingResponse{} remotePath := normalizeWindowsPath(request.RemotePath) diff --git a/internal/server/smb/server_test.go b/internal/server/smb/server_test.go index 614323fb..9cc7f8cb 100644 --- a/internal/server/smb/server_test.go +++ b/internal/server/smb/server_test.go @@ -6,12 +6,15 @@ import ( "github.com/kubernetes-csi/csi-proxy/client/apiversion" "github.com/kubernetes-csi/csi-proxy/internal/os/filesystem" + "github.com/kubernetes-csi/csi-proxy/internal/os/smb" fsserver "github.com/kubernetes-csi/csi-proxy/internal/server/filesystem" "github.com/kubernetes-csi/csi-proxy/internal/server/smb/internal" ) type fakeSmbAPI struct{} +var _ smb.API = &fakeSmbAPI{} + func (fakeSmbAPI) NewSmbGlobalMapping(remotePath, username, password string) error { return nil } @@ -96,12 +99,12 @@ func TestNewSmbGlobalMapping(t *testing.T) { Username: tc.username, Password: tc.password, } - response, err := srv.NewSmbGlobalMapping(context.TODO(), req, tc.version) + _, err := srv.NewSmbGlobalMapping(context.TODO(), req, tc.version) if tc.expectError && err == nil { t.Errorf("Expected error but NewSmbGlobalMapping returned a nil error") } if !tc.expectError && err != nil { - t.Errorf("Expected no errors but NewSmbGlobalMapping returned error: %s", response.Error) + t.Errorf("Expected no errors but NewSmbGlobalMapping returned error: %v", err) } } } diff --git a/vendor/github.com/kubernetes-csi/csi-proxy/client/api/smb/v1beta2/api.pb.go b/vendor/github.com/kubernetes-csi/csi-proxy/client/api/smb/v1beta2/api.pb.go index ce2f6b07..a7afd5ea 100644 --- a/vendor/github.com/kubernetes-csi/csi-proxy/client/api/smb/v1beta2/api.pb.go +++ b/vendor/github.com/kubernetes-csi/csi-proxy/client/api/smb/v1beta2/api.pb.go @@ -111,10 +111,6 @@ type NewSmbGlobalMappingResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - - // Windows error code - // Success is represented as 0 - Error string `protobuf:"bytes,1,opt,name=error,proto3" json:"error,omitempty"` } func (x *NewSmbGlobalMappingResponse) Reset() { @@ -149,13 +145,6 @@ func (*NewSmbGlobalMappingResponse) Descriptor() ([]byte, []int) { return file_github_com_kubernetes_csi_csi_proxy_client_api_smb_v1beta2_api_proto_rawDescGZIP(), []int{1} } -func (x *NewSmbGlobalMappingResponse) GetError() string { - if x != nil { - return x.Error - } - return "" -} - type RemoveSmbGlobalMappingRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -216,10 +205,6 @@ type RemoveSmbGlobalMappingResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - - // Windows error code - // Success is represented as 0 - Error string `protobuf:"bytes,1,opt,name=error,proto3" json:"error,omitempty"` } func (x *RemoveSmbGlobalMappingResponse) Reset() { @@ -254,13 +239,6 @@ func (*RemoveSmbGlobalMappingResponse) Descriptor() ([]byte, []int) { return file_github_com_kubernetes_csi_csi_proxy_client_api_smb_v1beta2_api_proto_rawDescGZIP(), []int{3} } -func (x *RemoveSmbGlobalMappingResponse) GetError() string { - if x != nil { - return x.Error - } - return "" -} - var File_github_com_kubernetes_csi_csi_proxy_client_api_smb_v1beta2_api_proto protoreflect.FileDescriptor var file_github_com_kubernetes_csi_csi_proxy_client_api_smb_v1beta2_api_proto_rawDesc = []byte{ @@ -278,36 +256,33 @@ var file_github_com_kubernetes_csi_csi_proxy_client_api_smb_v1beta2_api_proto_ra 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x61, - 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x22, 0x33, 0x0a, 0x1b, 0x4e, 0x65, 0x77, 0x53, 0x6d, 0x62, + 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x22, 0x1d, 0x0a, 0x1b, 0x4e, 0x65, 0x77, 0x53, 0x6d, 0x62, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x4d, 0x61, 0x70, 0x70, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0x40, 0x0a, 0x1d, 0x52, - 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x53, 0x6d, 0x62, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x4d, 0x61, - 0x70, 0x70, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1f, 0x0a, 0x0b, - 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x0a, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, 0x50, 0x61, 0x74, 0x68, 0x22, 0x36, 0x0a, - 0x1e, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x53, 0x6d, 0x62, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, - 0x4d, 0x61, 0x70, 0x70, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, - 0x14, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, - 0x65, 0x72, 0x72, 0x6f, 0x72, 0x32, 0xd6, 0x01, 0x0a, 0x03, 0x53, 0x6d, 0x62, 0x12, 0x62, 0x0a, - 0x13, 0x4e, 0x65, 0x77, 0x53, 0x6d, 0x62, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x4d, 0x61, 0x70, - 0x70, 0x69, 0x6e, 0x67, 0x12, 0x23, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x32, 0x2e, 0x4e, - 0x65, 0x77, 0x53, 0x6d, 0x62, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x4d, 0x61, 0x70, 0x70, 0x69, - 0x6e, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x24, 0x2e, 0x76, 0x31, 0x62, 0x65, - 0x74, 0x61, 0x32, 0x2e, 0x4e, 0x65, 0x77, 0x53, 0x6d, 0x62, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, - 0x4d, 0x61, 0x70, 0x70, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, - 0x00, 0x12, 0x6b, 0x0a, 0x16, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x53, 0x6d, 0x62, 0x47, 0x6c, - 0x6f, 0x62, 0x61, 0x6c, 0x4d, 0x61, 0x70, 0x70, 0x69, 0x6e, 0x67, 0x12, 0x26, 0x2e, 0x76, 0x31, - 0x62, 0x65, 0x74, 0x61, 0x32, 0x2e, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x53, 0x6d, 0x62, 0x47, - 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x4d, 0x61, 0x70, 0x70, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x27, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x32, 0x2e, 0x52, 0x65, - 0x6d, 0x6f, 0x76, 0x65, 0x53, 0x6d, 0x62, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x4d, 0x61, 0x70, - 0x70, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x3c, - 0x5a, 0x3a, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6b, 0x75, 0x62, - 0x65, 0x72, 0x6e, 0x65, 0x74, 0x65, 0x73, 0x2d, 0x63, 0x73, 0x69, 0x2f, 0x63, 0x73, 0x69, 0x2d, - 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2f, 0x61, 0x70, 0x69, - 0x2f, 0x73, 0x6d, 0x62, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x32, 0x62, 0x06, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x33, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x40, 0x0a, 0x1d, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x53, + 0x6d, 0x62, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x4d, 0x61, 0x70, 0x70, 0x69, 0x6e, 0x67, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1f, 0x0a, 0x0b, 0x72, 0x65, 0x6d, 0x6f, 0x74, 0x65, + 0x5f, 0x70, 0x61, 0x74, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x72, 0x65, 0x6d, + 0x6f, 0x74, 0x65, 0x50, 0x61, 0x74, 0x68, 0x22, 0x20, 0x0a, 0x1e, 0x52, 0x65, 0x6d, 0x6f, 0x76, + 0x65, 0x53, 0x6d, 0x62, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x4d, 0x61, 0x70, 0x70, 0x69, 0x6e, + 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0xd6, 0x01, 0x0a, 0x03, 0x53, 0x6d, + 0x62, 0x12, 0x62, 0x0a, 0x13, 0x4e, 0x65, 0x77, 0x53, 0x6d, 0x62, 0x47, 0x6c, 0x6f, 0x62, 0x61, + 0x6c, 0x4d, 0x61, 0x70, 0x70, 0x69, 0x6e, 0x67, 0x12, 0x23, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, + 0x61, 0x32, 0x2e, 0x4e, 0x65, 0x77, 0x53, 0x6d, 0x62, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x4d, + 0x61, 0x70, 0x70, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x24, 0x2e, + 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x32, 0x2e, 0x4e, 0x65, 0x77, 0x53, 0x6d, 0x62, 0x47, 0x6c, + 0x6f, 0x62, 0x61, 0x6c, 0x4d, 0x61, 0x70, 0x70, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x6b, 0x0a, 0x16, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x53, + 0x6d, 0x62, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x4d, 0x61, 0x70, 0x70, 0x69, 0x6e, 0x67, 0x12, + 0x26, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x32, 0x2e, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, + 0x53, 0x6d, 0x62, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x4d, 0x61, 0x70, 0x70, 0x69, 0x6e, 0x67, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x27, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, + 0x32, 0x2e, 0x52, 0x65, 0x6d, 0x6f, 0x76, 0x65, 0x53, 0x6d, 0x62, 0x47, 0x6c, 0x6f, 0x62, 0x61, + 0x6c, 0x4d, 0x61, 0x70, 0x70, 0x69, 0x6e, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x22, 0x00, 0x42, 0x3c, 0x5a, 0x3a, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, + 0x2f, 0x6b, 0x75, 0x62, 0x65, 0x72, 0x6e, 0x65, 0x74, 0x65, 0x73, 0x2d, 0x63, 0x73, 0x69, 0x2f, + 0x63, 0x73, 0x69, 0x2d, 0x70, 0x72, 0x6f, 0x78, 0x79, 0x2f, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, + 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x73, 0x6d, 0x62, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x32, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/vendor/github.com/kubernetes-csi/csi-proxy/client/api/smb/v1beta2/api.proto b/vendor/github.com/kubernetes-csi/csi-proxy/client/api/smb/v1beta2/api.proto index b30e69bf..9e4fe249 100644 --- a/vendor/github.com/kubernetes-csi/csi-proxy/client/api/smb/v1beta2/api.proto +++ b/vendor/github.com/kubernetes-csi/csi-proxy/client/api/smb/v1beta2/api.proto @@ -35,9 +35,7 @@ message NewSmbGlobalMappingRequest { } message NewSmbGlobalMappingResponse { - // Windows error code - // Success is represented as 0 - string error = 1; + // Intentionally empty. } @@ -55,7 +53,5 @@ message RemoveSmbGlobalMappingRequest { } message RemoveSmbGlobalMappingResponse { - // Windows error code - // Success is represented as 0 - string error = 1; + // Intentionally empty. } diff --git a/vendor/modules.txt b/vendor/modules.txt index aea7ee50..8292679d 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -52,6 +52,8 @@ github.com/kubernetes-csi/csi-proxy/client/groups/filesystem/v1alpha1 github.com/kubernetes-csi/csi-proxy/client/groups/filesystem/v1beta1 github.com/kubernetes-csi/csi-proxy/client/groups/filesystem/v1beta2 github.com/kubernetes-csi/csi-proxy/client/groups/iscsi/v1alpha2 +github.com/kubernetes-csi/csi-proxy/client/groups/smb/v1alpha1 +github.com/kubernetes-csi/csi-proxy/client/groups/smb/v1beta1 github.com/kubernetes-csi/csi-proxy/client/groups/smb/v1beta2 github.com/kubernetes-csi/csi-proxy/client/groups/system/v1alpha1 github.com/kubernetes-csi/csi-proxy/client/groups/volume/v1alpha1 From f826e46afb966c008e36c8fc8c312d2c55ed4af2 Mon Sep 17 00:00:00 2001 From: Mauricio Poppe Date: Thu, 3 Jun 2021 00:01:29 +0000 Subject: [PATCH 4/4] Include ignored vendor files --- client/api/filesystem/v1beta2/api.pb.go | 5 +- .../client/api/filesystem/v1beta2/api.pb.go | 5 +- .../groups/smb/v1alpha1/client_generated.go | 74 +++++++++++++++++++ .../groups/smb/v1beta1/client_generated.go | 74 +++++++++++++++++++ 4 files changed, 152 insertions(+), 6 deletions(-) create mode 100644 vendor/github.com/kubernetes-csi/csi-proxy/client/groups/smb/v1alpha1/client_generated.go create mode 100644 vendor/github.com/kubernetes-csi/csi-proxy/client/groups/smb/v1beta1/client_generated.go diff --git a/client/api/filesystem/v1beta2/api.pb.go b/client/api/filesystem/v1beta2/api.pb.go index d1c3a914..0219d023 100644 --- a/client/api/filesystem/v1beta2/api.pb.go +++ b/client/api/filesystem/v1beta2/api.pb.go @@ -8,14 +8,13 @@ package v1beta2 import ( context "context" - reflect "reflect" - sync "sync" - grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" ) const ( diff --git a/vendor/github.com/kubernetes-csi/csi-proxy/client/api/filesystem/v1beta2/api.pb.go b/vendor/github.com/kubernetes-csi/csi-proxy/client/api/filesystem/v1beta2/api.pb.go index d1c3a914..0219d023 100644 --- a/vendor/github.com/kubernetes-csi/csi-proxy/client/api/filesystem/v1beta2/api.pb.go +++ b/vendor/github.com/kubernetes-csi/csi-proxy/client/api/filesystem/v1beta2/api.pb.go @@ -8,14 +8,13 @@ package v1beta2 import ( context "context" - reflect "reflect" - sync "sync" - grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" ) const ( diff --git a/vendor/github.com/kubernetes-csi/csi-proxy/client/groups/smb/v1alpha1/client_generated.go b/vendor/github.com/kubernetes-csi/csi-proxy/client/groups/smb/v1alpha1/client_generated.go new file mode 100644 index 00000000..45186cae --- /dev/null +++ b/vendor/github.com/kubernetes-csi/csi-proxy/client/groups/smb/v1alpha1/client_generated.go @@ -0,0 +1,74 @@ +// Code generated by csi-proxy-api-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "context" + "net" + + "github.com/Microsoft/go-winio" + "github.com/kubernetes-csi/csi-proxy/client" + "github.com/kubernetes-csi/csi-proxy/client/api/smb/v1alpha1" + "github.com/kubernetes-csi/csi-proxy/client/apiversion" + "google.golang.org/grpc" +) + +// GroupName is the group name of this API. +const GroupName = "smb" + +// Version is the api version. +var Version = apiversion.NewVersionOrPanic("v1alpha1") + +type Client struct { + client v1alpha1.SmbClient + connection *grpc.ClientConn +} + +// NewClient returns a client to make calls to the smb API group version v1alpha1. +// It's the caller's responsibility to Close the client when done. +func NewClient() (*Client, error) { + pipePath := client.PipePath(GroupName, Version) + return NewClientWithPipePath(pipePath) +} + +// NewClientWithPipePath returns a client to make calls to the named pipe located at "pipePath". +// It's the caller's responsibility to Close the client when done. +func NewClientWithPipePath(pipePath string) (*Client, error) { + + // verify that the pipe exists + _, err := winio.DialPipe(pipePath, nil) + if err != nil { + return nil, err + } + + connection, err := grpc.Dial(pipePath, + grpc.WithContextDialer(func(context context.Context, s string) (net.Conn, error) { + return winio.DialPipeContext(context, s) + }), + grpc.WithInsecure()) + if err != nil { + return nil, err + } + + client := v1alpha1.NewSmbClient(connection) + return &Client{ + client: client, + connection: connection, + }, nil +} + +// Close closes the client. It must be called before the client gets GC-ed. +func (w *Client) Close() error { + return w.connection.Close() +} + +// ensures we implement all the required methods +var _ v1alpha1.SmbClient = &Client{} + +func (w *Client) NewSmbGlobalMapping(context context.Context, request *v1alpha1.NewSmbGlobalMappingRequest, opts ...grpc.CallOption) (*v1alpha1.NewSmbGlobalMappingResponse, error) { + return w.client.NewSmbGlobalMapping(context, request, opts...) +} + +func (w *Client) RemoveSmbGlobalMapping(context context.Context, request *v1alpha1.RemoveSmbGlobalMappingRequest, opts ...grpc.CallOption) (*v1alpha1.RemoveSmbGlobalMappingResponse, error) { + return w.client.RemoveSmbGlobalMapping(context, request, opts...) +} diff --git a/vendor/github.com/kubernetes-csi/csi-proxy/client/groups/smb/v1beta1/client_generated.go b/vendor/github.com/kubernetes-csi/csi-proxy/client/groups/smb/v1beta1/client_generated.go new file mode 100644 index 00000000..9796ccb1 --- /dev/null +++ b/vendor/github.com/kubernetes-csi/csi-proxy/client/groups/smb/v1beta1/client_generated.go @@ -0,0 +1,74 @@ +// Code generated by csi-proxy-api-gen. DO NOT EDIT. + +package v1beta1 + +import ( + "context" + "net" + + "github.com/Microsoft/go-winio" + "github.com/kubernetes-csi/csi-proxy/client" + "github.com/kubernetes-csi/csi-proxy/client/api/smb/v1beta1" + "github.com/kubernetes-csi/csi-proxy/client/apiversion" + "google.golang.org/grpc" +) + +// GroupName is the group name of this API. +const GroupName = "smb" + +// Version is the api version. +var Version = apiversion.NewVersionOrPanic("v1beta1") + +type Client struct { + client v1beta1.SmbClient + connection *grpc.ClientConn +} + +// NewClient returns a client to make calls to the smb API group version v1beta1. +// It's the caller's responsibility to Close the client when done. +func NewClient() (*Client, error) { + pipePath := client.PipePath(GroupName, Version) + return NewClientWithPipePath(pipePath) +} + +// NewClientWithPipePath returns a client to make calls to the named pipe located at "pipePath". +// It's the caller's responsibility to Close the client when done. +func NewClientWithPipePath(pipePath string) (*Client, error) { + + // verify that the pipe exists + _, err := winio.DialPipe(pipePath, nil) + if err != nil { + return nil, err + } + + connection, err := grpc.Dial(pipePath, + grpc.WithContextDialer(func(context context.Context, s string) (net.Conn, error) { + return winio.DialPipeContext(context, s) + }), + grpc.WithInsecure()) + if err != nil { + return nil, err + } + + client := v1beta1.NewSmbClient(connection) + return &Client{ + client: client, + connection: connection, + }, nil +} + +// Close closes the client. It must be called before the client gets GC-ed. +func (w *Client) Close() error { + return w.connection.Close() +} + +// ensures we implement all the required methods +var _ v1beta1.SmbClient = &Client{} + +func (w *Client) NewSmbGlobalMapping(context context.Context, request *v1beta1.NewSmbGlobalMappingRequest, opts ...grpc.CallOption) (*v1beta1.NewSmbGlobalMappingResponse, error) { + return w.client.NewSmbGlobalMapping(context, request, opts...) +} + +func (w *Client) RemoveSmbGlobalMapping(context context.Context, request *v1beta1.RemoveSmbGlobalMappingRequest, opts ...grpc.CallOption) (*v1beta1.RemoveSmbGlobalMappingResponse, error) { + return w.client.RemoveSmbGlobalMapping(context, request, opts...) +}