diff options
author | Jacob Vosmaer <jacob@gitlab.com> | 2019-10-23 13:52:32 +0300 |
---|---|---|
committer | Jacob Vosmaer <jacob@gitlab.com> | 2019-10-23 13:52:32 +0300 |
commit | c665f43444faccfe5208b07e906cccd995d437b0 (patch) | |
tree | 4a93cff2feea7b8cad4b5d47ec0d0419fddd0a9a | |
parent | 50c9942e60aa02dbc708be09588b56b59cc7c0d3 (diff) | |
parent | 87230c01f37109dde8fe4568af83dc3820139969 (diff) |
Merge branch 'jc-remove-list-directories' into 'master'
Remove Storage service
Closes #1923
See merge request gitlab-org/gitaly!1544
-rw-r--r-- | changelogs/unreleased/jc-remove-list-directories.yml | 5 | ||||
-rw-r--r-- | internal/praefect/protoregistry/protoregistry_test.go | 8 | ||||
-rw-r--r-- | internal/service/register.go | 2 | ||||
-rw-r--r-- | internal/service/storage/.gitignore | 1 | ||||
-rw-r--r-- | internal/service/storage/deleteall.go | 69 | ||||
-rw-r--r-- | internal/service/storage/deleteall_test.go | 133 | ||||
-rw-r--r-- | internal/service/storage/listdirectories.go | 68 | ||||
-rw-r--r-- | internal/service/storage/listdirectories_test.go | 89 | ||||
-rw-r--r-- | internal/service/storage/server.go | 12 | ||||
-rw-r--r-- | internal/service/storage/testhelper_test.go | 69 | ||||
-rw-r--r-- | proto/go/gitalypb/protolist.go | 1 | ||||
-rw-r--r-- | proto/go/gitalypb/storage.pb.go | 356 | ||||
-rw-r--r-- | proto/storage.proto | 37 | ||||
-rw-r--r-- | ruby/proto/gitaly.rb | 2 | ||||
-rw-r--r-- | ruby/proto/gitaly/storage_pb.rb | 27 | ||||
-rw-r--r-- | ruby/proto/gitaly/storage_services_pb.rb | 23 |
16 files changed, 5 insertions, 897 deletions
diff --git a/changelogs/unreleased/jc-remove-list-directories.yml b/changelogs/unreleased/jc-remove-list-directories.yml new file mode 100644 index 000000000..c15cfefcc --- /dev/null +++ b/changelogs/unreleased/jc-remove-list-directories.yml @@ -0,0 +1,5 @@ +--- +title: Remove StorageService +merge_request: 1544 +author: +type: deprecated diff --git a/internal/praefect/protoregistry/protoregistry_test.go b/internal/praefect/protoregistry/protoregistry_test.go index 540d73926..dfcc09cc8 100644 --- a/internal/praefect/protoregistry/protoregistry_test.go +++ b/internal/praefect/protoregistry/protoregistry_test.go @@ -168,10 +168,6 @@ func TestPopulatesProtoRegistry(t *testing.T) { "SSHReceivePack": protoregistry.OpMutator, "SSHUploadArchive": protoregistry.OpMutator, }, - "StorageService": map[string]protoregistry.OpType{ - "ListDirectories": protoregistry.OpAccessor, - "DeleteAllRepositories": protoregistry.OpMutator, - }, "WikiService": map[string]protoregistry.OpType{ "WikiGetPageVersions": protoregistry.OpAccessor, "WikiWritePage": protoregistry.OpMutator, @@ -220,10 +216,6 @@ func TestMethodInfoScope(t *testing.T) { scope: protoregistry.ScopeRepository, }, { - method: "/gitaly.StorageService/ListDirectories", - scope: protoregistry.ScopeStorage, - }, - { method: "/gitaly.ServerService/ServerInfo", scope: protoregistry.ScopeServer, }, diff --git a/internal/service/register.go b/internal/service/register.go index aa1466e14..f12215e56 100644 --- a/internal/service/register.go +++ b/internal/service/register.go @@ -16,7 +16,6 @@ import ( "gitlab.com/gitlab-org/gitaly/internal/service/server" "gitlab.com/gitlab-org/gitaly/internal/service/smarthttp" "gitlab.com/gitlab-org/gitaly/internal/service/ssh" - "gitlab.com/gitlab-org/gitaly/internal/service/storage" "gitlab.com/gitlab-org/gitaly/internal/service/wiki" "gitlab.com/gitlab-org/gitaly/proto/go/gitalypb" "google.golang.org/grpc" @@ -41,7 +40,6 @@ func RegisterAll(grpcServer *grpc.Server, rubyServer *rubyserver.Server) { gitalypb.RegisterConflictsServiceServer(grpcServer, conflicts.NewServer(rubyServer)) gitalypb.RegisterRemoteServiceServer(grpcServer, remote.NewServer(rubyServer)) gitalypb.RegisterServerServiceServer(grpcServer, server.NewServer()) - gitalypb.RegisterStorageServiceServer(grpcServer, storage.NewServer()) gitalypb.RegisterObjectPoolServiceServer(grpcServer, objectpool.NewServer()) healthpb.RegisterHealthServer(grpcServer, health.NewServer()) diff --git a/internal/service/storage/.gitignore b/internal/service/storage/.gitignore deleted file mode 100644 index 2743e47ce..000000000 --- a/internal/service/storage/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/testdata/repositories diff --git a/internal/service/storage/deleteall.go b/internal/service/storage/deleteall.go deleted file mode 100644 index f560b0d16..000000000 --- a/internal/service/storage/deleteall.go +++ /dev/null @@ -1,69 +0,0 @@ -package storage - -import ( - "context" - "io" - "os" - "path" - - grpc_logrus "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus" - log "github.com/sirupsen/logrus" - "gitlab.com/gitlab-org/gitaly/internal/helper" - "gitlab.com/gitlab-org/gitaly/internal/tempdir" - "gitlab.com/gitlab-org/gitaly/proto/go/gitalypb" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" -) - -func (s *server) DeleteAllRepositories(ctx context.Context, req *gitalypb.DeleteAllRepositoriesRequest) (*gitalypb.DeleteAllRepositoriesResponse, error) { - storageDir, err := helper.GetStorageByName(req.StorageName) - if err != nil { - return nil, status.Errorf(codes.InvalidArgument, "storage lookup failed: %v", err) - } - - trashDir, err := tempdir.ForDeleteAllRepositories(req.StorageName) - if err != nil { - return nil, status.Errorf(codes.Internal, "create trash dir: %v", err) - } - - dir, err := os.Open(storageDir) - if err != nil { - return nil, status.Errorf(codes.Internal, "open storage dir: %v", err) - } - defer dir.Close() - - grpc_logrus.Extract(ctx).WithFields(log.Fields{ - "trashDir": trashDir, - "storage": req.StorageName, - }).Warn("moving all repositories in storage to trash") - - count := 0 - for done := false; !done; { - dirents, err := dir.Readdir(100) - if err == io.EOF { - done = true - } else if err != nil { - return nil, status.Errorf(codes.Internal, "read storage dir: %v", err) - } - - for _, d := range dirents { - if d.Name() == tempdir.GitalyDataPrefix { - continue - } - - count++ - - if err := os.Rename(path.Join(storageDir, d.Name()), path.Join(trashDir, d.Name())); err != nil { - return nil, status.Errorf(codes.Internal, "move dir: %v", err) - } - } - } - - grpc_logrus.Extract(ctx).WithFields(log.Fields{ - "trashDir": trashDir, - "storage": req.StorageName, - "numDirectories": count, - }).Warn("directories moved to trash") - - return &gitalypb.DeleteAllRepositoriesResponse{}, nil -} diff --git a/internal/service/storage/deleteall_test.go b/internal/service/storage/deleteall_test.go deleted file mode 100644 index be0814a81..000000000 --- a/internal/service/storage/deleteall_test.go +++ /dev/null @@ -1,133 +0,0 @@ -package storage - -import ( - "fmt" - "io/ioutil" - "os" - "os/exec" - "path" - "testing" - - "github.com/stretchr/testify/require" - "gitlab.com/gitlab-org/gitaly/internal/config" - "gitlab.com/gitlab-org/gitaly/internal/tempdir" - "gitlab.com/gitlab-org/gitaly/internal/testhelper" - "gitlab.com/gitlab-org/gitaly/proto/go/gitalypb" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" -) - -func TestDeleteAllSuccess(t *testing.T) { - require.NoError(t, os.RemoveAll(testStorage.Path)) - - gitalyDataFile := path.Join(testStorage.Path, tempdir.GitalyDataPrefix+"/foobar") - require.NoError(t, os.MkdirAll(path.Dir(gitalyDataFile), 0755)) - require.NoError(t, ioutil.WriteFile(gitalyDataFile, nil, 0644)) - - repoPaths := []string{ - "foo/bar1.git", - "foo/bar2.git", - "baz/foo/qux3.git", - "baz/foo/bar1.git", - } - - for _, p := range repoPaths { - fullPath := path.Join(testStorage.Path, p) - require.NoError(t, os.MkdirAll(fullPath, 0755)) - require.NoError(t, exec.Command("git", "init", "--bare", fullPath).Run()) - } - - dirents := storageDirents(t, testStorage) - expectedNames := []string{"+gitaly", "baz", "foo"} - require.Len(t, dirents, len(expectedNames)) - for i, expected := range expectedNames { - require.Equal(t, expected, dirents[i].Name()) - } - - server, socketPath := runStorageServer(t) - defer server.Stop() - - client, conn := newStorageClient(t, socketPath) - defer conn.Close() - - ctx, cancel := testhelper.Context() - defer cancel() - _, err := client.DeleteAllRepositories(ctx, &gitalypb.DeleteAllRepositoriesRequest{StorageName: testStorage.Name}) - require.NoError(t, err) - - dirents = storageDirents(t, testStorage) - require.Len(t, dirents, 1) - require.Equal(t, "+gitaly", dirents[0].Name()) - - _, err = os.Stat(gitalyDataFile) - require.NoError(t, err, "unrelated data file should still exist") -} - -func storageDirents(t *testing.T, st config.Storage) []os.FileInfo { - dirents, err := ioutil.ReadDir(st.Path) - require.NoError(t, err) - return dirents -} - -func TestDeleteAllFail(t *testing.T) { - server, socketPath := runStorageServer(t) - defer server.Stop() - - client, conn := newStorageClient(t, socketPath) - defer conn.Close() - - ctx, cancel := testhelper.Context() - defer cancel() - - testCases := []struct { - desc string - req *gitalypb.DeleteAllRepositoriesRequest - setup func(t *testing.T) - code codes.Code - }{ - { - desc: "empty storage name", - req: &gitalypb.DeleteAllRepositoriesRequest{}, - code: codes.InvalidArgument, - }, - { - desc: "unknown storage name", - req: &gitalypb.DeleteAllRepositoriesRequest{StorageName: "does not exist"}, - code: codes.InvalidArgument, - }, - { - desc: "cannot create trash dir", - req: &gitalypb.DeleteAllRepositoriesRequest{StorageName: testStorage.Name}, - setup: func(t *testing.T) { - dataDir := path.Join(testStorage.Path, tempdir.GitalyDataPrefix) - require.NoError(t, os.RemoveAll(dataDir)) - require.NoError(t, ioutil.WriteFile(dataDir, nil, 0644), "write file where there should be a directory") - - lsOut, err := exec.Command("ls", "-l", testStorage.Path).CombinedOutput() - require.NoError(t, err) - fmt.Printf("%s\n", lsOut) - }, - code: codes.Internal, - }, - } - - for _, tc := range testCases { - t.Run(tc.desc, func(t *testing.T) { - require.NoError(t, os.RemoveAll(testStorage.Path)) - require.NoError(t, os.MkdirAll(testStorage.Path, 0755)) - - repoPath := path.Join(testStorage.Path, "foobar.git") - require.NoError(t, exec.Command("git", "init", "--bare", repoPath).Run()) - - if tc.setup != nil { - tc.setup(t) - } - - _, err := client.DeleteAllRepositories(ctx, tc.req) - require.Equal(t, tc.code, status.Code(err), "expected grpc status code") - - _, err = os.Stat(repoPath) - require.NoError(t, err, "repo must still exist") - }) - } -} diff --git a/internal/service/storage/listdirectories.go b/internal/service/storage/listdirectories.go deleted file mode 100644 index 8c4e90b06..000000000 --- a/internal/service/storage/listdirectories.go +++ /dev/null @@ -1,68 +0,0 @@ -package storage - -import ( - "os" - "path/filepath" - "strings" - - "gitlab.com/gitlab-org/gitaly/internal/helper" - "gitlab.com/gitlab-org/gitaly/internal/helper/chunk" - "gitlab.com/gitlab-org/gitaly/proto/go/gitalypb" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" -) - -func (s *server) ListDirectories(req *gitalypb.ListDirectoriesRequest, stream gitalypb.StorageService_ListDirectoriesServer) error { - storageDir, err := helper.GetStorageByName(req.StorageName) - if err != nil { - return status.Errorf(codes.InvalidArgument, "storage lookup failed: %v", err) - } - - storageDir = storageDir + "/" - maxDepth := dirDepth(storageDir) + req.GetDepth() - sender := chunk.New(&dirSender{stream: stream}) - - err = filepath.Walk(storageDir, func(path string, info os.FileInfo, err error) error { - if err != nil { - return err - } - - if info.IsDir() { - relPath := strings.TrimPrefix(path, storageDir) - if relPath == "" { - return nil - } - - sender.Send(relPath) - - if dirDepth(path)+1 > maxDepth { - return filepath.SkipDir - } - - return nil - } - - return nil - }) - - if err != nil { - return err - } - - return sender.Flush() -} - -func dirDepth(dir string) uint32 { - return uint32(len(strings.Split(dir, string(os.PathSeparator)))) + 1 -} - -type dirSender struct { - stream gitalypb.StorageService_ListDirectoriesServer - dirs []string -} - -func (s *dirSender) Reset() { s.dirs = nil } -func (s *dirSender) Append(it chunk.Item) { s.dirs = append(s.dirs, it.(string)) } -func (s *dirSender) Send() error { - return s.stream.Send(&gitalypb.ListDirectoriesResponse{Paths: s.dirs}) -} diff --git a/internal/service/storage/listdirectories_test.go b/internal/service/storage/listdirectories_test.go deleted file mode 100644 index 115d17444..000000000 --- a/internal/service/storage/listdirectories_test.go +++ /dev/null @@ -1,89 +0,0 @@ -package storage - -import ( - "io" - "io/ioutil" - "os" - "path" - "path/filepath" - "strings" - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - "gitlab.com/gitlab-org/gitaly/internal/config" - "gitlab.com/gitlab-org/gitaly/internal/testhelper" - "gitlab.com/gitlab-org/gitaly/proto/go/gitalypb" -) - -func TestListDirectories(t *testing.T) { - testDir := path.Join(testStorage.Path, t.Name()) - require.NoError(t, os.MkdirAll(path.Dir(testDir), 0755)) - defer os.RemoveAll(testDir) - - // Mock the storage dir being our test dir, so results aren't influenced - // by other tests. - testStorages := []config.Storage{{Name: "default", Path: testDir}} - - defer func(oldStorages []config.Storage) { - config.Config.Storages = oldStorages - }(config.Config.Storages) - config.Config.Storages = testStorages - - repoPaths := []string{"foo", "bar", "bar/baz", "bar/baz/foo/buz"} - for _, p := range repoPaths { - dirPath := filepath.Join(testDir, p) - require.NoError(t, os.MkdirAll(dirPath, 0755)) - require.NoError(t, ioutil.WriteFile(filepath.Join(dirPath, "file"), []byte("Hello"), 0644)) - } - - server, socketPath := runStorageServer(t) - defer server.Stop() - - client, conn := newStorageClient(t, socketPath) - defer conn.Close() - - ctx, cancel := testhelper.Context() - defer cancel() - - testCases := []struct { - depth uint32 - dirs []string - }{ - { - depth: 0, - dirs: []string{"bar", "foo"}, - }, - { - depth: 1, - dirs: []string{"bar", "bar/baz", "foo"}, - }, - { - depth: 3, - dirs: []string{"bar", "bar/baz", "bar/baz/foo", "bar/baz/foo/buz", "foo"}, - }, - } - - for _, tc := range testCases { - stream, err := client.ListDirectories(ctx, &gitalypb.ListDirectoriesRequest{StorageName: "default", Depth: tc.depth}) - - var dirs []string - for { - resp, err := stream.Recv() - if err == io.EOF { - break - } - - require.NoError(t, err) - dirs = append(dirs, resp.GetPaths()...) - } - - require.NoError(t, err) - require.NotEmpty(t, dirs) - assert.Equal(t, tc.dirs, dirs) - - for _, dir := range dirs { - assert.False(t, strings.HasSuffix(dir, "file")) - } - } -} diff --git a/internal/service/storage/server.go b/internal/service/storage/server.go deleted file mode 100644 index 84cf4fdc4..000000000 --- a/internal/service/storage/server.go +++ /dev/null @@ -1,12 +0,0 @@ -package storage - -import "gitlab.com/gitlab-org/gitaly/proto/go/gitalypb" - -type server struct { - gitalypb.UnimplementedStorageServiceServer -} - -// NewServer creates a new instance of a gRPC storage server -func NewServer() gitalypb.StorageServiceServer { - return &server{} -} diff --git a/internal/service/storage/testhelper_test.go b/internal/service/storage/testhelper_test.go deleted file mode 100644 index 63da71a65..000000000 --- a/internal/service/storage/testhelper_test.go +++ /dev/null @@ -1,69 +0,0 @@ -package storage - -import ( - "net" - "os" - "path/filepath" - "testing" - - "gitlab.com/gitlab-org/gitaly/internal/config" - "gitlab.com/gitlab-org/gitaly/internal/testhelper" - "gitlab.com/gitlab-org/gitaly/proto/go/gitalypb" - "google.golang.org/grpc" - "google.golang.org/grpc/reflection" -) - -var testStorage config.Storage - -func TestMain(m *testing.M) { - configureTestStorage() - os.Exit(m.Run()) -} - -func configureTestStorage() { - storagePath, err := filepath.Abs("testdata/repositories/storage1") - if err != nil { - panic(err) - } - - if err := os.RemoveAll(storagePath); err != nil { - panic(err) - } - - if err := os.MkdirAll(storagePath, 0755); err != nil { - panic(err) - } - - testStorage = config.Storage{Name: "storage-will-be-deleted", Path: storagePath} - - config.Config.Storages = []config.Storage{testStorage} -} - -func runStorageServer(t *testing.T) (*grpc.Server, string) { - server := testhelper.NewTestGrpcServer(t, nil, nil) - serverSocketPath := testhelper.GetTemporaryGitalySocketFileName() - - listener, err := net.Listen("unix", serverSocketPath) - if err != nil { - t.Fatal(err) - } - - gitalypb.RegisterStorageServiceServer(server, NewServer()) - reflection.Register(server) - - go server.Serve(listener) - - return server, "unix://" + serverSocketPath -} - -func newStorageClient(t *testing.T, serverSocketPath string) (gitalypb.StorageServiceClient, *grpc.ClientConn) { - connOpts := []grpc.DialOption{ - grpc.WithInsecure(), - } - conn, err := grpc.Dial(serverSocketPath, connOpts...) - if err != nil { - t.Fatal(err) - } - - return gitalypb.NewStorageServiceClient(conn), conn -} diff --git a/proto/go/gitalypb/protolist.go b/proto/go/gitalypb/protolist.go index c85049d62..8e400d0df 100644 --- a/proto/go/gitalypb/protolist.go +++ b/proto/go/gitalypb/protolist.go @@ -19,6 +19,5 @@ var GitalyProtos = []string{ "shared.proto", "smarthttp.proto", "ssh.proto", - "storage.proto", "wiki.proto", } diff --git a/proto/go/gitalypb/storage.pb.go b/proto/go/gitalypb/storage.pb.go deleted file mode 100644 index 5d4770406..000000000 --- a/proto/go/gitalypb/storage.pb.go +++ /dev/null @@ -1,356 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// source: storage.proto - -package gitalypb - -import ( - context "context" - fmt "fmt" - proto "github.com/golang/protobuf/proto" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" - math "math" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package - -type ListDirectoriesRequest struct { - StorageName string `protobuf:"bytes,1,opt,name=storage_name,json=storageName,proto3" json:"storage_name,omitempty"` - Depth uint32 `protobuf:"varint,2,opt,name=depth,proto3" json:"depth,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ListDirectoriesRequest) Reset() { *m = ListDirectoriesRequest{} } -func (m *ListDirectoriesRequest) String() string { return proto.CompactTextString(m) } -func (*ListDirectoriesRequest) ProtoMessage() {} -func (*ListDirectoriesRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_0d2c4ccf1453ffdb, []int{0} -} - -func (m *ListDirectoriesRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_ListDirectoriesRequest.Unmarshal(m, b) -} -func (m *ListDirectoriesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_ListDirectoriesRequest.Marshal(b, m, deterministic) -} -func (m *ListDirectoriesRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_ListDirectoriesRequest.Merge(m, src) -} -func (m *ListDirectoriesRequest) XXX_Size() int { - return xxx_messageInfo_ListDirectoriesRequest.Size(m) -} -func (m *ListDirectoriesRequest) XXX_DiscardUnknown() { - xxx_messageInfo_ListDirectoriesRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_ListDirectoriesRequest proto.InternalMessageInfo - -func (m *ListDirectoriesRequest) GetStorageName() string { - if m != nil { - return m.StorageName - } - return "" -} - -func (m *ListDirectoriesRequest) GetDepth() uint32 { - if m != nil { - return m.Depth - } - return 0 -} - -type ListDirectoriesResponse struct { - Paths []string `protobuf:"bytes,1,rep,name=paths,proto3" json:"paths,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *ListDirectoriesResponse) Reset() { *m = ListDirectoriesResponse{} } -func (m *ListDirectoriesResponse) String() string { return proto.CompactTextString(m) } -func (*ListDirectoriesResponse) ProtoMessage() {} -func (*ListDirectoriesResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_0d2c4ccf1453ffdb, []int{1} -} - -func (m *ListDirectoriesResponse) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_ListDirectoriesResponse.Unmarshal(m, b) -} -func (m *ListDirectoriesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_ListDirectoriesResponse.Marshal(b, m, deterministic) -} -func (m *ListDirectoriesResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_ListDirectoriesResponse.Merge(m, src) -} -func (m *ListDirectoriesResponse) XXX_Size() int { - return xxx_messageInfo_ListDirectoriesResponse.Size(m) -} -func (m *ListDirectoriesResponse) XXX_DiscardUnknown() { - xxx_messageInfo_ListDirectoriesResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_ListDirectoriesResponse proto.InternalMessageInfo - -func (m *ListDirectoriesResponse) GetPaths() []string { - if m != nil { - return m.Paths - } - return nil -} - -type DeleteAllRepositoriesRequest struct { - StorageName string `protobuf:"bytes,1,opt,name=storage_name,json=storageName,proto3" json:"storage_name,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *DeleteAllRepositoriesRequest) Reset() { *m = DeleteAllRepositoriesRequest{} } -func (m *DeleteAllRepositoriesRequest) String() string { return proto.CompactTextString(m) } -func (*DeleteAllRepositoriesRequest) ProtoMessage() {} -func (*DeleteAllRepositoriesRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_0d2c4ccf1453ffdb, []int{2} -} - -func (m *DeleteAllRepositoriesRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_DeleteAllRepositoriesRequest.Unmarshal(m, b) -} -func (m *DeleteAllRepositoriesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_DeleteAllRepositoriesRequest.Marshal(b, m, deterministic) -} -func (m *DeleteAllRepositoriesRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_DeleteAllRepositoriesRequest.Merge(m, src) -} -func (m *DeleteAllRepositoriesRequest) XXX_Size() int { - return xxx_messageInfo_DeleteAllRepositoriesRequest.Size(m) -} -func (m *DeleteAllRepositoriesRequest) XXX_DiscardUnknown() { - xxx_messageInfo_DeleteAllRepositoriesRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_DeleteAllRepositoriesRequest proto.InternalMessageInfo - -func (m *DeleteAllRepositoriesRequest) GetStorageName() string { - if m != nil { - return m.StorageName - } - return "" -} - -type DeleteAllRepositoriesResponse struct { - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *DeleteAllRepositoriesResponse) Reset() { *m = DeleteAllRepositoriesResponse{} } -func (m *DeleteAllRepositoriesResponse) String() string { return proto.CompactTextString(m) } -func (*DeleteAllRepositoriesResponse) ProtoMessage() {} -func (*DeleteAllRepositoriesResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_0d2c4ccf1453ffdb, []int{3} -} - -func (m *DeleteAllRepositoriesResponse) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_DeleteAllRepositoriesResponse.Unmarshal(m, b) -} -func (m *DeleteAllRepositoriesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_DeleteAllRepositoriesResponse.Marshal(b, m, deterministic) -} -func (m *DeleteAllRepositoriesResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_DeleteAllRepositoriesResponse.Merge(m, src) -} -func (m *DeleteAllRepositoriesResponse) XXX_Size() int { - return xxx_messageInfo_DeleteAllRepositoriesResponse.Size(m) -} -func (m *DeleteAllRepositoriesResponse) XXX_DiscardUnknown() { - xxx_messageInfo_DeleteAllRepositoriesResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_DeleteAllRepositoriesResponse proto.InternalMessageInfo - -func init() { - proto.RegisterType((*ListDirectoriesRequest)(nil), "gitaly.ListDirectoriesRequest") - proto.RegisterType((*ListDirectoriesResponse)(nil), "gitaly.ListDirectoriesResponse") - proto.RegisterType((*DeleteAllRepositoriesRequest)(nil), "gitaly.DeleteAllRepositoriesRequest") - proto.RegisterType((*DeleteAllRepositoriesResponse)(nil), "gitaly.DeleteAllRepositoriesResponse") -} - -func init() { proto.RegisterFile("storage.proto", fileDescriptor_0d2c4ccf1453ffdb) } - -var fileDescriptor_0d2c4ccf1453ffdb = []byte{ - // 287 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x51, 0xdd, 0x4a, 0xc3, 0x30, - 0x14, 0x26, 0x55, 0xc7, 0x76, 0xdc, 0x74, 0x04, 0x7f, 0x46, 0x51, 0x57, 0x8b, 0x42, 0x6f, 0x6c, - 0x87, 0x3e, 0xc1, 0x64, 0x97, 0x22, 0xd8, 0xdd, 0x79, 0xa1, 0xa4, 0xdd, 0xa1, 0x0d, 0xa4, 0x4d, - 0x4c, 0xa2, 0xe0, 0x93, 0xf8, 0x7a, 0x3e, 0x87, 0x57, 0x62, 0x53, 0x2f, 0xd4, 0x4d, 0xf1, 0x2e, - 0xdf, 0x97, 0x7c, 0x3f, 0x39, 0x07, 0x06, 0xc6, 0x4a, 0xcd, 0x0a, 0x8c, 0x95, 0x96, 0x56, 0xd2, - 0x4e, 0xc1, 0x2d, 0x13, 0xcf, 0x7e, 0xdf, 0x94, 0x4c, 0xe3, 0xc2, 0xb1, 0xe1, 0x0d, 0xec, 0x5d, - 0x71, 0x63, 0x67, 0x5c, 0x63, 0x6e, 0xa5, 0xe6, 0x68, 0x52, 0x7c, 0x78, 0x44, 0x63, 0xe9, 0x31, - 0xf4, 0x5b, 0x83, 0xfb, 0x9a, 0x55, 0x38, 0x22, 0x01, 0x89, 0x7a, 0xe9, 0x66, 0xcb, 0x5d, 0xb3, - 0x0a, 0xe9, 0x0e, 0x6c, 0x2c, 0x50, 0xd9, 0x72, 0xe4, 0x05, 0x24, 0x1a, 0xa4, 0x0e, 0x84, 0x09, - 0xec, 0xff, 0xb0, 0x34, 0x4a, 0xd6, 0xa6, 0x11, 0x28, 0x66, 0x4b, 0x33, 0x22, 0xc1, 0x5a, 0xd4, - 0x4b, 0x1d, 0x08, 0xa7, 0x70, 0x30, 0x43, 0x81, 0x16, 0xa7, 0x42, 0xa4, 0xa8, 0xa4, 0xe1, 0xff, - 0x6d, 0x12, 0x8e, 0xe1, 0x70, 0x85, 0x85, 0x4b, 0x3e, 0x7f, 0x25, 0xb0, 0x35, 0x77, 0x82, 0x39, - 0xea, 0x27, 0x9e, 0x23, 0xbd, 0x83, 0xed, 0x6f, 0x3d, 0xe9, 0x51, 0xec, 0x86, 0x14, 0x2f, 0x9f, - 0x89, 0x3f, 0x5e, 0x79, 0xef, 0x62, 0xc2, 0xee, 0xdb, 0x4b, 0xb4, 0xde, 0xf5, 0x86, 0xde, 0x84, - 0xd0, 0x1a, 0x76, 0x97, 0x76, 0xa2, 0x27, 0x9f, 0x2e, 0xbf, 0xfd, 0xda, 0x3f, 0xfd, 0xe3, 0xd5, - 0x97, 0x44, 0x32, 0xf4, 0x2e, 0x27, 0xb7, 0x1f, 0x0a, 0xc1, 0xb2, 0x38, 0x97, 0x55, 0xe2, 0x8e, - 0x67, 0x52, 0x17, 0x89, 0xf3, 0x49, 0x9a, 0x85, 0x27, 0x85, 0x6c, 0xb1, 0xca, 0xb2, 0x4e, 0x43, - 0x5d, 0xbc, 0x07, 0x00, 0x00, 0xff, 0xff, 0x66, 0xad, 0x6a, 0x34, 0x2a, 0x02, 0x00, 0x00, -} - -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion4 - -// StorageServiceClient is the client API for StorageService service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type StorageServiceClient interface { - ListDirectories(ctx context.Context, in *ListDirectoriesRequest, opts ...grpc.CallOption) (StorageService_ListDirectoriesClient, error) - DeleteAllRepositories(ctx context.Context, in *DeleteAllRepositoriesRequest, opts ...grpc.CallOption) (*DeleteAllRepositoriesResponse, error) -} - -type storageServiceClient struct { - cc *grpc.ClientConn -} - -func NewStorageServiceClient(cc *grpc.ClientConn) StorageServiceClient { - return &storageServiceClient{cc} -} - -func (c *storageServiceClient) ListDirectories(ctx context.Context, in *ListDirectoriesRequest, opts ...grpc.CallOption) (StorageService_ListDirectoriesClient, error) { - stream, err := c.cc.NewStream(ctx, &_StorageService_serviceDesc.Streams[0], "/gitaly.StorageService/ListDirectories", opts...) - if err != nil { - return nil, err - } - x := &storageServiceListDirectoriesClient{stream} - if err := x.ClientStream.SendMsg(in); err != nil { - return nil, err - } - if err := x.ClientStream.CloseSend(); err != nil { - return nil, err - } - return x, nil -} - -type StorageService_ListDirectoriesClient interface { - Recv() (*ListDirectoriesResponse, error) - grpc.ClientStream -} - -type storageServiceListDirectoriesClient struct { - grpc.ClientStream -} - -func (x *storageServiceListDirectoriesClient) Recv() (*ListDirectoriesResponse, error) { - m := new(ListDirectoriesResponse) - if err := x.ClientStream.RecvMsg(m); err != nil { - return nil, err - } - return m, nil -} - -func (c *storageServiceClient) DeleteAllRepositories(ctx context.Context, in *DeleteAllRepositoriesRequest, opts ...grpc.CallOption) (*DeleteAllRepositoriesResponse, error) { - out := new(DeleteAllRepositoriesResponse) - err := c.cc.Invoke(ctx, "/gitaly.StorageService/DeleteAllRepositories", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// StorageServiceServer is the server API for StorageService service. -type StorageServiceServer interface { - ListDirectories(*ListDirectoriesRequest, StorageService_ListDirectoriesServer) error - DeleteAllRepositories(context.Context, *DeleteAllRepositoriesRequest) (*DeleteAllRepositoriesResponse, error) -} - -// UnimplementedStorageServiceServer can be embedded to have forward compatible implementations. -type UnimplementedStorageServiceServer struct { -} - -func (*UnimplementedStorageServiceServer) ListDirectories(req *ListDirectoriesRequest, srv StorageService_ListDirectoriesServer) error { - return status.Errorf(codes.Unimplemented, "method ListDirectories not implemented") -} -func (*UnimplementedStorageServiceServer) DeleteAllRepositories(ctx context.Context, req *DeleteAllRepositoriesRequest) (*DeleteAllRepositoriesResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method DeleteAllRepositories not implemented") -} - -func RegisterStorageServiceServer(s *grpc.Server, srv StorageServiceServer) { - s.RegisterService(&_StorageService_serviceDesc, srv) -} - -func _StorageService_ListDirectories_Handler(srv interface{}, stream grpc.ServerStream) error { - m := new(ListDirectoriesRequest) - if err := stream.RecvMsg(m); err != nil { - return err - } - return srv.(StorageServiceServer).ListDirectories(m, &storageServiceListDirectoriesServer{stream}) -} - -type StorageService_ListDirectoriesServer interface { - Send(*ListDirectoriesResponse) error - grpc.ServerStream -} - -type storageServiceListDirectoriesServer struct { - grpc.ServerStream -} - -func (x *storageServiceListDirectoriesServer) Send(m *ListDirectoriesResponse) error { - return x.ServerStream.SendMsg(m) -} - -func _StorageService_DeleteAllRepositories_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(DeleteAllRepositoriesRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(StorageServiceServer).DeleteAllRepositories(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/gitaly.StorageService/DeleteAllRepositories", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(StorageServiceServer).DeleteAllRepositories(ctx, req.(*DeleteAllRepositoriesRequest)) - } - return interceptor(ctx, in, info, handler) -} - -var _StorageService_serviceDesc = grpc.ServiceDesc{ - ServiceName: "gitaly.StorageService", - HandlerType: (*StorageServiceServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "DeleteAllRepositories", - Handler: _StorageService_DeleteAllRepositories_Handler, - }, - }, - Streams: []grpc.StreamDesc{ - { - StreamName: "ListDirectories", - Handler: _StorageService_ListDirectories_Handler, - ServerStreams: true, - }, - }, - Metadata: "storage.proto", -} diff --git a/proto/storage.proto b/proto/storage.proto deleted file mode 100644 index 74d753267..000000000 --- a/proto/storage.proto +++ /dev/null @@ -1,37 +0,0 @@ -syntax = "proto3"; - -package gitaly; - -option go_package = "gitlab.com/gitlab-org/gitaly/proto/go/gitalypb"; - -import "shared.proto"; - -service StorageService { - rpc ListDirectories(ListDirectoriesRequest) returns (stream ListDirectoriesResponse) { - option (op_type) = { - op: ACCESSOR, - scope_level: STORAGE, - }; - } - rpc DeleteAllRepositories(DeleteAllRepositoriesRequest) returns (DeleteAllRepositoriesResponse) { - option (op_type) = { - op: MUTATOR, - scope_level: STORAGE, - }; - } -} - -message ListDirectoriesRequest { - string storage_name = 1; - uint32 depth = 2; -} - -message ListDirectoriesResponse { - repeated string paths = 1; -} - -message DeleteAllRepositoriesRequest { - string storage_name = 1; -} - -message DeleteAllRepositoriesResponse {} diff --git a/ruby/proto/gitaly.rb b/ruby/proto/gitaly.rb index c35bc6e06..6347a6fbe 100644 --- a/ruby/proto/gitaly.rb +++ b/ruby/proto/gitaly.rb @@ -31,7 +31,5 @@ require 'gitaly/smarthttp_services_pb' require 'gitaly/ssh_services_pb' -require 'gitaly/storage_services_pb' - require 'gitaly/wiki_services_pb' diff --git a/ruby/proto/gitaly/storage_pb.rb b/ruby/proto/gitaly/storage_pb.rb deleted file mode 100644 index 22972ab58..000000000 --- a/ruby/proto/gitaly/storage_pb.rb +++ /dev/null @@ -1,27 +0,0 @@ -# Generated by the protocol buffer compiler. DO NOT EDIT! -# source: storage.proto - -require 'google/protobuf' - -require 'shared_pb' -Google::Protobuf::DescriptorPool.generated_pool.build do - add_message "gitaly.ListDirectoriesRequest" do - optional :storage_name, :string, 1 - optional :depth, :uint32, 2 - end - add_message "gitaly.ListDirectoriesResponse" do - repeated :paths, :string, 1 - end - add_message "gitaly.DeleteAllRepositoriesRequest" do - optional :storage_name, :string, 1 - end - add_message "gitaly.DeleteAllRepositoriesResponse" do - end -end - -module Gitaly - ListDirectoriesRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("gitaly.ListDirectoriesRequest").msgclass - ListDirectoriesResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("gitaly.ListDirectoriesResponse").msgclass - DeleteAllRepositoriesRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup("gitaly.DeleteAllRepositoriesRequest").msgclass - DeleteAllRepositoriesResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup("gitaly.DeleteAllRepositoriesResponse").msgclass -end diff --git a/ruby/proto/gitaly/storage_services_pb.rb b/ruby/proto/gitaly/storage_services_pb.rb deleted file mode 100644 index e799263c6..000000000 --- a/ruby/proto/gitaly/storage_services_pb.rb +++ /dev/null @@ -1,23 +0,0 @@ -# Generated by the protocol buffer compiler. DO NOT EDIT! -# Source: storage.proto for package 'gitaly' - -require 'grpc' -require 'storage_pb' - -module Gitaly - module StorageService - class Service - - include GRPC::GenericService - - self.marshal_class_method = :encode - self.unmarshal_class_method = :decode - self.service_name = 'gitaly.StorageService' - - rpc :ListDirectories, ListDirectoriesRequest, stream(ListDirectoriesResponse) - rpc :DeleteAllRepositories, DeleteAllRepositoriesRequest, DeleteAllRepositoriesResponse - end - - Stub = Service.rpc_stub_class - end -end |