diff --git a/Makefile b/Makefile index 684f4c425..e469721f0 100644 --- a/Makefile +++ b/Makefile @@ -35,7 +35,7 @@ tools: $(tools) ## Install tools required for the build mocks: $(mocks) @echo "Generating Test Mocks" -wire: cli/server/harness.wire.go cli/server/standalone.wire.go +wire: cli/server/harness.wire_gen.go cli/server/standalone.wire_gen.go generate: $(mocks) wire mocks/mock_client.go proto @echo "Generating Code" diff --git a/cli/server/harness.wire.go b/cli/server/harness.wire.go index 435321f25..c138de5f0 100644 --- a/cli/server/harness.wire.go +++ b/cli/server/harness.wire.go @@ -21,6 +21,7 @@ import ( "github.com/harness/gitness/internal/api/controller/space" "github.com/harness/gitness/internal/api/controller/user" "github.com/harness/gitness/internal/cron" + "github.com/harness/gitness/internal/gitrpc" "github.com/harness/gitness/internal/server" "github.com/harness/gitness/internal/store/database" "github.com/harness/gitness/internal/store/memory" @@ -41,6 +42,7 @@ func initSystem(ctx context.Context, config *gitnessTypes.Config) (*system, erro space.WireSet, user.WireSet, service.WireSet, + gitrpc.WireSet, types.LoadConfig, router.WireSet, authn.WireSet, diff --git a/cli/server/harness.wire_gen.go b/cli/server/harness.wire_gen.go index b4dcae56a..14870e6cc 100644 --- a/cli/server/harness.wire_gen.go +++ b/cli/server/harness.wire_gen.go @@ -19,6 +19,7 @@ import ( "github.com/harness/gitness/internal/api/controller/space" "github.com/harness/gitness/internal/api/controller/user" "github.com/harness/gitness/internal/cron" + "github.com/harness/gitness/internal/gitrpc" router2 "github.com/harness/gitness/internal/router" "github.com/harness/gitness/internal/server" "github.com/harness/gitness/internal/store/database" @@ -77,7 +78,11 @@ func initSystem(ctx context.Context, config *types.Config) (*system, error) { spaceStore := database.ProvideSpaceStore(db) repoStore := database.ProvideRepoStore(db) spaceController := space.NewController(authorizer, spaceStore, repoStore, serviceAccountStore) - repoController := repo.NewController(authorizer, spaceStore, repoStore, serviceAccountStore) + gitrpcInterface, err := gitrpc.ProvideClient() + if err != nil { + return nil, err + } + repoController := repo.NewController(authorizer, spaceStore, repoStore, serviceAccountStore, gitrpcInterface) apiHandler := router.ProvideAPIHandler(systemStore, authenticator, accountClient, spaceController, repoController) gitHandler := router2.ProvideGitHandler(repoStore, authenticator) webHandler := router2.ProvideWebHandler(systemStore) diff --git a/cli/server/standalone.wire_gen.go b/cli/server/standalone.wire_gen.go index 4793a6b27..8d0000ea0 100644 --- a/cli/server/standalone.wire_gen.go +++ b/cli/server/standalone.wire_gen.go @@ -1,8 +1,7 @@ // Code generated by Wire. DO NOT EDIT. -//go:generate go run github.com/google/wire/cmd/wire -//go:build !wireinject -// +build !wireinject +//go:build !wireinject && !harness +// +build !wireinject,!harness package server diff --git a/cli/session/session.go b/cli/session/session.go index 07e2a5dfa..747a1b2f3 100644 --- a/cli/session/session.go +++ b/cli/session/session.go @@ -1,3 +1,7 @@ +// Copyright 2022 Harness Inc. All rights reserved. +// Use of this source code is governed by the Polyform Free Trial License +// that can be found in the LICENSE.md file for this repository. + package session type Session struct { diff --git a/internal/api/controller/repo/create.go b/internal/api/controller/repo/create.go index e97e7efc3..3f64b5cc0 100644 --- a/internal/api/controller/repo/create.go +++ b/internal/api/controller/repo/create.go @@ -33,11 +33,12 @@ type CreateInput struct { IsPublic bool `json:"isPublic"` ForkID int64 `json:"forkId"` Readme bool `json:"readme"` - Licence string `json:"licence"` + License string `json:"license"` GitIgnore string `json:"gitIgnore"` } // Create creates a new repository. +//nolint:funlen,goimports // needs refactor func (c *Controller) Create(ctx context.Context, session *auth.Session, in *CreateInput) (*types.Repository, error) { log := zerolog.Ctx(ctx) // ensure we reference a space @@ -93,19 +94,21 @@ func (c *Controller) Create(ctx context.Context, session *auth.Session, in *Crea }) } - if in.Licence != "" && in.Licence != "none" { - content, err = resources.Licence.ReadFile(fmt.Sprintf("licence/%s.txt", in.Licence)) + if in.License != "" && in.License != "none" { + // TODO: The caller shouldn't need to know the actual location. + content, err = resources.Licence.ReadFile(fmt.Sprintf("license/%s.txt", in.License)) if err != nil { return nil, err } files = append(files, gitrpc.File{ - Name: "LICENCE", + Name: "LICENSE", Base64: false, Content: content, }) } if in.GitIgnore != "" { + // TODO: The caller shouldn't need to know the actual location. content, err = resources.Gitignore.ReadFile(fmt.Sprintf("gitignore/%s.gitignore", in.GitIgnore)) if err != nil { return nil, err @@ -120,8 +123,9 @@ func (c *Controller) Create(ctx context.Context, session *auth.Session, in *Crea err = c.rpcClient.CreateRepository(ctx, &gitrpc.CreateRepositoryParams{ RepositoryParams: gitrpc.RepositoryParams{ Username: session.Principal.Name, - Name: repo.Name, - Branch: in.Branch, + // TODO: use UID as name + Name: repo.PathName, + Branch: in.Branch, }, Files: files, }) diff --git a/internal/api/handler/repo/resource.go b/internal/api/handler/repo/resource.go index 5fd86330d..31ca2aff5 100644 --- a/internal/api/handler/repo/resource.go +++ b/internal/api/handler/repo/resource.go @@ -1,3 +1,7 @@ +// Copyright 2022 Harness Inc. All rights reserved. +// Use of this source code is governed by the Polyform Free Trial License +// that can be found in the LICENSE.md file for this repository. + package repo import ( diff --git a/internal/api/middleware/encode/encode.go b/internal/api/middleware/encode/encode.go index 161a54410..67a7420f0 100644 --- a/internal/api/middleware/encode/encode.go +++ b/internal/api/middleware/encode/encode.go @@ -1,3 +1,7 @@ +// Copyright 2022 Harness Inc. All rights reserved. +// Use of this source code is governed by the Polyform Free Trial License +// that can be found in the LICENSE.md file for this repository. + package encode import ( diff --git a/internal/api/render/platform/render.go b/internal/api/render/platform/render.go index 4373837aa..47c6d336a 100644 --- a/internal/api/render/platform/render.go +++ b/internal/api/render/platform/render.go @@ -1,3 +1,7 @@ +// Copyright 2022 Harness Inc. All rights reserved. +// Use of this source code is governed by the Polyform Free Trial License +// that can be found in the LICENSE.md file for this repository. + package platform import ( diff --git a/internal/api/request/path.go b/internal/api/request/path.go index fd7dbc103..9cf5bcd98 100644 --- a/internal/api/request/path.go +++ b/internal/api/request/path.go @@ -1,3 +1,7 @@ +// Copyright 2022 Harness Inc. All rights reserved. +// Use of this source code is governed by the Polyform Free Trial License +// that can be found in the LICENSE.md file for this repository. + package request import ( diff --git a/internal/api/request/principal.go b/internal/api/request/principal.go index a6eed8beb..5bbc01376 100644 --- a/internal/api/request/principal.go +++ b/internal/api/request/principal.go @@ -1,3 +1,7 @@ +// Copyright 2022 Harness Inc. All rights reserved. +// Use of this source code is governed by the Polyform Free Trial License +// that can be found in the LICENSE.md file for this repository. + package request import ( diff --git a/internal/api/request/repo.go b/internal/api/request/repo.go index a6762a43d..de10e78e8 100644 --- a/internal/api/request/repo.go +++ b/internal/api/request/repo.go @@ -1,3 +1,7 @@ +// Copyright 2022 Harness Inc. All rights reserved. +// Use of this source code is governed by the Polyform Free Trial License +// that can be found in the LICENSE.md file for this repository. + package request import ( diff --git a/internal/api/request/space.go b/internal/api/request/space.go index 3e6b3e86d..ffe8ccf60 100644 --- a/internal/api/request/space.go +++ b/internal/api/request/space.go @@ -1,3 +1,7 @@ +// Copyright 2022 Harness Inc. All rights reserved. +// Use of this source code is governed by the Polyform Free Trial License +// that can be found in the LICENSE.md file for this repository. + package request import ( diff --git a/internal/api/request/token.go b/internal/api/request/token.go index 1dca09bc6..00ac98411 100644 --- a/internal/api/request/token.go +++ b/internal/api/request/token.go @@ -1,3 +1,7 @@ +// Copyright 2022 Harness Inc. All rights reserved. +// Use of this source code is governed by the Polyform Free Trial License +// that can be found in the LICENSE.md file for this repository. + package request import ( diff --git a/internal/api/usererror/translate.go b/internal/api/usererror/translate.go index 086dddb26..92166d145 100644 --- a/internal/api/usererror/translate.go +++ b/internal/api/usererror/translate.go @@ -1,3 +1,7 @@ +// Copyright 2022 Harness Inc. All rights reserved. +// Use of this source code is governed by the Polyform Free Trial License +// that can be found in the LICENSE.md file for this repository. + package usererror import ( diff --git a/internal/gitrpc/client.go b/internal/gitrpc/client.go index e4275ad34..6d88b6ab5 100644 --- a/internal/gitrpc/client.go +++ b/internal/gitrpc/client.go @@ -1,3 +1,7 @@ +// Copyright 2022 Harness Inc. All rights reserved. +// Use of this source code is governed by the Polyform Free Trial License +// that can be found in the LICENSE.md file for this repository. + package gitrpc import ( @@ -28,6 +32,7 @@ type File struct { } type RepositoryParams struct { + // TODO: What is it used for? Username string Name string Branch string @@ -147,22 +152,28 @@ func (c *Client) process( stream rpc.RepositoryService_CreateRepositoryClient) error { n, err := reader.Read(buffer) if errors.Is(err, io.EOF) { - log.Info().Msgf("EOF detected at %v", filename) - buffer = []byte{'E', 'O', 'F'} - _ = c.send(buffer, stream) + log.Info().Msgf("EOF reached for %v", filename) + err = c.send(buffer[:n], true, stream) + if err != nil { + return err + } + return io.EOF } if err != nil { return fmt.Errorf("cannot read buffer: %w", err) } - return c.send(buffer[:n], stream) + return c.send(buffer[:n], false, stream) } -func (c *Client) send(buffer []byte, stream rpc.RepositoryService_CreateRepositoryClient) error { +func (c *Client) send(buffer []byte, eof bool, stream rpc.RepositoryService_CreateRepositoryClient) error { req := &rpc.CreateRepositoryRequest{ - Data: &rpc.CreateRepositoryRequest_ChunkData{ - ChunkData: buffer, + Data: &rpc.CreateRepositoryRequest_Chunk{ + Chunk: &rpc.Chunk{ + Eof: eof, + Data: buffer, + }, }, } @@ -214,17 +225,20 @@ func (c *Client) Upload(ctx context.Context, params *UploadParams, reader io.Rea for { var n int + eof := false n, err = reader.Read(buffer) if errors.Is(err, io.EOF) { - break - } - if err != nil { + eof = true + } else if err != nil { return "", fmt.Errorf("cannot read chunk to buffer: %w", err) } req = &rpc.UploadFileRequest{ - Data: &rpc.UploadFileRequest_ChunkData{ - ChunkData: buffer[:n], + Data: &rpc.UploadFileRequest_Chunk{ + Chunk: &rpc.Chunk{ + Eof: eof, + Data: buffer[:n], + }, }, } @@ -233,6 +247,10 @@ func (c *Client) Upload(ctx context.Context, params *UploadParams, reader io.Rea err = stream.RecvMsg(nil) return "", status.Errorf(codes.Internal, "cannot send chunk to server: %v", err) } + + if eof { + break + } } res, err := stream.CloseAndRecv() @@ -240,7 +258,7 @@ func (c *Client) Upload(ctx context.Context, params *UploadParams, reader io.Rea return "", fmt.Errorf("cannot receive response: %w", err) } fullPath := res.GetId() - log.Debug().Msgf("image uploaded with id: %s, size: %d", fullPath, res.GetSize()) + log.Debug().Msgf("file uploaded with id: %s, size: %d", fullPath, res.GetSize()) return fullPath, nil } diff --git a/internal/gitrpc/config.go b/internal/gitrpc/config.go index b2d338abc..780e1bcca 100644 --- a/internal/gitrpc/config.go +++ b/internal/gitrpc/config.go @@ -1,3 +1,7 @@ +// Copyright 2022 Harness Inc. All rights reserved. +// Use of this source code is governed by the Polyform Free Trial License +// that can be found in the LICENSE.md file for this repository. + package gitrpc type Config struct { diff --git a/internal/gitrpc/file.go b/internal/gitrpc/file.go index 5ac06ac66..4acb255ee 100644 --- a/internal/gitrpc/file.go +++ b/internal/gitrpc/file.go @@ -1,3 +1,7 @@ +// Copyright 2022 Harness Inc. All rights reserved. +// Use of this source code is governed by the Polyform Free Trial License +// that can be found in the LICENSE.md file for this repository. + package gitrpc import ( diff --git a/internal/gitrpc/gitea.go b/internal/gitrpc/gitea.go index 6bdfe1073..93796775a 100644 --- a/internal/gitrpc/gitea.go +++ b/internal/gitrpc/gitea.go @@ -1,3 +1,7 @@ +// Copyright 2022 Harness Inc. All rights reserved. +// Use of this source code is governed by the Polyform Free Trial License +// that can be found in the LICENSE.md file for this repository. + package gitrpc import ( diff --git a/internal/gitrpc/interface.go b/internal/gitrpc/interface.go index 085003e78..2f291ed4b 100644 --- a/internal/gitrpc/interface.go +++ b/internal/gitrpc/interface.go @@ -1,3 +1,7 @@ +// Copyright 2022 Harness Inc. All rights reserved. +// Use of this source code is governed by the Polyform Free Trial License +// that can be found in the LICENSE.md file for this repository. + package gitrpc import "context" diff --git a/internal/gitrpc/local.go b/internal/gitrpc/local.go index 306f30e27..16f64c5c0 100644 --- a/internal/gitrpc/local.go +++ b/internal/gitrpc/local.go @@ -1,3 +1,7 @@ +// Copyright 2022 Harness Inc. All rights reserved. +// Use of this source code is governed by the Polyform Free Trial License +// that can be found in the LICENSE.md file for this repository. + package gitrpc import ( @@ -9,13 +13,13 @@ import ( ) type localStore struct { - mutex sync.RWMutex - images map[string]bool + mutex sync.RWMutex + files map[string]bool } func newLocalStore() *localStore { return &localStore{ - images: make(map[string]bool), + files: make(map[string]bool), } } @@ -38,7 +42,7 @@ func (store *localStore) Save(filePath string, data bytes.Buffer) (string, error store.mutex.Lock() defer store.mutex.Unlock() - store.images[filePath] = true + store.files[filePath] = true return filePath, nil } diff --git a/internal/gitrpc/lock/example/main.go b/internal/gitrpc/lock/example/main.go index e029b5389..4af1dd591 100644 --- a/internal/gitrpc/lock/example/main.go +++ b/internal/gitrpc/lock/example/main.go @@ -1,3 +1,7 @@ +// Copyright 2022 Harness Inc. All rights reserved. +// Use of this source code is governed by the Polyform Free Trial License +// that can be found in the LICENSE.md file for this repository. + package main import ( diff --git a/internal/gitrpc/lock/interface.go b/internal/gitrpc/lock/interface.go index 54d49079b..a340ae635 100644 --- a/internal/gitrpc/lock/interface.go +++ b/internal/gitrpc/lock/interface.go @@ -1,3 +1,7 @@ +// Copyright 2022 Harness Inc. All rights reserved. +// Use of this source code is governed by the Polyform Free Trial License +// that can be found in the LICENSE.md file for this repository. + package lock import "context" diff --git a/internal/gitrpc/lock/mutex.go b/internal/gitrpc/lock/mutex.go index 9a6cf7eaa..aaf89642d 100644 --- a/internal/gitrpc/lock/mutex.go +++ b/internal/gitrpc/lock/mutex.go @@ -1,3 +1,7 @@ +// Copyright 2022 Harness Inc. All rights reserved. +// Use of this source code is governed by the Polyform Free Trial License +// that can be found in the LICENSE.md file for this repository. + package lock import ( @@ -33,6 +37,7 @@ func (c *Mutex) AcquireLock(ctx context.Context, key string) (*Lock, error) { lockChan: make(chan struct{}, 1), } } + // TODO: One acquire having to wait causes all to wait? select { case lock.lockChan <- struct{}{}: lock.state = true diff --git a/internal/gitrpc/lock/mutex_test.go b/internal/gitrpc/lock/mutex_test.go index 65b3209d2..45013d8cd 100644 --- a/internal/gitrpc/lock/mutex_test.go +++ b/internal/gitrpc/lock/mutex_test.go @@ -1,3 +1,7 @@ +// Copyright 2022 Harness Inc. All rights reserved. +// Use of this source code is governed by the Polyform Free Trial License +// that can be found in the LICENSE.md file for this repository. + package lock import ( diff --git a/internal/gitrpc/proto/repo.proto b/internal/gitrpc/proto/repo.proto index a714c3a30..d20436812 100644 --- a/internal/gitrpc/proto/repo.proto +++ b/internal/gitrpc/proto/repo.proto @@ -19,7 +19,7 @@ message CreateRepositoryRequest { oneof data { Repository repository = 1; string filepath = 2; - bytes chunk_data = 3; + Chunk chunk = 3; } } @@ -30,7 +30,7 @@ message CreateRepositoryResponse { message UploadFileRequest { oneof data { FileInfo info = 1; - bytes chunk_data = 2; + Chunk chunk = 2; }; } @@ -61,4 +61,9 @@ message Repository { string owner = 1; string name = 2; string default_branch = 3; +} + +message Chunk { + bool eof = 1; + bytes data = 2; } \ No newline at end of file diff --git a/internal/gitrpc/repo.go b/internal/gitrpc/repoService.go similarity index 75% rename from internal/gitrpc/repo.go rename to internal/gitrpc/repoService.go index e80d930da..56c36d344 100644 --- a/internal/gitrpc/repo.go +++ b/internal/gitrpc/repoService.go @@ -1,3 +1,7 @@ +// Copyright 2022 Harness Inc. All rights reserved. +// Use of this source code is governed by the Polyform Free Trial License +// that can be found in the LICENSE.md file for this repository. + package gitrpc import ( @@ -36,7 +40,7 @@ func (s repositoryService) CreateRepository(stream rpc.RepositoryService_CreateR log.Info().Msgf("receive an create repository request %v", repo) targetPath := filepath.Join(repoRoot, repo.Name) if _, err = os.Stat(targetPath); !os.IsNotExist(err) { - return fmt.Errorf("repository exists already: %v", targetPath) + return status.Errorf(codes.AlreadyExists, "repository exists already: %v", targetPath) } // create repository in repos folder @@ -69,7 +73,7 @@ func (s repositoryService) CreateRepository(stream rpc.RepositoryService_CreateR // logic for receiving the files files := make([]string, 0, 16) for { - log.Info().Msg("waiting to receive filepath data") + log.Info().Msg("waiting to receive file path") req, err = stream.Recv() if errors.Is(err, io.EOF) { log.Info().Msg("EOF found") @@ -82,30 +86,32 @@ func (s repositoryService) CreateRepository(stream rpc.RepositoryService_CreateR fileData := bytes.Buffer{} fileSize := 0 for { - log.Info().Msg("waiting to receive more data") + log.Debug().Msg("waiting to receive data") req, err = stream.Recv() if errors.Is(err, io.EOF) { - log.Print("no more data") + return status.Errorf(codes.Internal, "received unexpected end of stream: %v", err) + } + + chunk := req.GetChunk() + size := len(chunk.Data) + + if size > 0 { + log.Debug().Msgf("received a chunk with size: %d", size) + fileSize += size + if fileSize > maxFileSize { + return status.Errorf(codes.InvalidArgument, "file is too large: %d > %d", fileSize, maxFileSize) + } + _, err = fileData.Write(chunk.Data) + if err != nil { + return status.Errorf(codes.Internal, "cannot write chunk data: %v", err) + } + } + + if chunk.Eof { + log.Info().Msg("Received file EOF") break } - - chunk := req.GetChunkData() - size := len(chunk) - - if len("EOF") == size && chunk[0] == 'E' && chunk[1] == 'O' && chunk[2] == 'F' { - break - } - - log.Printf("received a chunk with size: %d", size) - fileSize += size - if fileSize > maxImageSize { - return status.Errorf(codes.InvalidArgument, "file is too large: %d > %d", fileSize, maxImageSize) - } - _, err = fileData.Write(chunk) - if err != nil { - return status.Errorf(codes.Internal, "cannot write chunk data: %v", err) - } } log.Info().Msgf("saving file %s in repo path %s", filePath, tempDir) fullPath := filepath.Join(tempDir, filePath) @@ -121,7 +127,7 @@ func (s repositoryService) CreateRepository(stream rpc.RepositoryService_CreateR if len(files) > 0 { if _, err = s.AddFilesAndPush(ctx, &rpc.AddFilesAndPushRequest{ - RepoPath: res.GetTempPath(), + RepoPath: tempDir, Message: "initial commit", Files: files, }); err != nil { @@ -131,10 +137,10 @@ func (s repositoryService) CreateRepository(stream rpc.RepositoryService_CreateR err = stream.SendAndClose(res) if err != nil { - return status.Errorf(codes.Unknown, "cannot send response: %v", err) + return status.Errorf(codes.Unknown, "cannot send completion response: %v", err) } - log.Info().Msgf("repository created: %s, path: %s", repo.Name, res.GetTempPath()) + log.Info().Msgf("repository created: %s, path: %s", repo.Name, targetPath) return nil } @@ -148,11 +154,13 @@ func (s repositoryService) AddFilesAndPush( } now := time.Now() err = s.adapter.Commit(params.GetRepoPath(), commitChangesOptions{ + // TODO: Add gitness signature committer: &signature{ name: "enver", email: "enver.bisevac@harness.io", when: now, }, + // TODO: Add gitness signature author: &signature{ name: "enver", email: "enver.bisevac@harness.io", @@ -164,6 +172,7 @@ func (s repositoryService) AddFilesAndPush( return nil, err } err = s.adapter.Push(ctx, params.GetRepoPath(), pushOptions{ + // TODO: Don't hard-code remote: "origin", branch: "", force: false, @@ -174,6 +183,7 @@ func (s repositoryService) AddFilesAndPush( if err != nil { return nil, err } + // TODO: caller should delete repo if needed (as we didn't create it here) err = os.RemoveAll(params.GetRepoPath()) if err != nil { return nil, err diff --git a/internal/gitrpc/rpc/repo.pb.go b/internal/gitrpc/rpc/repo.pb.go index e6ffc827a..a9d3f66e3 100644 --- a/internal/gitrpc/rpc/repo.pb.go +++ b/internal/gitrpc/rpc/repo.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.7 +// protoc-gen-go v1.27.1 +// protoc v3.19.4 // source: repo.proto package rpc @@ -28,7 +28,7 @@ type CreateRepositoryRequest struct { // Types that are assignable to Data: // *CreateRepositoryRequest_Repository // *CreateRepositoryRequest_Filepath - // *CreateRepositoryRequest_ChunkData + // *CreateRepositoryRequest_Chunk Data isCreateRepositoryRequest_Data `protobuf_oneof:"data"` } @@ -85,9 +85,9 @@ func (x *CreateRepositoryRequest) GetFilepath() string { return "" } -func (x *CreateRepositoryRequest) GetChunkData() []byte { - if x, ok := x.GetData().(*CreateRepositoryRequest_ChunkData); ok { - return x.ChunkData +func (x *CreateRepositoryRequest) GetChunk() *Chunk { + if x, ok := x.GetData().(*CreateRepositoryRequest_Chunk); ok { + return x.Chunk } return nil } @@ -104,15 +104,15 @@ type CreateRepositoryRequest_Filepath struct { Filepath string `protobuf:"bytes,2,opt,name=filepath,proto3,oneof"` } -type CreateRepositoryRequest_ChunkData struct { - ChunkData []byte `protobuf:"bytes,3,opt,name=chunk_data,json=chunkData,proto3,oneof"` +type CreateRepositoryRequest_Chunk struct { + Chunk *Chunk `protobuf:"bytes,3,opt,name=chunk,proto3,oneof"` } func (*CreateRepositoryRequest_Repository) isCreateRepositoryRequest_Data() {} func (*CreateRepositoryRequest_Filepath) isCreateRepositoryRequest_Data() {} -func (*CreateRepositoryRequest_ChunkData) isCreateRepositoryRequest_Data() {} +func (*CreateRepositoryRequest_Chunk) isCreateRepositoryRequest_Data() {} type CreateRepositoryResponse struct { state protoimpl.MessageState @@ -168,7 +168,7 @@ type UploadFileRequest struct { // Types that are assignable to Data: // *UploadFileRequest_Info - // *UploadFileRequest_ChunkData + // *UploadFileRequest_Chunk Data isUploadFileRequest_Data `protobuf_oneof:"data"` } @@ -218,9 +218,9 @@ func (x *UploadFileRequest) GetInfo() *FileInfo { return nil } -func (x *UploadFileRequest) GetChunkData() []byte { - if x, ok := x.GetData().(*UploadFileRequest_ChunkData); ok { - return x.ChunkData +func (x *UploadFileRequest) GetChunk() *Chunk { + if x, ok := x.GetData().(*UploadFileRequest_Chunk); ok { + return x.Chunk } return nil } @@ -233,13 +233,13 @@ type UploadFileRequest_Info struct { Info *FileInfo `protobuf:"bytes,1,opt,name=info,proto3,oneof"` } -type UploadFileRequest_ChunkData struct { - ChunkData []byte `protobuf:"bytes,2,opt,name=chunk_data,json=chunkData,proto3,oneof"` +type UploadFileRequest_Chunk struct { + Chunk *Chunk `protobuf:"bytes,2,opt,name=chunk,proto3,oneof"` } func (*UploadFileRequest_Info) isUploadFileRequest_Data() {} -func (*UploadFileRequest_ChunkData) isUploadFileRequest_Data() {} +func (*UploadFileRequest_Chunk) isUploadFileRequest_Data() {} type UploadFileResponse struct { state protoimpl.MessageState @@ -555,79 +555,137 @@ func (x *Repository) GetDefaultBranch() string { return "" } +type Chunk struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Eof bool `protobuf:"varint,1,opt,name=eof,proto3" json:"eof,omitempty"` + Data []byte `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` +} + +func (x *Chunk) Reset() { + *x = Chunk{} + if protoimpl.UnsafeEnabled { + mi := &file_repo_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Chunk) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Chunk) ProtoMessage() {} + +func (x *Chunk) ProtoReflect() protoreflect.Message { + mi := &file_repo_proto_msgTypes[8] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Chunk.ProtoReflect.Descriptor instead. +func (*Chunk) Descriptor() ([]byte, []int) { + return file_repo_proto_rawDescGZIP(), []int{8} +} + +func (x *Chunk) GetEof() bool { + if x != nil { + return x.Eof + } + return false +} + +func (x *Chunk) GetData() []byte { + if x != nil { + return x.Data + } + return nil +} + var File_repo_proto protoreflect.FileDescriptor var file_repo_proto_rawDesc = []byte{ 0x0a, 0x0a, 0x72, 0x65, 0x70, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x03, 0x72, 0x70, 0x63, 0x1a, 0x0c, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, - 0x93, 0x01, 0x0a, 0x17, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, + 0x96, 0x01, 0x0a, 0x17, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x31, 0x0a, 0x0a, 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x48, 0x00, 0x52, 0x0a, 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x12, 0x1c, 0x0a, 0x08, 0x66, 0x69, 0x6c, 0x65, 0x70, 0x61, 0x74, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, - 0x48, 0x00, 0x52, 0x08, 0x66, 0x69, 0x6c, 0x65, 0x70, 0x61, 0x74, 0x68, 0x12, 0x1f, 0x0a, 0x0a, - 0x63, 0x68, 0x75, 0x6e, 0x6b, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, - 0x48, 0x00, 0x52, 0x09, 0x63, 0x68, 0x75, 0x6e, 0x6b, 0x44, 0x61, 0x74, 0x61, 0x42, 0x06, 0x0a, - 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x37, 0x0a, 0x18, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, - 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x74, 0x65, 0x6d, 0x70, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x74, 0x65, 0x6d, 0x70, 0x50, 0x61, 0x74, 0x68, 0x22, 0x61, - 0x0a, 0x11, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x12, 0x23, 0x0a, 0x04, 0x69, 0x6e, 0x66, 0x6f, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x0d, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x46, 0x69, 0x6c, 0x65, 0x49, 0x6e, 0x66, 0x6f, - 0x48, 0x00, 0x52, 0x04, 0x69, 0x6e, 0x66, 0x6f, 0x12, 0x1f, 0x0a, 0x0a, 0x63, 0x68, 0x75, 0x6e, - 0x6b, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x48, 0x00, 0x52, 0x09, - 0x63, 0x68, 0x75, 0x6e, 0x6b, 0x44, 0x61, 0x74, 0x61, 0x42, 0x06, 0x0a, 0x04, 0x64, 0x61, 0x74, - 0x61, 0x22, 0x38, 0x0a, 0x12, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x46, 0x69, 0x6c, 0x65, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x22, 0xb0, 0x01, 0x0a, 0x08, - 0x46, 0x69, 0x6c, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, - 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, - 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x72, 0x65, 0x70, 0x6f, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x04, 0x72, 0x65, 0x70, 0x6f, 0x12, 0x16, 0x0a, 0x06, 0x62, 0x72, 0x61, 0x6e, - 0x63, 0x68, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, - 0x12, 0x1b, 0x0a, 0x09, 0x72, 0x65, 0x70, 0x6f, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x18, 0x05, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x08, 0x72, 0x65, 0x70, 0x6f, 0x50, 0x61, 0x74, 0x68, 0x12, 0x12, 0x0a, - 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, - 0x68, 0x12, 0x1b, 0x0a, 0x09, 0x66, 0x69, 0x6c, 0x65, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x07, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x66, 0x69, 0x6c, 0x65, 0x54, 0x79, 0x70, 0x65, 0x22, 0x65, - 0x0a, 0x16, 0x41, 0x64, 0x64, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x41, 0x6e, 0x64, 0x50, 0x75, 0x73, - 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x72, 0x65, 0x70, 0x6f, - 0x5f, 0x70, 0x61, 0x74, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x72, 0x65, 0x70, - 0x6f, 0x50, 0x61, 0x74, 0x68, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, - 0x14, 0x0a, 0x05, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x05, - 0x66, 0x69, 0x6c, 0x65, 0x73, 0x22, 0x19, 0x0a, 0x17, 0x41, 0x64, 0x64, 0x46, 0x69, 0x6c, 0x65, - 0x73, 0x41, 0x6e, 0x64, 0x50, 0x75, 0x73, 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x22, 0x5d, 0x0a, 0x0a, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x12, 0x14, - 0x0a, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6f, - 0x77, 0x6e, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x25, 0x0a, 0x0e, 0x64, 0x65, 0x66, 0x61, - 0x75, 0x6c, 0x74, 0x5f, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x0d, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x32, - 0xb4, 0x01, 0x0a, 0x11, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x53, 0x65, - 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x51, 0x0a, 0x10, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, - 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x12, 0x1c, 0x2e, 0x72, 0x70, 0x63, 0x2e, - 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x72, - 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x28, 0x01, 0x12, 0x4c, 0x0a, 0x0f, 0x41, 0x64, 0x64, 0x46, - 0x69, 0x6c, 0x65, 0x73, 0x41, 0x6e, 0x64, 0x50, 0x75, 0x73, 0x68, 0x12, 0x1b, 0x2e, 0x72, 0x70, - 0x63, 0x2e, 0x41, 0x64, 0x64, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x41, 0x6e, 0x64, 0x50, 0x75, 0x73, - 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x41, + 0x48, 0x00, 0x52, 0x08, 0x66, 0x69, 0x6c, 0x65, 0x70, 0x61, 0x74, 0x68, 0x12, 0x22, 0x0a, 0x05, + 0x63, 0x68, 0x75, 0x6e, 0x6b, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x72, 0x70, + 0x63, 0x2e, 0x43, 0x68, 0x75, 0x6e, 0x6b, 0x48, 0x00, 0x52, 0x05, 0x63, 0x68, 0x75, 0x6e, 0x6b, + 0x42, 0x06, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x37, 0x0a, 0x18, 0x43, 0x72, 0x65, 0x61, + 0x74, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x74, 0x65, 0x6d, 0x70, 0x5f, 0x70, 0x61, 0x74, + 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x74, 0x65, 0x6d, 0x70, 0x50, 0x61, 0x74, + 0x68, 0x22, 0x64, 0x0a, 0x11, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x46, 0x69, 0x6c, 0x65, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x23, 0x0a, 0x04, 0x69, 0x6e, 0x66, 0x6f, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x46, 0x69, 0x6c, 0x65, 0x49, + 0x6e, 0x66, 0x6f, 0x48, 0x00, 0x52, 0x04, 0x69, 0x6e, 0x66, 0x6f, 0x12, 0x22, 0x0a, 0x05, 0x63, + 0x68, 0x75, 0x6e, 0x6b, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x72, 0x70, 0x63, + 0x2e, 0x43, 0x68, 0x75, 0x6e, 0x6b, 0x48, 0x00, 0x52, 0x05, 0x63, 0x68, 0x75, 0x6e, 0x6b, 0x42, + 0x06, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x38, 0x0a, 0x12, 0x55, 0x70, 0x6c, 0x6f, 0x61, + 0x64, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x0e, 0x0a, + 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, + 0x04, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x04, 0x73, 0x69, 0x7a, + 0x65, 0x22, 0xb0, 0x01, 0x0a, 0x08, 0x46, 0x69, 0x6c, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x0e, + 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1a, + 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x72, 0x65, + 0x70, 0x6f, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x72, 0x65, 0x70, 0x6f, 0x12, 0x16, + 0x0a, 0x06, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, + 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x12, 0x1b, 0x0a, 0x09, 0x72, 0x65, 0x70, 0x6f, 0x5f, 0x70, + 0x61, 0x74, 0x68, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x72, 0x65, 0x70, 0x6f, 0x50, + 0x61, 0x74, 0x68, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x06, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x12, 0x1b, 0x0a, 0x09, 0x66, 0x69, 0x6c, 0x65, 0x5f, + 0x74, 0x79, 0x70, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x66, 0x69, 0x6c, 0x65, + 0x54, 0x79, 0x70, 0x65, 0x22, 0x65, 0x0a, 0x16, 0x41, 0x64, 0x64, 0x46, 0x69, 0x6c, 0x65, 0x73, + 0x41, 0x6e, 0x64, 0x50, 0x75, 0x73, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1b, + 0x0a, 0x09, 0x72, 0x65, 0x70, 0x6f, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x08, 0x72, 0x65, 0x70, 0x6f, 0x50, 0x61, 0x74, 0x68, 0x12, 0x18, 0x0a, 0x07, 0x6d, + 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, + 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x18, 0x03, + 0x20, 0x03, 0x28, 0x09, 0x52, 0x05, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x22, 0x19, 0x0a, 0x17, 0x41, 0x64, 0x64, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x41, 0x6e, 0x64, 0x50, 0x75, 0x73, 0x68, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0x4e, 0x0a, 0x0d, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, - 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x3d, 0x0a, 0x06, 0x55, 0x70, 0x6c, 0x6f, 0x61, - 0x64, 0x12, 0x16, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x46, 0x69, - 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x72, 0x70, 0x63, 0x2e, - 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x22, 0x00, 0x28, 0x01, 0x42, 0x27, 0x5a, 0x25, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, - 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x68, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2f, 0x67, 0x69, 0x74, - 0x6e, 0x65, 0x73, 0x73, 0x2f, 0x67, 0x69, 0x74, 0x72, 0x70, 0x63, 0x2f, 0x72, 0x70, 0x63, 0x62, - 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x5d, 0x0a, 0x0a, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, + 0x74, 0x6f, 0x72, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, + 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x25, + 0x0a, 0x0e, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x5f, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x42, + 0x72, 0x61, 0x6e, 0x63, 0x68, 0x22, 0x2d, 0x0a, 0x05, 0x43, 0x68, 0x75, 0x6e, 0x6b, 0x12, 0x10, + 0x0a, 0x03, 0x65, 0x6f, 0x66, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x03, 0x65, 0x6f, 0x66, + 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, + 0x64, 0x61, 0x74, 0x61, 0x32, 0xb4, 0x01, 0x0a, 0x11, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, + 0x6f, 0x72, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x51, 0x0a, 0x10, 0x43, 0x72, + 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x12, 0x1c, + 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x73, + 0x69, 0x74, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x72, + 0x70, 0x63, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, + 0x6f, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x28, 0x01, 0x12, 0x4c, 0x0a, + 0x0f, 0x41, 0x64, 0x64, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x41, 0x6e, 0x64, 0x50, 0x75, 0x73, 0x68, + 0x12, 0x1b, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x41, 0x64, 0x64, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x41, + 0x6e, 0x64, 0x50, 0x75, 0x73, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, + 0x72, 0x70, 0x63, 0x2e, 0x41, 0x64, 0x64, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x41, 0x6e, 0x64, 0x50, + 0x75, 0x73, 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0x4e, 0x0a, 0x0d, 0x55, + 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x3d, 0x0a, 0x06, + 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x12, 0x16, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x55, 0x70, 0x6c, + 0x6f, 0x61, 0x64, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, + 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x46, 0x69, 0x6c, 0x65, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x28, 0x01, 0x42, 0x27, 0x5a, 0x25, 0x67, + 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x68, 0x61, 0x72, 0x6e, 0x65, 0x73, + 0x73, 0x2f, 0x67, 0x69, 0x74, 0x6e, 0x65, 0x73, 0x73, 0x2f, 0x67, 0x69, 0x74, 0x72, 0x70, 0x63, + 0x2f, 0x72, 0x70, 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -642,7 +700,7 @@ func file_repo_proto_rawDescGZIP() []byte { return file_repo_proto_rawDescData } -var file_repo_proto_msgTypes = make([]protoimpl.MessageInfo, 8) +var file_repo_proto_msgTypes = make([]protoimpl.MessageInfo, 9) var file_repo_proto_goTypes = []interface{}{ (*CreateRepositoryRequest)(nil), // 0: rpc.CreateRepositoryRequest (*CreateRepositoryResponse)(nil), // 1: rpc.CreateRepositoryResponse @@ -652,21 +710,24 @@ var file_repo_proto_goTypes = []interface{}{ (*AddFilesAndPushRequest)(nil), // 5: rpc.AddFilesAndPushRequest (*AddFilesAndPushResponse)(nil), // 6: rpc.AddFilesAndPushResponse (*Repository)(nil), // 7: rpc.Repository + (*Chunk)(nil), // 8: rpc.Chunk } var file_repo_proto_depIdxs = []int32{ 7, // 0: rpc.CreateRepositoryRequest.repository:type_name -> rpc.Repository - 4, // 1: rpc.UploadFileRequest.info:type_name -> rpc.FileInfo - 0, // 2: rpc.RepositoryService.CreateRepository:input_type -> rpc.CreateRepositoryRequest - 5, // 3: rpc.RepositoryService.AddFilesAndPush:input_type -> rpc.AddFilesAndPushRequest - 2, // 4: rpc.UploadService.Upload:input_type -> rpc.UploadFileRequest - 1, // 5: rpc.RepositoryService.CreateRepository:output_type -> rpc.CreateRepositoryResponse - 6, // 6: rpc.RepositoryService.AddFilesAndPush:output_type -> rpc.AddFilesAndPushResponse - 3, // 7: rpc.UploadService.Upload:output_type -> rpc.UploadFileResponse - 5, // [5:8] is the sub-list for method output_type - 2, // [2:5] is the sub-list for method input_type - 2, // [2:2] is the sub-list for extension type_name - 2, // [2:2] is the sub-list for extension extendee - 0, // [0:2] is the sub-list for field type_name + 8, // 1: rpc.CreateRepositoryRequest.chunk:type_name -> rpc.Chunk + 4, // 2: rpc.UploadFileRequest.info:type_name -> rpc.FileInfo + 8, // 3: rpc.UploadFileRequest.chunk:type_name -> rpc.Chunk + 0, // 4: rpc.RepositoryService.CreateRepository:input_type -> rpc.CreateRepositoryRequest + 5, // 5: rpc.RepositoryService.AddFilesAndPush:input_type -> rpc.AddFilesAndPushRequest + 2, // 6: rpc.UploadService.Upload:input_type -> rpc.UploadFileRequest + 1, // 7: rpc.RepositoryService.CreateRepository:output_type -> rpc.CreateRepositoryResponse + 6, // 8: rpc.RepositoryService.AddFilesAndPush:output_type -> rpc.AddFilesAndPushResponse + 3, // 9: rpc.UploadService.Upload:output_type -> rpc.UploadFileResponse + 7, // [7:10] is the sub-list for method output_type + 4, // [4:7] is the sub-list for method input_type + 4, // [4:4] is the sub-list for extension type_name + 4, // [4:4] is the sub-list for extension extendee + 0, // [0:4] is the sub-list for field type_name } func init() { file_repo_proto_init() } @@ -772,15 +833,27 @@ func file_repo_proto_init() { return nil } } + file_repo_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Chunk); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } file_repo_proto_msgTypes[0].OneofWrappers = []interface{}{ (*CreateRepositoryRequest_Repository)(nil), (*CreateRepositoryRequest_Filepath)(nil), - (*CreateRepositoryRequest_ChunkData)(nil), + (*CreateRepositoryRequest_Chunk)(nil), } file_repo_proto_msgTypes[2].OneofWrappers = []interface{}{ (*UploadFileRequest_Info)(nil), - (*UploadFileRequest_ChunkData)(nil), + (*UploadFileRequest_Chunk)(nil), } type x struct{} out := protoimpl.TypeBuilder{ @@ -788,7 +861,7 @@ func file_repo_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_repo_proto_rawDesc, NumEnums: 0, - NumMessages: 8, + NumMessages: 9, NumExtensions: 0, NumServices: 2, }, diff --git a/internal/gitrpc/rpc/repo_grpc.pb.go b/internal/gitrpc/rpc/repo_grpc.pb.go index ca997647b..8ce3458e6 100644 --- a/internal/gitrpc/rpc/repo_grpc.pb.go +++ b/internal/gitrpc/rpc/repo_grpc.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.2.0 -// - protoc v3.21.7 +// - protoc v3.19.4 // source: repo.proto package rpc diff --git a/internal/gitrpc/rpc/shared.pb.go b/internal/gitrpc/rpc/shared.pb.go index 45aad3c6a..d6c949eed 100644 --- a/internal/gitrpc/rpc/shared.pb.go +++ b/internal/gitrpc/rpc/shared.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.7 +// protoc-gen-go v1.27.1 +// protoc v3.19.4 // source: shared.proto package rpc diff --git a/internal/gitrpc/server.go b/internal/gitrpc/server.go index f7eb47326..1bf35ca34 100644 --- a/internal/gitrpc/server.go +++ b/internal/gitrpc/server.go @@ -1,3 +1,7 @@ +// Copyright 2022 Harness Inc. All rights reserved. +// Use of this source code is governed by the Polyform Free Trial License +// that can be found in the LICENSE.md file for this repository. + package gitrpc import ( diff --git a/internal/gitrpc/types.go b/internal/gitrpc/types.go index a10f96f6c..d5ed11493 100644 --- a/internal/gitrpc/types.go +++ b/internal/gitrpc/types.go @@ -1,3 +1,7 @@ +// Copyright 2022 Harness Inc. All rights reserved. +// Use of this source code is governed by the Polyform Free Trial License +// that can be found in the LICENSE.md file for this repository. + package gitrpc import "time" diff --git a/internal/gitrpc/upload.go b/internal/gitrpc/upload.go index a01b85c5c..219e41892 100644 --- a/internal/gitrpc/upload.go +++ b/internal/gitrpc/upload.go @@ -1,3 +1,7 @@ +// Copyright 2022 Harness Inc. All rights reserved. +// Use of this source code is governed by the Polyform Free Trial License +// that can be found in the LICENSE.md file for this repository. + package gitrpc import ( @@ -12,7 +16,7 @@ import ( "google.golang.org/grpc/status" ) -const maxImageSize = 1 << 20 +const maxFileSize = 1 << 20 type UploadStore interface { Save(filePath string, data bytes.Buffer) (string, error) @@ -55,29 +59,29 @@ func (s uploadService) Upload(stream rpc.UploadService_UploadServer) error { return status.Errorf(codes.Unknown, "cannot receive chunk data: %v", err) } - chunk := req.GetChunkData() - size := len(chunk) + chunk := req.GetChunk() + size := len(chunk.Data) - log.Printf("received a chunk with size: %d", size) + log.Info().Msgf("received a chunk with size: %d", size) fileSize += size - if fileSize > maxImageSize { - return status.Errorf(codes.InvalidArgument, "file is too large: %d > %d", fileSize, maxImageSize) + if fileSize > maxFileSize { + return status.Errorf(codes.InvalidArgument, "file is too large: %d > %d", fileSize, maxFileSize) } - _, err = fileData.Write(chunk) + _, err = fileData.Write(chunk.Data) if err != nil { return status.Errorf(codes.Internal, "cannot write chunk data: %v", err) } } log.Info().Msgf("saving file %s in repo path %s", fi.GetPath(), fi.GetRepoPath()) fullPath := filepath.Join(fi.GetRepoPath(), fi.GetPath()) - imageID, err := s.store.Save(fullPath, fileData) + fileID, err := s.store.Save(fullPath, fileData) if err != nil { return status.Errorf(codes.Internal, "cannot save file to the store: %v", err) } res := &rpc.UploadFileResponse{ - Id: imageID, + Id: fileID, Size: uint32(fileSize), } @@ -86,6 +90,6 @@ func (s uploadService) Upload(stream rpc.UploadService_UploadServer) error { return status.Errorf(codes.Unknown, "cannot send response: %v", err) } - log.Info().Msgf("saved file with id: %s, size: %d", imageID, fileSize) + log.Info().Msgf("saved file with id: %s, size: %d", fileID, fileSize) return nil } diff --git a/internal/gitrpc/wire.go b/internal/gitrpc/wire.go index 628df976a..e8e1f3964 100644 --- a/internal/gitrpc/wire.go +++ b/internal/gitrpc/wire.go @@ -1,3 +1,7 @@ +// Copyright 2022 Harness Inc. All rights reserved. +// Use of this source code is governed by the Polyform Free Trial License +// that can be found in the LICENSE.md file for this repository. + package gitrpc import "github.com/google/wire" diff --git a/internal/router/api.go b/internal/router/api.go index 14078fe44..a2a71328d 100644 --- a/internal/router/api.go +++ b/internal/router/api.go @@ -1,3 +1,7 @@ +// Copyright 2022 Harness Inc. All rights reserved. +// Use of this source code is governed by the Polyform Free Trial License +// that can be found in the LICENSE.md file for this repository. + package router import ( diff --git a/internal/router/git.go b/internal/router/git.go index 379b802cb..3a7c7a489 100644 --- a/internal/router/git.go +++ b/internal/router/git.go @@ -1,3 +1,7 @@ +// Copyright 2022 Harness Inc. All rights reserved. +// Use of this source code is governed by the Polyform Free Trial License +// that can be found in the LICENSE.md file for this repository. + package router import ( diff --git a/internal/router/web.go b/internal/router/web.go index 5e695e6a7..f9b11b418 100644 --- a/internal/router/web.go +++ b/internal/router/web.go @@ -1,3 +1,7 @@ +// Copyright 2022 Harness Inc. All rights reserved. +// Use of this source code is governed by the Polyform Free Trial License +// that can be found in the LICENSE.md file for this repository. + package router import ( diff --git a/resources/embed.go b/resources/embed.go index 85d3cfba0..93e85ea06 100644 --- a/resources/embed.go +++ b/resources/embed.go @@ -1,3 +1,7 @@ +// Copyright 2022 Harness Inc. All rights reserved. +// Use of this source code is governed by the Polyform Free Trial License +// that can be found in the LICENSE.md file for this repository. + package resources import "embed" @@ -6,6 +10,6 @@ var ( //go:embed gitignore Gitignore embed.FS - //go:embed licence + //go:embed license Licence embed.FS ) diff --git a/resources/licence/afl-3.0.txt b/resources/license/afl-3.0.txt similarity index 100% rename from resources/licence/afl-3.0.txt rename to resources/license/afl-3.0.txt diff --git a/resources/licence/agpl-3.0.txt b/resources/license/agpl-3.0.txt similarity index 100% rename from resources/licence/agpl-3.0.txt rename to resources/license/agpl-3.0.txt diff --git a/resources/licence/apache-2.0.txt b/resources/license/apache-2.0.txt similarity index 100% rename from resources/licence/apache-2.0.txt rename to resources/license/apache-2.0.txt diff --git a/resources/licence/artistic-2.0.txt b/resources/license/artistic-2.0.txt similarity index 100% rename from resources/licence/artistic-2.0.txt rename to resources/license/artistic-2.0.txt diff --git a/resources/licence/bsd-2-clause.txt b/resources/license/bsd-2-clause.txt similarity index 100% rename from resources/licence/bsd-2-clause.txt rename to resources/license/bsd-2-clause.txt diff --git a/resources/licence/bsd-3-clause-clear.txt b/resources/license/bsd-3-clause-clear.txt similarity index 100% rename from resources/licence/bsd-3-clause-clear.txt rename to resources/license/bsd-3-clause-clear.txt diff --git a/resources/licence/bsd-3-clause.txt b/resources/license/bsd-3-clause.txt similarity index 100% rename from resources/licence/bsd-3-clause.txt rename to resources/license/bsd-3-clause.txt diff --git a/resources/licence/bsl-1.0.txt b/resources/license/bsl-1.0.txt similarity index 100% rename from resources/licence/bsl-1.0.txt rename to resources/license/bsl-1.0.txt diff --git a/resources/licence/cc-by-4.0.txt b/resources/license/cc-by-4.0.txt similarity index 100% rename from resources/licence/cc-by-4.0.txt rename to resources/license/cc-by-4.0.txt diff --git a/resources/licence/cc-by-sa-4.0.txt b/resources/license/cc-by-sa-4.0.txt similarity index 100% rename from resources/licence/cc-by-sa-4.0.txt rename to resources/license/cc-by-sa-4.0.txt diff --git a/resources/licence/cc.txt b/resources/license/cc.txt similarity index 100% rename from resources/licence/cc.txt rename to resources/license/cc.txt diff --git a/resources/licence/cc0-1.0.txt b/resources/license/cc0-1.0.txt similarity index 100% rename from resources/licence/cc0-1.0.txt rename to resources/license/cc0-1.0.txt diff --git a/resources/licence/ecl-2.0.txt b/resources/license/ecl-2.0.txt similarity index 100% rename from resources/licence/ecl-2.0.txt rename to resources/license/ecl-2.0.txt diff --git a/resources/licence/epl-1.0.txt b/resources/license/epl-1.0.txt similarity index 100% rename from resources/licence/epl-1.0.txt rename to resources/license/epl-1.0.txt diff --git a/resources/licence/epl-2.0.txt b/resources/license/epl-2.0.txt similarity index 100% rename from resources/licence/epl-2.0.txt rename to resources/license/epl-2.0.txt diff --git a/resources/licence/eupl-1.1.txt b/resources/license/eupl-1.1.txt similarity index 100% rename from resources/licence/eupl-1.1.txt rename to resources/license/eupl-1.1.txt diff --git a/resources/licence/gpl-2.0.txt b/resources/license/gpl-2.0.txt similarity index 100% rename from resources/licence/gpl-2.0.txt rename to resources/license/gpl-2.0.txt diff --git a/resources/licence/gpl-3.0.txt b/resources/license/gpl-3.0.txt similarity index 100% rename from resources/licence/gpl-3.0.txt rename to resources/license/gpl-3.0.txt diff --git a/resources/licence/gpl.txt b/resources/license/gpl.txt similarity index 100% rename from resources/licence/gpl.txt rename to resources/license/gpl.txt diff --git a/resources/licence/index.json b/resources/license/index.json similarity index 100% rename from resources/licence/index.json rename to resources/license/index.json diff --git a/resources/licence/isc.txt b/resources/license/isc.txt similarity index 100% rename from resources/licence/isc.txt rename to resources/license/isc.txt diff --git a/resources/licence/lgpl-2.1.txt b/resources/license/lgpl-2.1.txt similarity index 100% rename from resources/licence/lgpl-2.1.txt rename to resources/license/lgpl-2.1.txt diff --git a/resources/licence/lgpl-3.0.txt b/resources/license/lgpl-3.0.txt similarity index 100% rename from resources/licence/lgpl-3.0.txt rename to resources/license/lgpl-3.0.txt diff --git a/resources/licence/lgpl.txt b/resources/license/lgpl.txt similarity index 100% rename from resources/licence/lgpl.txt rename to resources/license/lgpl.txt diff --git a/resources/licence/mit.txt b/resources/license/mit.txt similarity index 100% rename from resources/licence/mit.txt rename to resources/license/mit.txt diff --git a/resources/licence/mpl-2.0.txt b/resources/license/mpl-2.0.txt similarity index 100% rename from resources/licence/mpl-2.0.txt rename to resources/license/mpl-2.0.txt diff --git a/resources/licence/osl-3.0.txt b/resources/license/osl-3.0.txt similarity index 100% rename from resources/licence/osl-3.0.txt rename to resources/license/osl-3.0.txt diff --git a/resources/licence/unlicense.txt b/resources/license/unlicense.txt similarity index 100% rename from resources/licence/unlicense.txt rename to resources/license/unlicense.txt diff --git a/resources/licence/zlib.txt b/resources/license/zlib.txt similarity index 100% rename from resources/licence/zlib.txt rename to resources/license/zlib.txt