Add EOF to RPC File Chunk & Cleanups (#29)

Adds an EOF flag to data chunks to avoid using []byte("EOF") as end (due to potential false positives).
Furthermore, a few cleanups are done:
- Add TODOs for initial git changes
- Add missing file headers
- Fix typo for license (was licence)
- Fix make wire target
This commit is contained in:
Johannes Batzill 2022-10-12 10:21:53 -07:00 committed by GitHub
parent 6cadb048ba
commit ecb6276fa8
67 changed files with 387 additions and 162 deletions

View File

@ -35,7 +35,7 @@ tools: $(tools) ## Install tools required for the build
mocks: $(mocks) mocks: $(mocks)
@echo "Generating Test 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 generate: $(mocks) wire mocks/mock_client.go proto
@echo "Generating Code" @echo "Generating Code"

View File

@ -21,6 +21,7 @@ import (
"github.com/harness/gitness/internal/api/controller/space" "github.com/harness/gitness/internal/api/controller/space"
"github.com/harness/gitness/internal/api/controller/user" "github.com/harness/gitness/internal/api/controller/user"
"github.com/harness/gitness/internal/cron" "github.com/harness/gitness/internal/cron"
"github.com/harness/gitness/internal/gitrpc"
"github.com/harness/gitness/internal/server" "github.com/harness/gitness/internal/server"
"github.com/harness/gitness/internal/store/database" "github.com/harness/gitness/internal/store/database"
"github.com/harness/gitness/internal/store/memory" "github.com/harness/gitness/internal/store/memory"
@ -41,6 +42,7 @@ func initSystem(ctx context.Context, config *gitnessTypes.Config) (*system, erro
space.WireSet, space.WireSet,
user.WireSet, user.WireSet,
service.WireSet, service.WireSet,
gitrpc.WireSet,
types.LoadConfig, types.LoadConfig,
router.WireSet, router.WireSet,
authn.WireSet, authn.WireSet,

View File

@ -19,6 +19,7 @@ import (
"github.com/harness/gitness/internal/api/controller/space" "github.com/harness/gitness/internal/api/controller/space"
"github.com/harness/gitness/internal/api/controller/user" "github.com/harness/gitness/internal/api/controller/user"
"github.com/harness/gitness/internal/cron" "github.com/harness/gitness/internal/cron"
"github.com/harness/gitness/internal/gitrpc"
router2 "github.com/harness/gitness/internal/router" router2 "github.com/harness/gitness/internal/router"
"github.com/harness/gitness/internal/server" "github.com/harness/gitness/internal/server"
"github.com/harness/gitness/internal/store/database" "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) spaceStore := database.ProvideSpaceStore(db)
repoStore := database.ProvideRepoStore(db) repoStore := database.ProvideRepoStore(db)
spaceController := space.NewController(authorizer, spaceStore, repoStore, serviceAccountStore) 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) apiHandler := router.ProvideAPIHandler(systemStore, authenticator, accountClient, spaceController, repoController)
gitHandler := router2.ProvideGitHandler(repoStore, authenticator) gitHandler := router2.ProvideGitHandler(repoStore, authenticator)
webHandler := router2.ProvideWebHandler(systemStore) webHandler := router2.ProvideWebHandler(systemStore)

View File

@ -1,8 +1,7 @@
// Code generated by Wire. DO NOT EDIT. // Code generated by Wire. DO NOT EDIT.
//go:generate go run github.com/google/wire/cmd/wire //go:build !wireinject && !harness
//go:build !wireinject // +build !wireinject,!harness
// +build !wireinject
package server package server

View File

@ -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 package session
type Session struct { type Session struct {

View File

@ -33,11 +33,12 @@ type CreateInput struct {
IsPublic bool `json:"isPublic"` IsPublic bool `json:"isPublic"`
ForkID int64 `json:"forkId"` ForkID int64 `json:"forkId"`
Readme bool `json:"readme"` Readme bool `json:"readme"`
Licence string `json:"licence"` License string `json:"license"`
GitIgnore string `json:"gitIgnore"` GitIgnore string `json:"gitIgnore"`
} }
// Create creates a new repository. // 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) { func (c *Controller) Create(ctx context.Context, session *auth.Session, in *CreateInput) (*types.Repository, error) {
log := zerolog.Ctx(ctx) log := zerolog.Ctx(ctx)
// ensure we reference a space // 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" { if in.License != "" && in.License != "none" {
content, err = resources.Licence.ReadFile(fmt.Sprintf("licence/%s.txt", in.Licence)) // 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 { if err != nil {
return nil, err return nil, err
} }
files = append(files, gitrpc.File{ files = append(files, gitrpc.File{
Name: "LICENCE", Name: "LICENSE",
Base64: false, Base64: false,
Content: content, Content: content,
}) })
} }
if in.GitIgnore != "" { 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)) content, err = resources.Gitignore.ReadFile(fmt.Sprintf("gitignore/%s.gitignore", in.GitIgnore))
if err != nil { if err != nil {
return nil, err 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{ err = c.rpcClient.CreateRepository(ctx, &gitrpc.CreateRepositoryParams{
RepositoryParams: gitrpc.RepositoryParams{ RepositoryParams: gitrpc.RepositoryParams{
Username: session.Principal.Name, Username: session.Principal.Name,
Name: repo.Name, // TODO: use UID as name
Branch: in.Branch, Name: repo.PathName,
Branch: in.Branch,
}, },
Files: files, Files: files,
}) })

View File

@ -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 package repo
import ( import (

View File

@ -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 package encode
import ( import (

View File

@ -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 package platform
import ( import (

View File

@ -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 package request
import ( import (

View File

@ -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 package request
import ( import (

View File

@ -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 package request
import ( import (

View File

@ -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 package request
import ( import (

View File

@ -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 package request
import ( import (

View File

@ -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 package usererror
import ( import (

View File

@ -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 package gitrpc
import ( import (
@ -28,6 +32,7 @@ type File struct {
} }
type RepositoryParams struct { type RepositoryParams struct {
// TODO: What is it used for?
Username string Username string
Name string Name string
Branch string Branch string
@ -147,22 +152,28 @@ func (c *Client) process(
stream rpc.RepositoryService_CreateRepositoryClient) error { stream rpc.RepositoryService_CreateRepositoryClient) error {
n, err := reader.Read(buffer) n, err := reader.Read(buffer)
if errors.Is(err, io.EOF) { if errors.Is(err, io.EOF) {
log.Info().Msgf("EOF detected at %v", filename) log.Info().Msgf("EOF reached for %v", filename)
buffer = []byte{'E', 'O', 'F'} err = c.send(buffer[:n], true, stream)
_ = c.send(buffer, stream) if err != nil {
return err
}
return io.EOF return io.EOF
} }
if err != nil { if err != nil {
return fmt.Errorf("cannot read buffer: %w", err) 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{ req := &rpc.CreateRepositoryRequest{
Data: &rpc.CreateRepositoryRequest_ChunkData{ Data: &rpc.CreateRepositoryRequest_Chunk{
ChunkData: buffer, Chunk: &rpc.Chunk{
Eof: eof,
Data: buffer,
},
}, },
} }
@ -214,17 +225,20 @@ func (c *Client) Upload(ctx context.Context, params *UploadParams, reader io.Rea
for { for {
var n int var n int
eof := false
n, err = reader.Read(buffer) n, err = reader.Read(buffer)
if errors.Is(err, io.EOF) { if errors.Is(err, io.EOF) {
break eof = true
} } else if err != nil {
if err != nil {
return "", fmt.Errorf("cannot read chunk to buffer: %w", err) return "", fmt.Errorf("cannot read chunk to buffer: %w", err)
} }
req = &rpc.UploadFileRequest{ req = &rpc.UploadFileRequest{
Data: &rpc.UploadFileRequest_ChunkData{ Data: &rpc.UploadFileRequest_Chunk{
ChunkData: buffer[:n], 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) err = stream.RecvMsg(nil)
return "", status.Errorf(codes.Internal, "cannot send chunk to server: %v", err) return "", status.Errorf(codes.Internal, "cannot send chunk to server: %v", err)
} }
if eof {
break
}
} }
res, err := stream.CloseAndRecv() 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) return "", fmt.Errorf("cannot receive response: %w", err)
} }
fullPath := res.GetId() 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 return fullPath, nil
} }

View File

@ -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 package gitrpc
type Config struct { type Config struct {

View File

@ -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 package gitrpc
import ( import (

View File

@ -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 package gitrpc
import ( import (

View File

@ -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 package gitrpc
import "context" import "context"

View File

@ -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 package gitrpc
import ( import (
@ -9,13 +13,13 @@ import (
) )
type localStore struct { type localStore struct {
mutex sync.RWMutex mutex sync.RWMutex
images map[string]bool files map[string]bool
} }
func newLocalStore() *localStore { func newLocalStore() *localStore {
return &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() store.mutex.Lock()
defer store.mutex.Unlock() defer store.mutex.Unlock()
store.images[filePath] = true store.files[filePath] = true
return filePath, nil return filePath, nil
} }

View File

@ -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 package main
import ( import (

View File

@ -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 package lock
import "context" import "context"

View File

@ -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 package lock
import ( import (
@ -33,6 +37,7 @@ func (c *Mutex) AcquireLock(ctx context.Context, key string) (*Lock, error) {
lockChan: make(chan struct{}, 1), lockChan: make(chan struct{}, 1),
} }
} }
// TODO: One acquire having to wait causes all to wait?
select { select {
case lock.lockChan <- struct{}{}: case lock.lockChan <- struct{}{}:
lock.state = true lock.state = true

View File

@ -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 package lock
import ( import (

View File

@ -19,7 +19,7 @@ message CreateRepositoryRequest {
oneof data { oneof data {
Repository repository = 1; Repository repository = 1;
string filepath = 2; string filepath = 2;
bytes chunk_data = 3; Chunk chunk = 3;
} }
} }
@ -30,7 +30,7 @@ message CreateRepositoryResponse {
message UploadFileRequest { message UploadFileRequest {
oneof data { oneof data {
FileInfo info = 1; FileInfo info = 1;
bytes chunk_data = 2; Chunk chunk = 2;
}; };
} }
@ -61,4 +61,9 @@ message Repository {
string owner = 1; string owner = 1;
string name = 2; string name = 2;
string default_branch = 3; string default_branch = 3;
}
message Chunk {
bool eof = 1;
bytes data = 2;
} }

View File

@ -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 package gitrpc
import ( import (
@ -36,7 +40,7 @@ func (s repositoryService) CreateRepository(stream rpc.RepositoryService_CreateR
log.Info().Msgf("receive an create repository request %v", repo) log.Info().Msgf("receive an create repository request %v", repo)
targetPath := filepath.Join(repoRoot, repo.Name) targetPath := filepath.Join(repoRoot, repo.Name)
if _, err = os.Stat(targetPath); !os.IsNotExist(err) { 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 // create repository in repos folder
@ -69,7 +73,7 @@ func (s repositoryService) CreateRepository(stream rpc.RepositoryService_CreateR
// logic for receiving the files // logic for receiving the files
files := make([]string, 0, 16) files := make([]string, 0, 16)
for { for {
log.Info().Msg("waiting to receive filepath data") log.Info().Msg("waiting to receive file path")
req, err = stream.Recv() req, err = stream.Recv()
if errors.Is(err, io.EOF) { if errors.Is(err, io.EOF) {
log.Info().Msg("EOF found") log.Info().Msg("EOF found")
@ -82,30 +86,32 @@ func (s repositoryService) CreateRepository(stream rpc.RepositoryService_CreateR
fileData := bytes.Buffer{} fileData := bytes.Buffer{}
fileSize := 0 fileSize := 0
for { for {
log.Info().Msg("waiting to receive more data") log.Debug().Msg("waiting to receive data")
req, err = stream.Recv() req, err = stream.Recv()
if errors.Is(err, io.EOF) { 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 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) log.Info().Msgf("saving file %s in repo path %s", filePath, tempDir)
fullPath := filepath.Join(tempDir, filePath) fullPath := filepath.Join(tempDir, filePath)
@ -121,7 +127,7 @@ func (s repositoryService) CreateRepository(stream rpc.RepositoryService_CreateR
if len(files) > 0 { if len(files) > 0 {
if _, err = s.AddFilesAndPush(ctx, &rpc.AddFilesAndPushRequest{ if _, err = s.AddFilesAndPush(ctx, &rpc.AddFilesAndPushRequest{
RepoPath: res.GetTempPath(), RepoPath: tempDir,
Message: "initial commit", Message: "initial commit",
Files: files, Files: files,
}); err != nil { }); err != nil {
@ -131,10 +137,10 @@ func (s repositoryService) CreateRepository(stream rpc.RepositoryService_CreateR
err = stream.SendAndClose(res) err = stream.SendAndClose(res)
if err != nil { 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 return nil
} }
@ -148,11 +154,13 @@ func (s repositoryService) AddFilesAndPush(
} }
now := time.Now() now := time.Now()
err = s.adapter.Commit(params.GetRepoPath(), commitChangesOptions{ err = s.adapter.Commit(params.GetRepoPath(), commitChangesOptions{
// TODO: Add gitness signature
committer: &signature{ committer: &signature{
name: "enver", name: "enver",
email: "enver.bisevac@harness.io", email: "enver.bisevac@harness.io",
when: now, when: now,
}, },
// TODO: Add gitness signature
author: &signature{ author: &signature{
name: "enver", name: "enver",
email: "enver.bisevac@harness.io", email: "enver.bisevac@harness.io",
@ -164,6 +172,7 @@ func (s repositoryService) AddFilesAndPush(
return nil, err return nil, err
} }
err = s.adapter.Push(ctx, params.GetRepoPath(), pushOptions{ err = s.adapter.Push(ctx, params.GetRepoPath(), pushOptions{
// TODO: Don't hard-code
remote: "origin", remote: "origin",
branch: "", branch: "",
force: false, force: false,
@ -174,6 +183,7 @@ func (s repositoryService) AddFilesAndPush(
if err != nil { if err != nil {
return nil, err return nil, err
} }
// TODO: caller should delete repo if needed (as we didn't create it here)
err = os.RemoveAll(params.GetRepoPath()) err = os.RemoveAll(params.GetRepoPath())
if err != nil { if err != nil {
return nil, err return nil, err

View File

@ -1,7 +1,7 @@
// Code generated by protoc-gen-go. DO NOT EDIT. // Code generated by protoc-gen-go. DO NOT EDIT.
// versions: // versions:
// protoc-gen-go v1.28.1 // protoc-gen-go v1.27.1
// protoc v3.21.7 // protoc v3.19.4
// source: repo.proto // source: repo.proto
package rpc package rpc
@ -28,7 +28,7 @@ type CreateRepositoryRequest struct {
// Types that are assignable to Data: // Types that are assignable to Data:
// *CreateRepositoryRequest_Repository // *CreateRepositoryRequest_Repository
// *CreateRepositoryRequest_Filepath // *CreateRepositoryRequest_Filepath
// *CreateRepositoryRequest_ChunkData // *CreateRepositoryRequest_Chunk
Data isCreateRepositoryRequest_Data `protobuf_oneof:"data"` Data isCreateRepositoryRequest_Data `protobuf_oneof:"data"`
} }
@ -85,9 +85,9 @@ func (x *CreateRepositoryRequest) GetFilepath() string {
return "" return ""
} }
func (x *CreateRepositoryRequest) GetChunkData() []byte { func (x *CreateRepositoryRequest) GetChunk() *Chunk {
if x, ok := x.GetData().(*CreateRepositoryRequest_ChunkData); ok { if x, ok := x.GetData().(*CreateRepositoryRequest_Chunk); ok {
return x.ChunkData return x.Chunk
} }
return nil return nil
} }
@ -104,15 +104,15 @@ type CreateRepositoryRequest_Filepath struct {
Filepath string `protobuf:"bytes,2,opt,name=filepath,proto3,oneof"` Filepath string `protobuf:"bytes,2,opt,name=filepath,proto3,oneof"`
} }
type CreateRepositoryRequest_ChunkData struct { type CreateRepositoryRequest_Chunk struct {
ChunkData []byte `protobuf:"bytes,3,opt,name=chunk_data,json=chunkData,proto3,oneof"` Chunk *Chunk `protobuf:"bytes,3,opt,name=chunk,proto3,oneof"`
} }
func (*CreateRepositoryRequest_Repository) isCreateRepositoryRequest_Data() {} func (*CreateRepositoryRequest_Repository) isCreateRepositoryRequest_Data() {}
func (*CreateRepositoryRequest_Filepath) isCreateRepositoryRequest_Data() {} func (*CreateRepositoryRequest_Filepath) isCreateRepositoryRequest_Data() {}
func (*CreateRepositoryRequest_ChunkData) isCreateRepositoryRequest_Data() {} func (*CreateRepositoryRequest_Chunk) isCreateRepositoryRequest_Data() {}
type CreateRepositoryResponse struct { type CreateRepositoryResponse struct {
state protoimpl.MessageState state protoimpl.MessageState
@ -168,7 +168,7 @@ type UploadFileRequest struct {
// Types that are assignable to Data: // Types that are assignable to Data:
// *UploadFileRequest_Info // *UploadFileRequest_Info
// *UploadFileRequest_ChunkData // *UploadFileRequest_Chunk
Data isUploadFileRequest_Data `protobuf_oneof:"data"` Data isUploadFileRequest_Data `protobuf_oneof:"data"`
} }
@ -218,9 +218,9 @@ func (x *UploadFileRequest) GetInfo() *FileInfo {
return nil return nil
} }
func (x *UploadFileRequest) GetChunkData() []byte { func (x *UploadFileRequest) GetChunk() *Chunk {
if x, ok := x.GetData().(*UploadFileRequest_ChunkData); ok { if x, ok := x.GetData().(*UploadFileRequest_Chunk); ok {
return x.ChunkData return x.Chunk
} }
return nil return nil
} }
@ -233,13 +233,13 @@ type UploadFileRequest_Info struct {
Info *FileInfo `protobuf:"bytes,1,opt,name=info,proto3,oneof"` Info *FileInfo `protobuf:"bytes,1,opt,name=info,proto3,oneof"`
} }
type UploadFileRequest_ChunkData struct { type UploadFileRequest_Chunk struct {
ChunkData []byte `protobuf:"bytes,2,opt,name=chunk_data,json=chunkData,proto3,oneof"` Chunk *Chunk `protobuf:"bytes,2,opt,name=chunk,proto3,oneof"`
} }
func (*UploadFileRequest_Info) isUploadFileRequest_Data() {} func (*UploadFileRequest_Info) isUploadFileRequest_Data() {}
func (*UploadFileRequest_ChunkData) isUploadFileRequest_Data() {} func (*UploadFileRequest_Chunk) isUploadFileRequest_Data() {}
type UploadFileResponse struct { type UploadFileResponse struct {
state protoimpl.MessageState state protoimpl.MessageState
@ -555,79 +555,137 @@ func (x *Repository) GetDefaultBranch() string {
return "" 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 protoreflect.FileDescriptor
var file_repo_proto_rawDesc = []byte{ var file_repo_proto_rawDesc = []byte{
0x0a, 0x0a, 0x72, 0x65, 0x70, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x03, 0x72, 0x70, 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, 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, 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, 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, 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, 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, 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, 0x48, 0x00, 0x52, 0x08, 0x66, 0x69, 0x6c, 0x65, 0x70, 0x61, 0x74, 0x68, 0x12, 0x22, 0x0a, 0x05,
0x63, 0x68, 0x75, 0x6e, 0x6b, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x63, 0x68, 0x75, 0x6e, 0x6b, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x72, 0x70,
0x48, 0x00, 0x52, 0x09, 0x63, 0x68, 0x75, 0x6e, 0x6b, 0x44, 0x61, 0x74, 0x61, 0x42, 0x06, 0x0a, 0x63, 0x2e, 0x43, 0x68, 0x75, 0x6e, 0x6b, 0x48, 0x00, 0x52, 0x05, 0x63, 0x68, 0x75, 0x6e, 0x6b,
0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x37, 0x0a, 0x18, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x42, 0x06, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x37, 0x0a, 0x18, 0x43, 0x72, 0x65, 0x61,
0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x74, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70,
0x65, 0x12, 0x1b, 0x0a, 0x09, 0x74, 0x65, 0x6d, 0x70, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x18, 0x01, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x74, 0x65, 0x6d, 0x70, 0x5f, 0x70, 0x61, 0x74,
0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x74, 0x65, 0x6d, 0x70, 0x50, 0x61, 0x74, 0x68, 0x22, 0x61, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x74, 0x65, 0x6d, 0x70, 0x50, 0x61, 0x74,
0x0a, 0x11, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x68, 0x22, 0x64, 0x0a, 0x11, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x46, 0x69, 0x6c, 0x65, 0x52,
0x65, 0x73, 0x74, 0x12, 0x23, 0x0a, 0x04, 0x69, 0x6e, 0x66, 0x6f, 0x18, 0x01, 0x20, 0x01, 0x28, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x23, 0x0a, 0x04, 0x69, 0x6e, 0x66, 0x6f, 0x18, 0x01,
0x0b, 0x32, 0x0d, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x46, 0x69, 0x6c, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x46, 0x69, 0x6c, 0x65, 0x49,
0x48, 0x00, 0x52, 0x04, 0x69, 0x6e, 0x66, 0x6f, 0x12, 0x1f, 0x0a, 0x0a, 0x63, 0x68, 0x75, 0x6e, 0x6e, 0x66, 0x6f, 0x48, 0x00, 0x52, 0x04, 0x69, 0x6e, 0x66, 0x6f, 0x12, 0x22, 0x0a, 0x05, 0x63,
0x6b, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x48, 0x00, 0x52, 0x09, 0x68, 0x75, 0x6e, 0x6b, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x72, 0x70, 0x63,
0x63, 0x68, 0x75, 0x6e, 0x6b, 0x44, 0x61, 0x74, 0x61, 0x42, 0x06, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x2e, 0x43, 0x68, 0x75, 0x6e, 0x6b, 0x48, 0x00, 0x52, 0x05, 0x63, 0x68, 0x75, 0x6e, 0x6b, 0x42,
0x61, 0x22, 0x38, 0x0a, 0x12, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x06, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x38, 0x0a, 0x12, 0x55, 0x70, 0x6c, 0x6f, 0x61,
0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x64, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x0e, 0x0a,
0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a,
0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x22, 0xb0, 0x01, 0x0a, 0x08, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x04, 0x73, 0x69, 0x7a,
0x46, 0x69, 0x6c, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x65, 0x22, 0xb0, 0x01, 0x0a, 0x08, 0x46, 0x69, 0x6c, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x0e,
0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1a,
0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09,
0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x72, 0x65, 0x70, 0x6f, 0x18, 0x03, 0x20, 0x01, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x72, 0x65,
0x28, 0x09, 0x52, 0x04, 0x72, 0x65, 0x70, 0x6f, 0x12, 0x16, 0x0a, 0x06, 0x62, 0x72, 0x61, 0x6e, 0x70, 0x6f, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x72, 0x65, 0x70, 0x6f, 0x12, 0x16,
0x63, 0x68, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x0a, 0x06, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06,
0x12, 0x1b, 0x0a, 0x09, 0x72, 0x65, 0x70, 0x6f, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x18, 0x05, 0x20, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x12, 0x1b, 0x0a, 0x09, 0x72, 0x65, 0x70, 0x6f, 0x5f, 0x70,
0x01, 0x28, 0x09, 0x52, 0x08, 0x72, 0x65, 0x70, 0x6f, 0x50, 0x61, 0x74, 0x68, 0x12, 0x12, 0x0a, 0x61, 0x74, 0x68, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x72, 0x65, 0x70, 0x6f, 0x50,
0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, 0x61, 0x74, 0x68, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x06, 0x20, 0x01, 0x28,
0x68, 0x12, 0x1b, 0x0a, 0x09, 0x66, 0x69, 0x6c, 0x65, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x07, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x12, 0x1b, 0x0a, 0x09, 0x66, 0x69, 0x6c, 0x65, 0x5f,
0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x66, 0x69, 0x6c, 0x65, 0x54, 0x79, 0x70, 0x65, 0x22, 0x65, 0x74, 0x79, 0x70, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x66, 0x69, 0x6c, 0x65,
0x0a, 0x16, 0x41, 0x64, 0x64, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x41, 0x6e, 0x64, 0x50, 0x75, 0x73, 0x54, 0x79, 0x70, 0x65, 0x22, 0x65, 0x0a, 0x16, 0x41, 0x64, 0x64, 0x46, 0x69, 0x6c, 0x65, 0x73,
0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x72, 0x65, 0x70, 0x6f, 0x41, 0x6e, 0x64, 0x50, 0x75, 0x73, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1b,
0x5f, 0x70, 0x61, 0x74, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x72, 0x65, 0x70, 0x0a, 0x09, 0x72, 0x65, 0x70, 0x6f, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28,
0x6f, 0x50, 0x61, 0x74, 0x68, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x09, 0x52, 0x08, 0x72, 0x65, 0x70, 0x6f, 0x50, 0x61, 0x74, 0x68, 0x12, 0x18, 0x0a, 0x07, 0x6d,
0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65,
0x14, 0x0a, 0x05, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x05, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x18, 0x03,
0x66, 0x69, 0x6c, 0x65, 0x73, 0x22, 0x19, 0x0a, 0x17, 0x41, 0x64, 0x64, 0x46, 0x69, 0x6c, 0x65, 0x20, 0x03, 0x28, 0x09, 0x52, 0x05, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x22, 0x19, 0x0a, 0x17, 0x41,
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,
0x64, 0x64, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x41, 0x6e, 0x64, 0x50, 0x75, 0x73, 0x68, 0x52, 0x65, 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, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x5d, 0x0a, 0x0a, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69,
0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x3d, 0x0a, 0x06, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x74, 0x6f, 0x72, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x18, 0x01, 0x20,
0x64, 0x12, 0x16, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x46, 0x69, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61,
0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x25,
0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x0a, 0x0e, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x5f, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68,
0x73, 0x65, 0x22, 0x00, 0x28, 0x01, 0x42, 0x27, 0x5a, 0x25, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x42,
0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x68, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2f, 0x67, 0x69, 0x74, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x22, 0x2d, 0x0a, 0x05, 0x43, 0x68, 0x75, 0x6e, 0x6b, 0x12, 0x10,
0x6e, 0x65, 0x73, 0x73, 0x2f, 0x67, 0x69, 0x74, 0x72, 0x70, 0x63, 0x2f, 0x72, 0x70, 0x63, 0x62, 0x0a, 0x03, 0x65, 0x6f, 0x66, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x03, 0x65, 0x6f, 0x66,
0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 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 ( var (
@ -642,7 +700,7 @@ func file_repo_proto_rawDescGZIP() []byte {
return file_repo_proto_rawDescData 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{}{ var file_repo_proto_goTypes = []interface{}{
(*CreateRepositoryRequest)(nil), // 0: rpc.CreateRepositoryRequest (*CreateRepositoryRequest)(nil), // 0: rpc.CreateRepositoryRequest
(*CreateRepositoryResponse)(nil), // 1: rpc.CreateRepositoryResponse (*CreateRepositoryResponse)(nil), // 1: rpc.CreateRepositoryResponse
@ -652,21 +710,24 @@ var file_repo_proto_goTypes = []interface{}{
(*AddFilesAndPushRequest)(nil), // 5: rpc.AddFilesAndPushRequest (*AddFilesAndPushRequest)(nil), // 5: rpc.AddFilesAndPushRequest
(*AddFilesAndPushResponse)(nil), // 6: rpc.AddFilesAndPushResponse (*AddFilesAndPushResponse)(nil), // 6: rpc.AddFilesAndPushResponse
(*Repository)(nil), // 7: rpc.Repository (*Repository)(nil), // 7: rpc.Repository
(*Chunk)(nil), // 8: rpc.Chunk
} }
var file_repo_proto_depIdxs = []int32{ var file_repo_proto_depIdxs = []int32{
7, // 0: rpc.CreateRepositoryRequest.repository:type_name -> rpc.Repository 7, // 0: rpc.CreateRepositoryRequest.repository:type_name -> rpc.Repository
4, // 1: rpc.UploadFileRequest.info:type_name -> rpc.FileInfo 8, // 1: rpc.CreateRepositoryRequest.chunk:type_name -> rpc.Chunk
0, // 2: rpc.RepositoryService.CreateRepository:input_type -> rpc.CreateRepositoryRequest 4, // 2: rpc.UploadFileRequest.info:type_name -> rpc.FileInfo
5, // 3: rpc.RepositoryService.AddFilesAndPush:input_type -> rpc.AddFilesAndPushRequest 8, // 3: rpc.UploadFileRequest.chunk:type_name -> rpc.Chunk
2, // 4: rpc.UploadService.Upload:input_type -> rpc.UploadFileRequest 0, // 4: rpc.RepositoryService.CreateRepository:input_type -> rpc.CreateRepositoryRequest
1, // 5: rpc.RepositoryService.CreateRepository:output_type -> rpc.CreateRepositoryResponse 5, // 5: rpc.RepositoryService.AddFilesAndPush:input_type -> rpc.AddFilesAndPushRequest
6, // 6: rpc.RepositoryService.AddFilesAndPush:output_type -> rpc.AddFilesAndPushResponse 2, // 6: rpc.UploadService.Upload:input_type -> rpc.UploadFileRequest
3, // 7: rpc.UploadService.Upload:output_type -> rpc.UploadFileResponse 1, // 7: rpc.RepositoryService.CreateRepository:output_type -> rpc.CreateRepositoryResponse
5, // [5:8] is the sub-list for method output_type 6, // 8: rpc.RepositoryService.AddFilesAndPush:output_type -> rpc.AddFilesAndPushResponse
2, // [2:5] is the sub-list for method input_type 3, // 9: rpc.UploadService.Upload:output_type -> rpc.UploadFileResponse
2, // [2:2] is the sub-list for extension type_name 7, // [7:10] is the sub-list for method output_type
2, // [2:2] is the sub-list for extension extendee 4, // [4:7] is the sub-list for method input_type
0, // [0:2] is the sub-list for field type_name 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() } func init() { file_repo_proto_init() }
@ -772,15 +833,27 @@ func file_repo_proto_init() {
return nil 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{}{ file_repo_proto_msgTypes[0].OneofWrappers = []interface{}{
(*CreateRepositoryRequest_Repository)(nil), (*CreateRepositoryRequest_Repository)(nil),
(*CreateRepositoryRequest_Filepath)(nil), (*CreateRepositoryRequest_Filepath)(nil),
(*CreateRepositoryRequest_ChunkData)(nil), (*CreateRepositoryRequest_Chunk)(nil),
} }
file_repo_proto_msgTypes[2].OneofWrappers = []interface{}{ file_repo_proto_msgTypes[2].OneofWrappers = []interface{}{
(*UploadFileRequest_Info)(nil), (*UploadFileRequest_Info)(nil),
(*UploadFileRequest_ChunkData)(nil), (*UploadFileRequest_Chunk)(nil),
} }
type x struct{} type x struct{}
out := protoimpl.TypeBuilder{ out := protoimpl.TypeBuilder{
@ -788,7 +861,7 @@ func file_repo_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(), GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_repo_proto_rawDesc, RawDescriptor: file_repo_proto_rawDesc,
NumEnums: 0, NumEnums: 0,
NumMessages: 8, NumMessages: 9,
NumExtensions: 0, NumExtensions: 0,
NumServices: 2, NumServices: 2,
}, },

View File

@ -1,7 +1,7 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT. // Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions: // versions:
// - protoc-gen-go-grpc v1.2.0 // - protoc-gen-go-grpc v1.2.0
// - protoc v3.21.7 // - protoc v3.19.4
// source: repo.proto // source: repo.proto
package rpc package rpc

View File

@ -1,7 +1,7 @@
// Code generated by protoc-gen-go. DO NOT EDIT. // Code generated by protoc-gen-go. DO NOT EDIT.
// versions: // versions:
// protoc-gen-go v1.28.1 // protoc-gen-go v1.27.1
// protoc v3.21.7 // protoc v3.19.4
// source: shared.proto // source: shared.proto
package rpc package rpc

View File

@ -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 package gitrpc
import ( import (

View File

@ -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 package gitrpc
import "time" import "time"

View File

@ -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 package gitrpc
import ( import (
@ -12,7 +16,7 @@ import (
"google.golang.org/grpc/status" "google.golang.org/grpc/status"
) )
const maxImageSize = 1 << 20 const maxFileSize = 1 << 20
type UploadStore interface { type UploadStore interface {
Save(filePath string, data bytes.Buffer) (string, error) 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) return status.Errorf(codes.Unknown, "cannot receive chunk data: %v", err)
} }
chunk := req.GetChunkData() chunk := req.GetChunk()
size := len(chunk) 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 fileSize += size
if fileSize > maxImageSize { if fileSize > maxFileSize {
return status.Errorf(codes.InvalidArgument, "file is too large: %d > %d", fileSize, maxImageSize) 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 { if err != nil {
return status.Errorf(codes.Internal, "cannot write chunk data: %v", err) 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()) log.Info().Msgf("saving file %s in repo path %s", fi.GetPath(), fi.GetRepoPath())
fullPath := filepath.Join(fi.GetRepoPath(), fi.GetPath()) fullPath := filepath.Join(fi.GetRepoPath(), fi.GetPath())
imageID, err := s.store.Save(fullPath, fileData) fileID, err := s.store.Save(fullPath, fileData)
if err != nil { if err != nil {
return status.Errorf(codes.Internal, "cannot save file to the store: %v", err) return status.Errorf(codes.Internal, "cannot save file to the store: %v", err)
} }
res := &rpc.UploadFileResponse{ res := &rpc.UploadFileResponse{
Id: imageID, Id: fileID,
Size: uint32(fileSize), 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) 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 return nil
} }

View File

@ -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 package gitrpc
import "github.com/google/wire" import "github.com/google/wire"

View File

@ -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 package router
import ( import (

View File

@ -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 package router
import ( import (

View File

@ -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 package router
import ( import (

View File

@ -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 package resources
import "embed" import "embed"
@ -6,6 +10,6 @@ var (
//go:embed gitignore //go:embed gitignore
Gitignore embed.FS Gitignore embed.FS
//go:embed licence //go:embed license
Licence embed.FS Licence embed.FS
) )