import pipelines

jobatzil/rename
Marko Gaćeša 2023-09-13 22:41:02 +02:00
parent c128ebace5
commit b78c04e054
21 changed files with 1028 additions and 217 deletions

View File

@ -109,6 +109,7 @@ func initSystem(ctx context.Context, config *types.Config) (*server.System, erro
if err != nil {
return nil, err
}
triggerStore := database.ProvideTriggerStore(db)
encrypter, err := encrypt.ProvideEncrypter(config)
if err != nil {
return nil, err
@ -128,7 +129,7 @@ func initSystem(ctx context.Context, config *types.Config) (*server.System, erro
return nil, err
}
streamer := sse.ProvideEventsStreaming(pubSub)
repository, err := importer.ProvideRepoImporter(config, provider, gitrpcInterface, repoStore, encrypter, jobScheduler, executor, streamer)
repository, err := importer.ProvideRepoImporter(config, provider, gitrpcInterface, db, repoStore, pipelineStore, triggerStore, encrypter, jobScheduler, executor, streamer)
if err != nil {
return nil, err
}
@ -157,7 +158,6 @@ func initSystem(ctx context.Context, config *types.Config) (*server.System, erro
return nil, err
}
spaceController := space.ProvideController(db, provider, streamer, pathUID, authorizer, pathStore, pipelineStore, secretStore, connectorStore, templateStore, spaceStore, repoStore, principalStore, repoController, membershipStore, repository, exporterRepository)
triggerStore := database.ProvideTriggerStore(db)
pipelineController := pipeline.ProvideController(db, pathUID, pathStore, repoStore, triggerStore, authorizer, pipelineStore)
secretController := secret.ProvideController(db, pathUID, pathStore, encrypter, secretStore, authorizer, spaceStore)
triggerController := trigger.ProvideController(db, authorizer, triggerStore, pathUID, pipelineStore, repoStore)

View File

@ -32,6 +32,8 @@ type Interface interface {
SyncRepository(ctx context.Context, params *SyncRepositoryParams) (*SyncRepositoryOutput, error)
MatchFiles(ctx context.Context, params *MatchFilesParams) (*MatchFilesOutput, error)
/*
* Commits service
*/

View File

@ -0,0 +1,55 @@
// 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 gitea
import (
"context"
"errors"
"fmt"
"github.com/harness/gitness/gitrpc/internal/types"
gogit "github.com/go-git/go-git/v5"
gogitplumbing "github.com/go-git/go-git/v5/plumbing"
gogitobject "github.com/go-git/go-git/v5/plumbing/object"
)
func (g Adapter) getGoGitCommit(ctx context.Context,
repoPath string,
rev string,
) (*gogit.Repository, *gogitobject.Commit, error) {
repoEntry, err := g.repoCache.Get(ctx, repoPath)
if err != nil {
return nil, nil, fmt.Errorf("failed to open repository: %w", err)
}
repo := repoEntry.Repo()
var refSHA *gogitplumbing.Hash
if rev == "" {
var head *gogitplumbing.Reference
head, err = repo.Head()
if err != nil {
return nil, nil, fmt.Errorf("failed to get head: %w", err)
}
headHash := head.Hash()
refSHA = &headHash
} else {
refSHA, err = repo.ResolveRevision(gogitplumbing.Revision(rev))
if errors.Is(err, gogitplumbing.ErrReferenceNotFound) {
return nil, nil, types.ErrNotFound
} else if err != nil {
return nil, nil, fmt.Errorf("failed to resolve revision %s: %w", rev, err)
}
}
refCommit, err := repo.CommitObject(*refSHA)
if err != nil {
return nil, nil, fmt.Errorf("failed to load commit data: %w", err)
}
return repo, refCommit, nil
}

View File

@ -0,0 +1,91 @@
// 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 gitea
import (
"context"
"errors"
"fmt"
"github.com/harness/gitness/gitrpc/internal/types"
"io"
"path"
gogitobject "github.com/go-git/go-git/v5/plumbing/object"
)
func (g Adapter) MatchFiles(ctx context.Context,
repoPath string,
ref string,
dirPath string,
pattern string,
maxSize int,
) ([]types.FileContent, error) {
_, refCommit, err := g.getGoGitCommit(ctx, repoPath, ref)
if err != nil {
return nil, err
}
tree, err := refCommit.Tree()
if err != nil {
return nil, fmt.Errorf("failed to get tree for the commit: %w", err)
}
if dirPath != "" {
tree, err = tree.Tree(dirPath)
if errors.Is(err, gogitobject.ErrDirectoryNotFound) {
return nil, types.ErrPathNotFound
}
if err != nil {
return nil, fmt.Errorf("failed to navigate to %s directory: %w", dirPath, err)
}
}
var files []types.FileContent
for _, fileEntry := range tree.Entries {
ok, err := path.Match(pattern, fileEntry.Name)
if err != nil {
return nil, err
}
if !ok {
continue
}
name := fileEntry.Name
f, err := tree.TreeEntryFile(&fileEntry)
if err != nil {
return nil, fmt.Errorf("failed to get tree entry file %s: %w", name, err)
}
reader, err := f.Reader()
if err != nil {
return nil, fmt.Errorf("failed to open tree entry file %s: %w", name, err)
}
filePath := path.Join(dirPath, name)
content, err := func(r io.ReadCloser) ([]byte, error) {
defer func() {
_ = r.Close()
}()
return io.ReadAll(io.LimitReader(reader, int64(maxSize)))
}(reader)
if err != nil {
return nil, fmt.Errorf("failed to read file content %s: %w", name, err)
}
if len(content) == maxSize {
// skip truncated files
continue
}
files = append(files, types.FileContent{
Path: filePath,
Content: content,
})
}
return files, nil
}

View File

@ -19,27 +19,15 @@ import (
// PathsDetails returns additional details about provided the paths.
func (g Adapter) PathsDetails(ctx context.Context,
repoPath string,
rev string,
ref string,
paths []string,
) ([]types.PathDetails, error) {
repoEntry, err := g.repoCache.Get(ctx, repoPath)
repo, refCommit, err := g.getGoGitCommit(ctx, repoPath, ref)
if err != nil {
return nil, fmt.Errorf("failed to open repository: %w", err)
return nil, err
}
repo := repoEntry.Repo()
refSHA, err := repo.ResolveRevision(gogitplumbing.Revision(rev))
if errors.Is(err, gogitplumbing.ErrReferenceNotFound) {
return nil, types.ErrNotFound
} else if err != nil {
return nil, fmt.Errorf("failed to resolve revision %s: %w", rev, err)
}
refCommit, err := repo.CommitObject(*refSHA)
if err != nil {
return nil, fmt.Errorf("failed to load commit data: %w", err)
}
refSHA := refCommit.Hash.String()
tree, err := refCommit.Tree()
if err != nil {
@ -70,7 +58,7 @@ func (g Adapter) PathsDetails(ctx context.Context,
}
}
commitEntry, err := g.lastCommitCache.Get(ctx, makeCommitEntryKey(repoPath, refSHA.String(), path))
commitEntry, err := g.lastCommitCache.Get(ctx, makeCommitEntryKey(repoPath, refSHA, path))
if err != nil {
return nil, fmt.Errorf("failed to find last commit for path %s: %w", path, err)
}

View File

@ -17,7 +17,6 @@ import (
"github.com/harness/gitness/gitrpc/internal/types"
gitea "code.gitea.io/gitea/modules/git"
gogitplumbing "github.com/go-git/go-git/v5/plumbing"
gogitfilemode "github.com/go-git/go-git/v5/plumbing/filemode"
gogitobject "github.com/go-git/go-git/v5/plumbing/object"
)
@ -35,23 +34,9 @@ func (g Adapter) GetTreeNode(ctx context.Context,
) (*types.TreeNode, error) {
treePath = cleanTreePath(treePath)
repoEntry, err := g.repoCache.Get(ctx, repoPath)
_, refCommit, err := g.getGoGitCommit(ctx, repoPath, ref)
if err != nil {
return nil, processGiteaErrorf(err, "failed to open repository")
}
repo := repoEntry.Repo()
refSHA, err := repo.ResolveRevision(gogitplumbing.Revision(ref))
if errors.Is(err, gogitplumbing.ErrReferenceNotFound) {
return nil, types.ErrNotFound
} else if err != nil {
return nil, fmt.Errorf("failed to resolve revision %s: %w", ref, err)
}
refCommit, err := repo.CommitObject(*refSHA)
if err != nil {
return nil, fmt.Errorf("failed to load commit data: %w", err)
return nil, err
}
rootEntry := gogitobject.TreeEntry{
@ -100,23 +85,9 @@ func (g Adapter) ListTreeNodes(ctx context.Context,
) ([]types.TreeNode, error) {
treePath = cleanTreePath(treePath)
repoEntry, err := g.repoCache.Get(ctx, repoPath)
_, refCommit, err := g.getGoGitCommit(ctx, repoPath, ref)
if err != nil {
return nil, processGiteaErrorf(err, "failed to open repository")
}
repo := repoEntry.Repo()
refSHA, err := repo.ResolveRevision(gogitplumbing.Revision(ref))
if errors.Is(err, gogitplumbing.ErrReferenceNotFound) {
return nil, types.ErrNotFound
} else if err != nil {
return nil, fmt.Errorf("failed to resolve revision %s: %w", ref, err)
}
refCommit, err := repo.CommitObject(*refSHA)
if err != nil {
return nil, fmt.Errorf("failed to load commit data: %w", err)
return nil, err
}
tree, err := refCommit.Tree()

View File

@ -88,4 +88,11 @@ type GitAdapter interface {
sourceRef string,
path string,
params types.DiffCutParams) (types.HunkHeader, types.Hunk, error)
MatchFiles(ctx context.Context,
repoPath string,
ref string,
dirPath string,
regExpDef string,
maxSize int) ([]types.FileContent, error)
}

View File

@ -0,0 +1,41 @@
// 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 service
import (
"context"
"github.com/harness/gitness/gitrpc/internal/types"
"github.com/harness/gitness/gitrpc/rpc"
)
func (s RepositoryService) MatchFiles(
ctx context.Context,
request *rpc.MatchFilesRequest,
) (*rpc.MatchFilesResponse, error) {
base := request.GetBase()
if base == nil {
return nil, types.ErrBaseCannotBeEmpty
}
repoPath := getFullPathForRepo(s.reposRoot, base.GetRepoUid())
matchedFiles, err := s.adapter.MatchFiles(ctx, repoPath,
request.Ref, request.DirPath, request.Pattern, int(request.MaxSize))
if err != nil {
return nil, processGitErrorf(err, "failed to open repo")
}
files := make([]*rpc.FileContent, len(matchedFiles))
for i, matchedFile := range matchedFiles {
files[i] = &rpc.FileContent{
Path: matchedFile.Path,
Content: matchedFile.Content,
}
}
return &rpc.MatchFilesResponse{
Files: files,
}, nil
}

View File

@ -5,7 +5,6 @@
package service
import (
"bytes"
"context"
"errors"
"fmt"
@ -55,7 +54,7 @@ var (
)
type Storage interface {
Save(filePath string, data bytes.Buffer) (string, error)
Save(filePath string, data io.Reader) (string, error)
}
type RepositoryService struct {
@ -232,7 +231,7 @@ func (s RepositoryService) createRepositoryInternal(
}
// NOTE: This creates the branch in origin repo (as it doesn't exist as of now)
// TODO: this should at least be a constant and not hardcoded?
if err = s.addFilesAndPush(ctx, tempDir, filePaths, "HEAD:"+defaultBranch, author, authorDate,
if err = s.addFilesAndPush(ctx, tempDir, filePaths, "HEAD:"+defaultBranch, nil, author, authorDate,
committer, committerDate, "origin", "initial commit"); err != nil {
return err
}

View File

@ -27,6 +27,7 @@ func (s RepositoryService) addFilesAndPush(
repoPath string,
filePaths []string,
branch string,
env []string,
author *rpc.Identity,
authorDate time.Time,
committer *rpc.Identity,
@ -62,12 +63,13 @@ func (s RepositoryService) addFilesAndPush(
if err != nil {
return processGitErrorf(err, "failed to commit files")
}
err = s.adapter.Push(ctx, repoPath, types.PushOptions{
// TODO: Don't hard-code
Remote: remote,
Branch: branch,
Force: false,
Env: nil,
Env: env,
Timeout: 0,
})
if err != nil {
@ -129,7 +131,7 @@ func (s RepositoryService) handleFileUploadIfAvailable(ctx context.Context, base
}
fullPath := filepath.Join(basePath, header.Path)
log.Info().Msgf("saving file at path %s", fullPath)
_, err = s.store.Save(fullPath, fileData)
_, err = s.store.Save(fullPath, &fileData)
if err != nil {
return "", status.Errorf(codes.Internal, "cannot save file to the store: %v", err)
}

View File

@ -5,25 +5,19 @@
package storage
import (
"bytes"
"fmt"
"io"
"os"
"path/filepath"
"sync"
)
type LocalStore struct {
mutex sync.RWMutex
files map[string]bool
}
type LocalStore struct{}
func NewLocalStore() *LocalStore {
return &LocalStore{
files: make(map[string]bool),
}
return &LocalStore{}
}
func (store *LocalStore) Save(filePath string, data bytes.Buffer) (string, error) {
func (store *LocalStore) Save(filePath string, data io.Reader) (string, error) {
err := os.MkdirAll(filepath.Dir(filePath), 0o777)
if err != nil {
return "", err
@ -34,15 +28,10 @@ func (store *LocalStore) Save(filePath string, data bytes.Buffer) (string, error
}
defer file.Close()
_, err = data.WriteTo(file)
_, err = io.Copy(file, data)
if err != nil {
return "", fmt.Errorf("cannot write to file: %w", err)
}
store.mutex.Lock()
defer store.mutex.Unlock()
store.files[filePath] = true
return filePath, nil
}

View File

@ -327,3 +327,8 @@ type PathDetails struct {
LastCommit *Commit
Size int64
}
type FileContent struct {
Path string
Content []byte
}

55
gitrpc/match_files.go Normal file
View File

@ -0,0 +1,55 @@
// 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"
"github.com/harness/gitness/gitrpc/rpc"
)
type FileContent struct {
Path string
Content []byte
}
type MatchFilesParams struct {
ReadParams
Ref string
DirPath string
Pattern string
MaxSize int
}
type MatchFilesOutput struct {
Files []FileContent
}
func (c *Client) MatchFiles(ctx context.Context,
params *MatchFilesParams,
) (*MatchFilesOutput, error) {
resp, err := c.repoService.MatchFiles(ctx, &rpc.MatchFilesRequest{
Base: mapToRPCReadRequest(params.ReadParams),
Ref: params.Ref,
DirPath: params.DirPath,
Pattern: params.Pattern,
MaxSize: int32(params.MaxSize),
})
if err != nil {
return nil, processRPCErrorf(err, "failed to match files")
}
files := make([]FileContent, len(resp.Files))
for i, f := range resp.Files {
files[i] = FileContent{
Path: f.Path,
Content: f.Content,
}
}
return &MatchFilesOutput{
Files: files,
}, nil
}

View File

@ -20,6 +20,7 @@ service RepositoryService {
rpc SyncRepository(SyncRepositoryRequest) returns (SyncRepositoryResponse) {}
rpc HashRepository(HashRepositoryRequest) returns (HashRepositoryResponse) {}
rpc MergeBase(MergeBaseRequest) returns (MergeBaseResponse);
rpc MatchFiles(MatchFilesRequest) returns (MatchFilesResponse);
}
message CreateRepositoryRequest {
@ -233,3 +234,20 @@ message MergeBaseRequest {
message MergeBaseResponse {
string merge_base_sha = 1;
}
message FileContent {
string path = 1;
bytes content = 2;
}
message MatchFilesRequest {
ReadRequest base = 1;
string ref = 2;
string dir_path = 3;
string pattern = 4;
int32 max_size = 5;
}
message MatchFilesResponse {
repeated FileContent files = 1;
}

View File

@ -2250,6 +2250,187 @@ func (x *MergeBaseResponse) GetMergeBaseSha() string {
return ""
}
type FileContent struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Path string `protobuf:"bytes,1,opt,name=path,proto3" json:"path,omitempty"`
Content []byte `protobuf:"bytes,2,opt,name=content,proto3" json:"content,omitempty"`
}
func (x *FileContent) Reset() {
*x = FileContent{}
if protoimpl.UnsafeEnabled {
mi := &file_repo_proto_msgTypes[34]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *FileContent) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*FileContent) ProtoMessage() {}
func (x *FileContent) ProtoReflect() protoreflect.Message {
mi := &file_repo_proto_msgTypes[34]
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 FileContent.ProtoReflect.Descriptor instead.
func (*FileContent) Descriptor() ([]byte, []int) {
return file_repo_proto_rawDescGZIP(), []int{34}
}
func (x *FileContent) GetPath() string {
if x != nil {
return x.Path
}
return ""
}
func (x *FileContent) GetContent() []byte {
if x != nil {
return x.Content
}
return nil
}
type MatchFilesRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Base *ReadRequest `protobuf:"bytes,1,opt,name=base,proto3" json:"base,omitempty"`
Ref string `protobuf:"bytes,2,opt,name=ref,proto3" json:"ref,omitempty"`
DirPath string `protobuf:"bytes,3,opt,name=dir_path,json=dirPath,proto3" json:"dir_path,omitempty"`
Pattern string `protobuf:"bytes,4,opt,name=pattern,proto3" json:"pattern,omitempty"`
MaxSize int32 `protobuf:"varint,5,opt,name=max_size,json=maxSize,proto3" json:"max_size,omitempty"`
}
func (x *MatchFilesRequest) Reset() {
*x = MatchFilesRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_repo_proto_msgTypes[35]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *MatchFilesRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*MatchFilesRequest) ProtoMessage() {}
func (x *MatchFilesRequest) ProtoReflect() protoreflect.Message {
mi := &file_repo_proto_msgTypes[35]
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 MatchFilesRequest.ProtoReflect.Descriptor instead.
func (*MatchFilesRequest) Descriptor() ([]byte, []int) {
return file_repo_proto_rawDescGZIP(), []int{35}
}
func (x *MatchFilesRequest) GetBase() *ReadRequest {
if x != nil {
return x.Base
}
return nil
}
func (x *MatchFilesRequest) GetRef() string {
if x != nil {
return x.Ref
}
return ""
}
func (x *MatchFilesRequest) GetDirPath() string {
if x != nil {
return x.DirPath
}
return ""
}
func (x *MatchFilesRequest) GetPattern() string {
if x != nil {
return x.Pattern
}
return ""
}
func (x *MatchFilesRequest) GetMaxSize() int32 {
if x != nil {
return x.MaxSize
}
return 0
}
type MatchFilesResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Files []*FileContent `protobuf:"bytes,1,rep,name=files,proto3" json:"files,omitempty"`
}
func (x *MatchFilesResponse) Reset() {
*x = MatchFilesResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_repo_proto_msgTypes[36]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *MatchFilesResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*MatchFilesResponse) ProtoMessage() {}
func (x *MatchFilesResponse) ProtoReflect() protoreflect.Message {
mi := &file_repo_proto_msgTypes[36]
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 MatchFilesResponse.ProtoReflect.Descriptor instead.
func (*MatchFilesResponse) Descriptor() ([]byte, []int) {
return file_repo_proto_rawDescGZIP(), []int{36}
}
func (x *MatchFilesResponse) GetFiles() []*FileContent {
if x != nil {
return x.Files
}
return nil
}
var File_repo_proto protoreflect.FileDescriptor
var file_repo_proto_rawDesc = []byte{
@ -2475,89 +2656,110 @@ var file_repo_proto_rawDesc = []byte{
0x22, 0x39, 0x0a, 0x11, 0x4d, 0x65, 0x72, 0x67, 0x65, 0x42, 0x61, 0x73, 0x65, 0x52, 0x65, 0x73,
0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x24, 0x0a, 0x0e, 0x6d, 0x65, 0x72, 0x67, 0x65, 0x5f, 0x62,
0x61, 0x73, 0x65, 0x5f, 0x73, 0x68, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x6d,
0x65, 0x72, 0x67, 0x65, 0x42, 0x61, 0x73, 0x65, 0x53, 0x68, 0x61, 0x2a, 0x52, 0x0a, 0x0c, 0x54,
0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x14, 0x0a, 0x10, 0x54,
0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x54, 0x79, 0x70, 0x65, 0x54, 0x72, 0x65, 0x65, 0x10,
0x00, 0x12, 0x14, 0x0a, 0x10, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x54, 0x79, 0x70,
0x65, 0x42, 0x6c, 0x6f, 0x62, 0x10, 0x01, 0x12, 0x16, 0x0a, 0x12, 0x54, 0x72, 0x65, 0x65, 0x4e,
0x6f, 0x64, 0x65, 0x54, 0x79, 0x70, 0x65, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x10, 0x02, 0x2a,
0x81, 0x01, 0x0a, 0x0c, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x4d, 0x6f, 0x64, 0x65,
0x12, 0x14, 0x0a, 0x10, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x4d, 0x6f, 0x64, 0x65,
0x46, 0x69, 0x6c, 0x65, 0x10, 0x00, 0x12, 0x17, 0x0a, 0x13, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f,
0x64, 0x65, 0x4d, 0x6f, 0x64, 0x65, 0x53, 0x79, 0x6d, 0x6c, 0x69, 0x6e, 0x6b, 0x10, 0x01, 0x12,
0x14, 0x0a, 0x10, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x4d, 0x6f, 0x64, 0x65, 0x45,
0x78, 0x65, 0x63, 0x10, 0x02, 0x12, 0x14, 0x0a, 0x10, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64,
0x65, 0x4d, 0x6f, 0x64, 0x65, 0x54, 0x72, 0x65, 0x65, 0x10, 0x03, 0x12, 0x16, 0x0a, 0x12, 0x54,
0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x4d, 0x6f, 0x64, 0x65, 0x43, 0x6f, 0x6d, 0x6d, 0x69,
0x74, 0x10, 0x04, 0x2a, 0x1e, 0x0a, 0x08, 0x48, 0x61, 0x73, 0x68, 0x54, 0x79, 0x70, 0x65, 0x12,
0x12, 0x0a, 0x0e, 0x48, 0x61, 0x73, 0x68, 0x54, 0x79, 0x70, 0x65, 0x53, 0x48, 0x41, 0x32, 0x35,
0x36, 0x10, 0x00, 0x2a, 0x31, 0x0a, 0x13, 0x48, 0x61, 0x73, 0x68, 0x41, 0x67, 0x67, 0x72, 0x65,
0x67, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1a, 0x0a, 0x16, 0x48, 0x61,
0x73, 0x68, 0x41, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x79, 0x70,
0x65, 0x58, 0x4f, 0x52, 0x10, 0x00, 0x32, 0xb8, 0x07, 0x0a, 0x11, 0x52, 0x65, 0x70, 0x6f, 0x73,
0x69, 0x74, 0x6f, 0x72, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x51, 0x0a, 0x10,
0x65, 0x72, 0x67, 0x65, 0x42, 0x61, 0x73, 0x65, 0x53, 0x68, 0x61, 0x22, 0x3b, 0x0a, 0x0b, 0x46,
0x69, 0x6c, 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61,
0x74, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x12, 0x18,
0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52,
0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x22, 0x9b, 0x01, 0x0a, 0x11, 0x4d, 0x61, 0x74,
0x63, 0x68, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x24,
0x0a, 0x04, 0x62, 0x61, 0x73, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72,
0x70, 0x63, 0x2e, 0x52, 0x65, 0x61, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, 0x04,
0x62, 0x61, 0x73, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x72, 0x65, 0x66, 0x18, 0x02, 0x20, 0x01, 0x28,
0x09, 0x52, 0x03, 0x72, 0x65, 0x66, 0x12, 0x19, 0x0a, 0x08, 0x64, 0x69, 0x72, 0x5f, 0x70, 0x61,
0x74, 0x68, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x64, 0x69, 0x72, 0x50, 0x61, 0x74,
0x68, 0x12, 0x18, 0x0a, 0x07, 0x70, 0x61, 0x74, 0x74, 0x65, 0x72, 0x6e, 0x18, 0x04, 0x20, 0x01,
0x28, 0x09, 0x52, 0x07, 0x70, 0x61, 0x74, 0x74, 0x65, 0x72, 0x6e, 0x12, 0x19, 0x0a, 0x08, 0x6d,
0x61, 0x78, 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x6d,
0x61, 0x78, 0x53, 0x69, 0x7a, 0x65, 0x22, 0x3c, 0x0a, 0x12, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x46,
0x69, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x26, 0x0a, 0x05,
0x66, 0x69, 0x6c, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x70,
0x63, 0x2e, 0x46, 0x69, 0x6c, 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x52, 0x05, 0x66,
0x69, 0x6c, 0x65, 0x73, 0x2a, 0x52, 0x0a, 0x0c, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65,
0x54, 0x79, 0x70, 0x65, 0x12, 0x14, 0x0a, 0x10, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65,
0x54, 0x79, 0x70, 0x65, 0x54, 0x72, 0x65, 0x65, 0x10, 0x00, 0x12, 0x14, 0x0a, 0x10, 0x54, 0x72,
0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x54, 0x79, 0x70, 0x65, 0x42, 0x6c, 0x6f, 0x62, 0x10, 0x01,
0x12, 0x16, 0x0a, 0x12, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x54, 0x79, 0x70, 0x65,
0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x10, 0x02, 0x2a, 0x81, 0x01, 0x0a, 0x0c, 0x54, 0x72, 0x65,
0x65, 0x4e, 0x6f, 0x64, 0x65, 0x4d, 0x6f, 0x64, 0x65, 0x12, 0x14, 0x0a, 0x10, 0x54, 0x72, 0x65,
0x65, 0x4e, 0x6f, 0x64, 0x65, 0x4d, 0x6f, 0x64, 0x65, 0x46, 0x69, 0x6c, 0x65, 0x10, 0x00, 0x12,
0x17, 0x0a, 0x13, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x4d, 0x6f, 0x64, 0x65, 0x53,
0x79, 0x6d, 0x6c, 0x69, 0x6e, 0x6b, 0x10, 0x01, 0x12, 0x14, 0x0a, 0x10, 0x54, 0x72, 0x65, 0x65,
0x4e, 0x6f, 0x64, 0x65, 0x4d, 0x6f, 0x64, 0x65, 0x45, 0x78, 0x65, 0x63, 0x10, 0x02, 0x12, 0x14,
0x0a, 0x10, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x4d, 0x6f, 0x64, 0x65, 0x54, 0x72,
0x65, 0x65, 0x10, 0x03, 0x12, 0x16, 0x0a, 0x12, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65,
0x4d, 0x6f, 0x64, 0x65, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x10, 0x04, 0x2a, 0x1e, 0x0a, 0x08,
0x48, 0x61, 0x73, 0x68, 0x54, 0x79, 0x70, 0x65, 0x12, 0x12, 0x0a, 0x0e, 0x48, 0x61, 0x73, 0x68,
0x54, 0x79, 0x70, 0x65, 0x53, 0x48, 0x41, 0x32, 0x35, 0x36, 0x10, 0x00, 0x2a, 0x31, 0x0a, 0x13,
0x48, 0x61, 0x73, 0x68, 0x41, 0x67, 0x67, 0x72, 0x65, 0x67, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x54,
0x79, 0x70, 0x65, 0x12, 0x1a, 0x0a, 0x16, 0x48, 0x61, 0x73, 0x68, 0x41, 0x67, 0x67, 0x72, 0x65,
0x67, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x58, 0x4f, 0x52, 0x10, 0x00, 0x32,
0xf7, 0x07, 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,
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,
0x40, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x12, 0x17,
0x2e, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65,
0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65,
0x74, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
0x65, 0x12, 0x48, 0x0a, 0x0d, 0x4c, 0x69, 0x73, 0x74, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64,
0x65, 0x73, 0x12, 0x19, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x54, 0x72, 0x65,
0x65, 0x4e, 0x6f, 0x64, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e,
0x72, 0x70, 0x63, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65,
0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x30, 0x01, 0x12, 0x43, 0x0a, 0x0c, 0x50,
0x61, 0x74, 0x68, 0x73, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x12, 0x18, 0x2e, 0x72, 0x70,
0x63, 0x2e, 0x50, 0x61, 0x74, 0x68, 0x73, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x52, 0x65,
0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x50, 0x61, 0x74, 0x68,
0x73, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
0x12, 0x43, 0x0a, 0x0c, 0x47, 0x65, 0x74, 0x53, 0x75, 0x62, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65,
0x12, 0x18, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x75, 0x62, 0x6d, 0x6f, 0x64,
0x75, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x72, 0x70, 0x63,
0x2e, 0x47, 0x65, 0x74, 0x53, 0x75, 0x62, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x52, 0x65, 0x73,
0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x36, 0x0a, 0x07, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x62,
0x12, 0x13, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x62, 0x52, 0x65,
0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x42,
0x6c, 0x6f, 0x62, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x30, 0x01, 0x12, 0x42, 0x0a,
0x0b, 0x4c, 0x69, 0x73, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x73, 0x12, 0x17, 0x2e, 0x72,
0x70, 0x63, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x73, 0x52, 0x65,
0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x4c, 0x69, 0x73, 0x74,
0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x30,
0x01, 0x12, 0x3a, 0x0a, 0x09, 0x47, 0x65, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x12, 0x15,
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, 0x40, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x54,
0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x12, 0x17, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65,
0x74, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
0x1a, 0x18, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f,
0x64, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x48, 0x0a, 0x0d, 0x4c, 0x69,
0x73, 0x74, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x73, 0x12, 0x19, 0x2e, 0x72, 0x70,
0x63, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x73, 0x52,
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x4c, 0x69, 0x73,
0x74, 0x54, 0x72, 0x65, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
0x73, 0x65, 0x30, 0x01, 0x12, 0x43, 0x0a, 0x0c, 0x50, 0x61, 0x74, 0x68, 0x73, 0x44, 0x65, 0x74,
0x61, 0x69, 0x6c, 0x73, 0x12, 0x18, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x50, 0x61, 0x74, 0x68, 0x73,
0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19,
0x2e, 0x72, 0x70, 0x63, 0x2e, 0x50, 0x61, 0x74, 0x68, 0x73, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c,
0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x43, 0x0a, 0x0c, 0x47, 0x65, 0x74,
0x53, 0x75, 0x62, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x12, 0x18, 0x2e, 0x72, 0x70, 0x63, 0x2e,
0x47, 0x65, 0x74, 0x53, 0x75, 0x62, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75,
0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x75, 0x62,
0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x36,
0x0a, 0x07, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x62, 0x12, 0x13, 0x2e, 0x72, 0x70, 0x63, 0x2e,
0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x62, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14,
0x2e, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x42, 0x6c, 0x6f, 0x62, 0x52, 0x65, 0x73, 0x70,
0x6f, 0x6e, 0x73, 0x65, 0x30, 0x01, 0x12, 0x42, 0x0a, 0x0b, 0x4c, 0x69, 0x73, 0x74, 0x43, 0x6f,
0x6d, 0x6d, 0x69, 0x74, 0x73, 0x12, 0x17, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x4c, 0x69, 0x73, 0x74,
0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18,
0x2e, 0x72, 0x70, 0x63, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x73,
0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x30, 0x01, 0x12, 0x3a, 0x0a, 0x09, 0x47, 0x65,
0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x12, 0x15, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65,
0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16,
0x2e, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x52, 0x65,
0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x43,
0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x5b, 0x0a,
0x14, 0x47, 0x65, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x44, 0x69, 0x76, 0x65, 0x72, 0x67,
0x65, 0x6e, 0x63, 0x65, 0x73, 0x12, 0x20, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x43,
0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x44, 0x69, 0x76, 0x65, 0x72, 0x67, 0x65, 0x6e, 0x63, 0x65, 0x73,
0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x21, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65,
0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x44, 0x69, 0x76, 0x65, 0x72, 0x67, 0x65, 0x6e, 0x63,
0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x4f, 0x0a, 0x10, 0x44, 0x65,
0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x12, 0x1c,
0x2e, 0x72, 0x70, 0x63, 0x2e, 0x44, 0x65, 0x6c, 0x65, 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, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74,
0x6f, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x4b, 0x0a, 0x0e, 0x53,
0x79, 0x6e, 0x63, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x12, 0x1a, 0x2e,
0x72, 0x70, 0x63, 0x2e, 0x53, 0x79, 0x6e, 0x63, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f,
0x72, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x72, 0x70, 0x63, 0x2e,
0x53, 0x79, 0x6e, 0x63, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x52, 0x65,
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x4b, 0x0a, 0x0e, 0x48, 0x61, 0x73, 0x68,
0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x12, 0x1a, 0x2e, 0x72, 0x70, 0x63,
0x2e, 0x48, 0x61, 0x73, 0x68, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x52,
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x48, 0x61, 0x73,
0x68, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f,
0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x3a, 0x0a, 0x09, 0x4d, 0x65, 0x72, 0x67, 0x65, 0x42, 0x61,
0x73, 0x65, 0x12, 0x15, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x4d, 0x65, 0x72, 0x67, 0x65, 0x42, 0x61,
0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x72, 0x70, 0x63, 0x2e,
0x4d, 0x65, 0x72, 0x67, 0x65, 0x42, 0x61, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
0x65, 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, 0x12, 0x5b, 0x0a, 0x14, 0x47, 0x65, 0x74, 0x43, 0x6f, 0x6d,
0x6d, 0x69, 0x74, 0x44, 0x69, 0x76, 0x65, 0x72, 0x67, 0x65, 0x6e, 0x63, 0x65, 0x73, 0x12, 0x20,
0x2e, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x44, 0x69,
0x76, 0x65, 0x72, 0x67, 0x65, 0x6e, 0x63, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
0x1a, 0x21, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74,
0x44, 0x69, 0x76, 0x65, 0x72, 0x67, 0x65, 0x6e, 0x63, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f,
0x6e, 0x73, 0x65, 0x12, 0x4f, 0x0a, 0x10, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x70,
0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x12, 0x1c, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x44, 0x65,
0x6c, 0x65, 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, 0x44, 0x65, 0x6c, 0x65,
0x74, 0x65, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70,
0x6f, 0x6e, 0x73, 0x65, 0x12, 0x4b, 0x0a, 0x0e, 0x53, 0x79, 0x6e, 0x63, 0x52, 0x65, 0x70, 0x6f,
0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x12, 0x1a, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x53, 0x79, 0x6e,
0x63, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65,
0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x53, 0x79, 0x6e, 0x63, 0x52, 0x65, 0x70,
0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22,
0x00, 0x12, 0x4b, 0x0a, 0x0e, 0x48, 0x61, 0x73, 0x68, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74,
0x6f, 0x72, 0x79, 0x12, 0x1a, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x48, 0x61, 0x73, 0x68, 0x52, 0x65,
0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a,
0x1b, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x48, 0x61, 0x73, 0x68, 0x52, 0x65, 0x70, 0x6f, 0x73, 0x69,
0x74, 0x6f, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x3a,
0x0a, 0x09, 0x4d, 0x65, 0x72, 0x67, 0x65, 0x42, 0x61, 0x73, 0x65, 0x12, 0x15, 0x2e, 0x72, 0x70,
0x63, 0x2e, 0x4d, 0x65, 0x72, 0x67, 0x65, 0x42, 0x61, 0x73, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65,
0x73, 0x74, 0x1a, 0x16, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x4d, 0x65, 0x72, 0x67, 0x65, 0x42, 0x61,
0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3d, 0x0a, 0x0a, 0x4d, 0x61,
0x74, 0x63, 0x68, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x12, 0x16, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x4d,
0x61, 0x74, 0x63, 0x68, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
0x1a, 0x17, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x46, 0x69, 0x6c, 0x65,
0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 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 (
@ -2573,7 +2775,7 @@ func file_repo_proto_rawDescGZIP() []byte {
}
var file_repo_proto_enumTypes = make([]protoimpl.EnumInfo, 4)
var file_repo_proto_msgTypes = make([]protoimpl.MessageInfo, 34)
var file_repo_proto_msgTypes = make([]protoimpl.MessageInfo, 37)
var file_repo_proto_goTypes = []interface{}{
(TreeNodeType)(0), // 0: rpc.TreeNodeType
(TreeNodeMode)(0), // 1: rpc.TreeNodeMode
@ -2613,77 +2815,84 @@ var file_repo_proto_goTypes = []interface{}{
(*HashRepositoryResponse)(nil), // 35: rpc.HashRepositoryResponse
(*MergeBaseRequest)(nil), // 36: rpc.MergeBaseRequest
(*MergeBaseResponse)(nil), // 37: rpc.MergeBaseResponse
(*FileUpload)(nil), // 38: rpc.FileUpload
(*WriteRequest)(nil), // 39: rpc.WriteRequest
(*Identity)(nil), // 40: rpc.Identity
(*ReadRequest)(nil), // 41: rpc.ReadRequest
(*Commit)(nil), // 42: rpc.Commit
(*FileContent)(nil), // 38: rpc.FileContent
(*MatchFilesRequest)(nil), // 39: rpc.MatchFilesRequest
(*MatchFilesResponse)(nil), // 40: rpc.MatchFilesResponse
(*FileUpload)(nil), // 41: rpc.FileUpload
(*WriteRequest)(nil), // 42: rpc.WriteRequest
(*Identity)(nil), // 43: rpc.Identity
(*ReadRequest)(nil), // 44: rpc.ReadRequest
(*Commit)(nil), // 45: rpc.Commit
}
var file_repo_proto_depIdxs = []int32{
5, // 0: rpc.CreateRepositoryRequest.header:type_name -> rpc.CreateRepositoryRequestHeader
38, // 1: rpc.CreateRepositoryRequest.file:type_name -> rpc.FileUpload
39, // 2: rpc.CreateRepositoryRequestHeader.base:type_name -> rpc.WriteRequest
40, // 3: rpc.CreateRepositoryRequestHeader.author:type_name -> rpc.Identity
40, // 4: rpc.CreateRepositoryRequestHeader.committer:type_name -> rpc.Identity
41, // 5: rpc.GetTreeNodeRequest.base:type_name -> rpc.ReadRequest
41, // 1: rpc.CreateRepositoryRequest.file:type_name -> rpc.FileUpload
42, // 2: rpc.CreateRepositoryRequestHeader.base:type_name -> rpc.WriteRequest
43, // 3: rpc.CreateRepositoryRequestHeader.author:type_name -> rpc.Identity
43, // 4: rpc.CreateRepositoryRequestHeader.committer:type_name -> rpc.Identity
44, // 5: rpc.GetTreeNodeRequest.base:type_name -> rpc.ReadRequest
11, // 6: rpc.GetTreeNodeResponse.node:type_name -> rpc.TreeNode
42, // 7: rpc.GetTreeNodeResponse.commit:type_name -> rpc.Commit
41, // 8: rpc.ListTreeNodesRequest.base:type_name -> rpc.ReadRequest
45, // 7: rpc.GetTreeNodeResponse.commit:type_name -> rpc.Commit
44, // 8: rpc.ListTreeNodesRequest.base:type_name -> rpc.ReadRequest
11, // 9: rpc.ListTreeNodesResponse.node:type_name -> rpc.TreeNode
0, // 10: rpc.TreeNode.type:type_name -> rpc.TreeNodeType
1, // 11: rpc.TreeNode.mode:type_name -> rpc.TreeNodeMode
41, // 12: rpc.PathsDetailsRequest.base:type_name -> rpc.ReadRequest
44, // 12: rpc.PathsDetailsRequest.base:type_name -> rpc.ReadRequest
14, // 13: rpc.PathsDetailsResponse.path_details:type_name -> rpc.PathDetails
42, // 14: rpc.PathDetails.last_commit:type_name -> rpc.Commit
41, // 15: rpc.GetCommitRequest.base:type_name -> rpc.ReadRequest
42, // 16: rpc.GetCommitResponse.commit:type_name -> rpc.Commit
41, // 17: rpc.ListCommitsRequest.base:type_name -> rpc.ReadRequest
42, // 18: rpc.ListCommitsResponse.commit:type_name -> rpc.Commit
45, // 14: rpc.PathDetails.last_commit:type_name -> rpc.Commit
44, // 15: rpc.GetCommitRequest.base:type_name -> rpc.ReadRequest
45, // 16: rpc.GetCommitResponse.commit:type_name -> rpc.Commit
44, // 17: rpc.ListCommitsRequest.base:type_name -> rpc.ReadRequest
45, // 18: rpc.ListCommitsResponse.commit:type_name -> rpc.Commit
19, // 19: rpc.ListCommitsResponse.rename_details:type_name -> rpc.RenameDetails
41, // 20: rpc.GetBlobRequest.base:type_name -> rpc.ReadRequest
44, // 20: rpc.GetBlobRequest.base:type_name -> rpc.ReadRequest
22, // 21: rpc.GetBlobResponse.header:type_name -> rpc.GetBlobResponseHeader
41, // 22: rpc.GetSubmoduleRequest.base:type_name -> rpc.ReadRequest
44, // 22: rpc.GetSubmoduleRequest.base:type_name -> rpc.ReadRequest
25, // 23: rpc.GetSubmoduleResponse.submodule:type_name -> rpc.Submodule
41, // 24: rpc.GetCommitDivergencesRequest.base:type_name -> rpc.ReadRequest
44, // 24: rpc.GetCommitDivergencesRequest.base:type_name -> rpc.ReadRequest
27, // 25: rpc.GetCommitDivergencesRequest.requests:type_name -> rpc.CommitDivergenceRequest
29, // 26: rpc.GetCommitDivergencesResponse.divergences:type_name -> rpc.CommitDivergence
39, // 27: rpc.DeleteRepositoryRequest.base:type_name -> rpc.WriteRequest
39, // 28: rpc.SyncRepositoryRequest.base:type_name -> rpc.WriteRequest
41, // 29: rpc.HashRepositoryRequest.base:type_name -> rpc.ReadRequest
42, // 27: rpc.DeleteRepositoryRequest.base:type_name -> rpc.WriteRequest
42, // 28: rpc.SyncRepositoryRequest.base:type_name -> rpc.WriteRequest
44, // 29: rpc.HashRepositoryRequest.base:type_name -> rpc.ReadRequest
2, // 30: rpc.HashRepositoryRequest.hash_type:type_name -> rpc.HashType
3, // 31: rpc.HashRepositoryRequest.aggregation_type:type_name -> rpc.HashAggregationType
41, // 32: rpc.MergeBaseRequest.base:type_name -> rpc.ReadRequest
4, // 33: rpc.RepositoryService.CreateRepository:input_type -> rpc.CreateRepositoryRequest
7, // 34: rpc.RepositoryService.GetTreeNode:input_type -> rpc.GetTreeNodeRequest
9, // 35: rpc.RepositoryService.ListTreeNodes:input_type -> rpc.ListTreeNodesRequest
12, // 36: rpc.RepositoryService.PathsDetails:input_type -> rpc.PathsDetailsRequest
23, // 37: rpc.RepositoryService.GetSubmodule:input_type -> rpc.GetSubmoduleRequest
20, // 38: rpc.RepositoryService.GetBlob:input_type -> rpc.GetBlobRequest
17, // 39: rpc.RepositoryService.ListCommits:input_type -> rpc.ListCommitsRequest
15, // 40: rpc.RepositoryService.GetCommit:input_type -> rpc.GetCommitRequest
26, // 41: rpc.RepositoryService.GetCommitDivergences:input_type -> rpc.GetCommitDivergencesRequest
30, // 42: rpc.RepositoryService.DeleteRepository:input_type -> rpc.DeleteRepositoryRequest
32, // 43: rpc.RepositoryService.SyncRepository:input_type -> rpc.SyncRepositoryRequest
34, // 44: rpc.RepositoryService.HashRepository:input_type -> rpc.HashRepositoryRequest
36, // 45: rpc.RepositoryService.MergeBase:input_type -> rpc.MergeBaseRequest
6, // 46: rpc.RepositoryService.CreateRepository:output_type -> rpc.CreateRepositoryResponse
8, // 47: rpc.RepositoryService.GetTreeNode:output_type -> rpc.GetTreeNodeResponse
10, // 48: rpc.RepositoryService.ListTreeNodes:output_type -> rpc.ListTreeNodesResponse
13, // 49: rpc.RepositoryService.PathsDetails:output_type -> rpc.PathsDetailsResponse
24, // 50: rpc.RepositoryService.GetSubmodule:output_type -> rpc.GetSubmoduleResponse
21, // 51: rpc.RepositoryService.GetBlob:output_type -> rpc.GetBlobResponse
18, // 52: rpc.RepositoryService.ListCommits:output_type -> rpc.ListCommitsResponse
16, // 53: rpc.RepositoryService.GetCommit:output_type -> rpc.GetCommitResponse
28, // 54: rpc.RepositoryService.GetCommitDivergences:output_type -> rpc.GetCommitDivergencesResponse
31, // 55: rpc.RepositoryService.DeleteRepository:output_type -> rpc.DeleteRepositoryResponse
33, // 56: rpc.RepositoryService.SyncRepository:output_type -> rpc.SyncRepositoryResponse
35, // 57: rpc.RepositoryService.HashRepository:output_type -> rpc.HashRepositoryResponse
37, // 58: rpc.RepositoryService.MergeBase:output_type -> rpc.MergeBaseResponse
46, // [46:59] is the sub-list for method output_type
33, // [33:46] is the sub-list for method input_type
33, // [33:33] is the sub-list for extension type_name
33, // [33:33] is the sub-list for extension extendee
0, // [0:33] is the sub-list for field type_name
44, // 32: rpc.MergeBaseRequest.base:type_name -> rpc.ReadRequest
44, // 33: rpc.MatchFilesRequest.base:type_name -> rpc.ReadRequest
38, // 34: rpc.MatchFilesResponse.files:type_name -> rpc.FileContent
4, // 35: rpc.RepositoryService.CreateRepository:input_type -> rpc.CreateRepositoryRequest
7, // 36: rpc.RepositoryService.GetTreeNode:input_type -> rpc.GetTreeNodeRequest
9, // 37: rpc.RepositoryService.ListTreeNodes:input_type -> rpc.ListTreeNodesRequest
12, // 38: rpc.RepositoryService.PathsDetails:input_type -> rpc.PathsDetailsRequest
23, // 39: rpc.RepositoryService.GetSubmodule:input_type -> rpc.GetSubmoduleRequest
20, // 40: rpc.RepositoryService.GetBlob:input_type -> rpc.GetBlobRequest
17, // 41: rpc.RepositoryService.ListCommits:input_type -> rpc.ListCommitsRequest
15, // 42: rpc.RepositoryService.GetCommit:input_type -> rpc.GetCommitRequest
26, // 43: rpc.RepositoryService.GetCommitDivergences:input_type -> rpc.GetCommitDivergencesRequest
30, // 44: rpc.RepositoryService.DeleteRepository:input_type -> rpc.DeleteRepositoryRequest
32, // 45: rpc.RepositoryService.SyncRepository:input_type -> rpc.SyncRepositoryRequest
34, // 46: rpc.RepositoryService.HashRepository:input_type -> rpc.HashRepositoryRequest
36, // 47: rpc.RepositoryService.MergeBase:input_type -> rpc.MergeBaseRequest
39, // 48: rpc.RepositoryService.MatchFiles:input_type -> rpc.MatchFilesRequest
6, // 49: rpc.RepositoryService.CreateRepository:output_type -> rpc.CreateRepositoryResponse
8, // 50: rpc.RepositoryService.GetTreeNode:output_type -> rpc.GetTreeNodeResponse
10, // 51: rpc.RepositoryService.ListTreeNodes:output_type -> rpc.ListTreeNodesResponse
13, // 52: rpc.RepositoryService.PathsDetails:output_type -> rpc.PathsDetailsResponse
24, // 53: rpc.RepositoryService.GetSubmodule:output_type -> rpc.GetSubmoduleResponse
21, // 54: rpc.RepositoryService.GetBlob:output_type -> rpc.GetBlobResponse
18, // 55: rpc.RepositoryService.ListCommits:output_type -> rpc.ListCommitsResponse
16, // 56: rpc.RepositoryService.GetCommit:output_type -> rpc.GetCommitResponse
28, // 57: rpc.RepositoryService.GetCommitDivergences:output_type -> rpc.GetCommitDivergencesResponse
31, // 58: rpc.RepositoryService.DeleteRepository:output_type -> rpc.DeleteRepositoryResponse
33, // 59: rpc.RepositoryService.SyncRepository:output_type -> rpc.SyncRepositoryResponse
35, // 60: rpc.RepositoryService.HashRepository:output_type -> rpc.HashRepositoryResponse
37, // 61: rpc.RepositoryService.MergeBase:output_type -> rpc.MergeBaseResponse
40, // 62: rpc.RepositoryService.MatchFiles:output_type -> rpc.MatchFilesResponse
49, // [49:63] is the sub-list for method output_type
35, // [35:49] is the sub-list for method input_type
35, // [35:35] is the sub-list for extension type_name
35, // [35:35] is the sub-list for extension extendee
0, // [0:35] is the sub-list for field type_name
}
func init() { file_repo_proto_init() }
@ -3101,6 +3310,42 @@ func file_repo_proto_init() {
return nil
}
}
file_repo_proto_msgTypes[34].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*FileContent); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_repo_proto_msgTypes[35].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*MatchFilesRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_repo_proto_msgTypes[36].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*MatchFilesResponse); 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_Header)(nil),
@ -3116,7 +3361,7 @@ func file_repo_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_repo_proto_rawDesc,
NumEnums: 4,
NumMessages: 34,
NumMessages: 37,
NumExtensions: 0,
NumServices: 1,
},

View File

@ -35,6 +35,7 @@ type RepositoryServiceClient interface {
SyncRepository(ctx context.Context, in *SyncRepositoryRequest, opts ...grpc.CallOption) (*SyncRepositoryResponse, error)
HashRepository(ctx context.Context, in *HashRepositoryRequest, opts ...grpc.CallOption) (*HashRepositoryResponse, error)
MergeBase(ctx context.Context, in *MergeBaseRequest, opts ...grpc.CallOption) (*MergeBaseResponse, error)
MatchFiles(ctx context.Context, in *MatchFilesRequest, opts ...grpc.CallOption) (*MatchFilesResponse, error)
}
type repositoryServiceClient struct {
@ -256,6 +257,15 @@ func (c *repositoryServiceClient) MergeBase(ctx context.Context, in *MergeBaseRe
return out, nil
}
func (c *repositoryServiceClient) MatchFiles(ctx context.Context, in *MatchFilesRequest, opts ...grpc.CallOption) (*MatchFilesResponse, error) {
out := new(MatchFilesResponse)
err := c.cc.Invoke(ctx, "/rpc.RepositoryService/MatchFiles", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// RepositoryServiceServer is the server API for RepositoryService service.
// All implementations must embed UnimplementedRepositoryServiceServer
// for forward compatibility
@ -273,6 +283,7 @@ type RepositoryServiceServer interface {
SyncRepository(context.Context, *SyncRepositoryRequest) (*SyncRepositoryResponse, error)
HashRepository(context.Context, *HashRepositoryRequest) (*HashRepositoryResponse, error)
MergeBase(context.Context, *MergeBaseRequest) (*MergeBaseResponse, error)
MatchFiles(context.Context, *MatchFilesRequest) (*MatchFilesResponse, error)
mustEmbedUnimplementedRepositoryServiceServer()
}
@ -319,6 +330,9 @@ func (UnimplementedRepositoryServiceServer) HashRepository(context.Context, *Has
func (UnimplementedRepositoryServiceServer) MergeBase(context.Context, *MergeBaseRequest) (*MergeBaseResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method MergeBase not implemented")
}
func (UnimplementedRepositoryServiceServer) MatchFiles(context.Context, *MatchFilesRequest) (*MatchFilesResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method MatchFiles not implemented")
}
func (UnimplementedRepositoryServiceServer) mustEmbedUnimplementedRepositoryServiceServer() {}
// UnsafeRepositoryServiceServer may be embedded to opt out of forward compatibility for this service.
@ -583,6 +597,24 @@ func _RepositoryService_MergeBase_Handler(srv interface{}, ctx context.Context,
return interceptor(ctx, in, info, handler)
}
func _RepositoryService_MatchFiles_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(MatchFilesRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(RepositoryServiceServer).MatchFiles(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/rpc.RepositoryService/MatchFiles",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(RepositoryServiceServer).MatchFiles(ctx, req.(*MatchFilesRequest))
}
return interceptor(ctx, in, info, handler)
}
// RepositoryService_ServiceDesc is the grpc.ServiceDesc for RepositoryService service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
@ -626,6 +658,10 @@ var RepositoryService_ServiceDesc = grpc.ServiceDesc{
MethodName: "MergeBase",
Handler: _RepositoryService_MergeBase_Handler,
},
{
MethodName: "MatchFiles",
Handler: _RepositoryService_MatchFiles_Handler,
},
},
Streams: []grpc.StreamDesc{
{

13
go.mod
View File

@ -27,7 +27,7 @@ require (
github.com/google/go-cmp v0.5.9
github.com/google/wire v0.5.0
github.com/gorhill/cronexpr v0.0.0-20180427100037-88b0669f7d75
github.com/gotidy/ptr v1.3.0
github.com/gotidy/ptr v1.4.0
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0
github.com/guregu/null v4.0.0+incompatible
github.com/harness/go-rbac v0.0.0-20230829014129-c9b217856ea2
@ -56,7 +56,7 @@ require (
golang.org/x/exp v0.0.0-20230108222341-4b8118a2686a
golang.org/x/sync v0.1.0
golang.org/x/term v0.6.0
golang.org/x/text v0.8.0
golang.org/x/text v0.13.0
google.golang.org/grpc v1.55.0
google.golang.org/protobuf v1.30.0
gopkg.in/alecthomas/kingpin.v2 v2.2.6
@ -66,16 +66,19 @@ require (
cloud.google.com/go v0.110.0 // indirect
cloud.google.com/go/compute v1.18.0 // indirect
cloud.google.com/go/compute/metadata v0.2.3 // indirect
dario.cat/mergo v1.0.0 // indirect
github.com/99designs/httpsignatures-go v0.0.0-20170731043157-88528bf4ca7e // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bmatcuk/doublestar v1.1.1 // indirect
github.com/bmatcuk/doublestar v1.3.4 // indirect
github.com/buildkite/yaml v2.1.0+incompatible // indirect
github.com/containerd/containerd v1.3.4 // indirect
github.com/docker/distribution v2.7.1+incompatible // indirect
github.com/docker/docker v0.0.0-00010101000000-000000000000 // indirect
github.com/docker/go-connections v0.3.0 // indirect
github.com/docker/go-units v0.4.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/drone/envsubst v1.0.3 // indirect
github.com/drone/go-convert v0.0.0-20230913194237-2228eb829d0e // indirect
github.com/drone/spec v0.0.0-20230913142424-983cda6e1ef2 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/ghodss/yaml v1.0.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
@ -127,7 +130,7 @@ require (
github.com/golang-jwt/jwt/v4 v4.4.1 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/pprof v0.0.0-20221103000818-d260c55eee4c // indirect
github.com/google/subcommands v1.0.1 // indirect
github.com/google/subcommands v1.2.0 // indirect
github.com/hashicorp/errwrap v1.0.0 // indirect
github.com/hashicorp/go-version v1.4.0 // indirect
github.com/imdario/mergo v0.3.12 // indirect

20
go.sum
View File

@ -13,6 +13,8 @@ cloud.google.com/go/profiler v0.3.1/go.mod h1:GsG14VnmcMFQ9b+kq71wh3EKMZr3WRMgLz
cloud.google.com/go/storage v1.28.1 h1:F5QDG5ChchaAVQhINh24U99OWHURqrW8OmQcGKXcbgI=
code.gitea.io/gitea v1.17.2 h1:NRcVr07jF+za4d0NZZlJXeCuQK5FfHMtjPDjq4u3UiY=
code.gitea.io/gitea v1.17.2/go.mod h1:sovminOoSsc8IC2T29rX9+MmaboHTu8QDEvJjaSqIXg=
dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk=
dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk=
docker.io/go-docker v1.0.0/go.mod h1:7tiAn5a0LFmjbPDbyTPOaTTOuG1ZRNXdPA6RvKY+fpY=
github.com/99designs/basicauth-go v0.0.0-20160802081356-2a93ba0f464d/go.mod h1:3cARGAK9CfW3HoxCy1a0G4TKrdiKke8ftOMEOHyySYs=
github.com/99designs/httpsignatures-go v0.0.0-20170731043157-88528bf4ca7e h1:rl2Aq4ZODqTDkeSqQBy+fzpZPamacO1Srp8zq7jf2Sc=
@ -72,6 +74,8 @@ github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6r
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
github.com/bmatcuk/doublestar v1.1.1 h1:YroD6BJCZBYx06yYFEWvUuKVWQn3vLLQAVmDmvTSaiQ=
github.com/bmatcuk/doublestar v1.1.1/go.mod h1:UD6OnuiIn0yFxxA2le/rnRU1G4RaI4UvFv1sNto9p6w=
github.com/bmatcuk/doublestar v1.3.4 h1:gPypJ5xD31uhX6Tf54sDPUOBXTqKH4c9aPY66CyQrS0=
github.com/bmatcuk/doublestar v1.3.4/go.mod h1:wiQtGV+rzVYxB7WIlirSN++5HPtPlXEo9MEoZQC/PmE=
github.com/bool64/dev v0.1.41/go.mod h1:cTHiTDNc8EewrQPy3p1obNilpMpdmlUesDkFTF2zRWU=
github.com/bool64/dev v0.1.42/go.mod h1:cTHiTDNc8EewrQPy3p1obNilpMpdmlUesDkFTF2zRWU=
github.com/bool64/dev v0.2.22 h1:YJFKBRKplkt+0Emq/5Xk1Z5QRmMNzc1UOJkR3rxJksA=
@ -132,6 +136,8 @@ github.com/docker/go-connections v0.3.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5Xh
github.com/docker/go-units v0.3.3/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
github.com/docker/go-units v0.4.0 h1:3uh0PgVws3nIA0Q+MwDC8yjEPf9zjRfZZWXZYDct3Tw=
github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4=
github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
github.com/drone-runners/drone-runner-docker v1.8.3 h1:uUnC45C1JMSLW+9uy6RoKG5ugzeXWN89pygs9BMLObY=
github.com/drone-runners/drone-runner-docker v1.8.3/go.mod h1:JR3pZeVZKKpkbTajiq0YtAx9WutkODdVKZGNR83kEwE=
github.com/drone/drone-go v1.7.1 h1:ZX+3Rs8YHUSUQ5mkuMLmm1zr1ttiiE2YGNxF3AnyDKw=
@ -144,11 +150,19 @@ github.com/drone/envsubst v1.0.3 h1:PCIBwNDYjs50AsLZPYdfhSATKaRg/FJmDc2D6+C2x8g=
github.com/drone/envsubst v1.0.3/go.mod h1:N2jZmlMufstn1KEqvbHjw40h1KyTmnVzHcSc9bFiJ2g=
github.com/drone/funcmap v0.0.0-20190918184546-d4ef6e88376d h1:/IO7UVVu191Jc0DajV4cDVoO+91cuppvgxg2MZl+AXI=
github.com/drone/funcmap v0.0.0-20190918184546-d4ef6e88376d/go.mod h1:Hph0/pT6ZxbujnE1Z6/08p5I0XXuOsppqF6NQlGOK0E=
github.com/drone/go-convert v0.0.0-20230908165218-a0afea9a7e89 h1:9seeOkClNlD61uw/v6V6BFJjbvfxJTHJkloivIVkKN4=
github.com/drone/go-convert v0.0.0-20230908165218-a0afea9a7e89/go.mod h1:QIHVL/PfD6SMrn/0z+zTV+oTLPldcmXpGhZumsjwSts=
github.com/drone/go-convert v0.0.0-20230913194237-2228eb829d0e h1:H0eAzGW6vj4XCHnrAlmrcyQbg6g3yVcjfobUHzjNxGM=
github.com/drone/go-convert v0.0.0-20230913194237-2228eb829d0e/go.mod h1:ciC4CjDBSrpHGWmodGdUQshx7P5lAqL6DFJBnf3zVWU=
github.com/drone/go-scm v1.31.2 h1:6hZxf0aETV17830fMCPrgcA4y8j/8Gdfy0xEdInUeqQ=
github.com/drone/go-scm v1.31.2/go.mod h1:DFIJJjhMj0TSXPz+0ni4nyZ9gtTtC40Vh/TGRugtyWw=
github.com/drone/runner-go v1.12.0 h1:zUjDj9ylsJ4n4Mvy4znddq/Z4EBzcUXzTltpzokKtgs=
github.com/drone/runner-go v1.12.0/go.mod h1:vu4pPPYDoeN6vdYQAY01GGGsAIW4aLganJNaa8Fx8zE=
github.com/drone/signal v1.0.0/go.mod h1:S8t92eFT0g4WUgEc/LxG+LCuiskpMNsG0ajAMGnyZpc=
github.com/drone/spec v0.0.0-20230906220911-f12508081721 h1:6knuLPmIlSL+kZe0HGdq3QVqeviJD1BZn87BrZJPNMM=
github.com/drone/spec v0.0.0-20230906220911-f12508081721/go.mod h1:pdaL6nOipGF/5L6jAu1DwAeLzmZdaU3+UIvQ1MUIZ9Y=
github.com/drone/spec v0.0.0-20230913142424-983cda6e1ef2 h1:i7OEq9V97UnPC0uLI5OeYThKnG9uqXFtFwdYyq4MYu0=
github.com/drone/spec v0.0.0-20230913142424-983cda6e1ef2/go.mod h1:pdaL6nOipGF/5L6jAu1DwAeLzmZdaU3+UIvQ1MUIZ9Y=
github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs=
github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU=
@ -287,6 +301,8 @@ github.com/google/pprof v0.0.0-20221103000818-d260c55eee4c/go.mod h1:dDKJzRmX4S3
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
github.com/google/subcommands v1.0.1 h1:/eqq+otEXm5vhfBrbREPCSVQbvofip6kIz+mX5TUH7k=
github.com/google/subcommands v1.0.1/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk=
github.com/google/subcommands v1.2.0 h1:vWQspBTo2nEqTUFita5/KeEWlUL8kQObDFbub/EN9oE=
github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk=
github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4=
@ -309,6 +325,8 @@ github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
github.com/gotidy/ptr v1.3.0 h1:5wdrH1G8X4txy6fbWWRznr7k974wMWtePWP3p6s1API=
github.com/gotidy/ptr v1.3.0/go.mod h1:vpltyHhOZE+NGXUiwpVl3wV9AGEBlxhdnaimPDxRLxg=
github.com/gotidy/ptr v1.4.0 h1:7++suUs+HNHMnyz6/AW3SE+4EnBhupPSQTSI7QNijVc=
github.com/gotidy/ptr v1.4.0/go.mod h1:MjRBG6/IETiiZGWI8LrRtISXEji+8b/jigmj2q0mEyM=
github.com/gregjones/httpcache v0.0.0-20181110185634-c63ab54fda8f/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA=
github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 h1:+9834+KizmvFV7pXQGSXQTsaWhq2GjuNUt0aUU0YBYw=
@ -895,6 +913,8 @@ golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68=
golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=

View File

@ -0,0 +1,236 @@
// 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 importer
import (
"context"
"fmt"
"path"
"strings"
"time"
"github.com/harness/gitness/gitrpc"
"github.com/harness/gitness/store/database/dbtx"
"github.com/harness/gitness/types"
"github.com/harness/gitness/types/enum"
"github.com/drone/go-convert/convert/bitbucket"
"github.com/drone/go-convert/convert/circle"
"github.com/drone/go-convert/convert/drone"
"github.com/drone/go-convert/convert/github"
"github.com/drone/go-convert/convert/gitlab"
"github.com/rs/zerolog/log"
)
type pipelineFile struct {
Name string
OriginalPath string
ConvertedPath string
Content []byte
}
func (r *Repository) processPipelines(ctx context.Context,
principal *types.Principal,
repo *types.Repository,
commitMessage string,
) error {
writeParams, err := r.createRPCWriteParams(ctx, principal, repo)
if err != nil {
return err
}
pipelineFiles := r.convertPipelines(ctx, principal, repo)
if len(pipelineFiles) == 0 {
return nil
}
actions := make([]gitrpc.CommitFileAction, len(pipelineFiles))
for i, file := range pipelineFiles {
actions[i] = gitrpc.CommitFileAction{
Action: gitrpc.CreateAction,
Path: file.ConvertedPath,
Payload: file.Content,
SHA: "",
}
}
now := time.Now()
identity := &gitrpc.Identity{
Name: principal.DisplayName,
Email: principal.Email,
}
_, err = r.git.CommitFiles(ctx, &gitrpc.CommitFilesParams{
WriteParams: writeParams,
Title: commitMessage,
Message: "",
Branch: repo.DefaultBranch,
NewBranch: repo.DefaultBranch,
Actions: actions,
Committer: identity,
CommitterDate: &now,
Author: identity,
AuthorDate: &now,
})
if err != nil {
return fmt.Errorf("failed to commit converted pipeline files: %w", err)
}
nowMilli := now.UnixMilli()
err = dbtx.New(r.db).WithTx(ctx, func(ctx context.Context) error {
for _, p := range pipelineFiles {
pipeline := &types.Pipeline{
Description: "",
RepoID: repo.ID,
UID: p.Name,
CreatedBy: principal.ID,
Seq: 0,
DefaultBranch: repo.DefaultBranch,
ConfigPath: p.ConvertedPath,
Created: nowMilli,
Updated: nowMilli,
Version: 0,
}
err = r.pipelineStore.Create(ctx, pipeline)
if err != nil {
return fmt.Errorf("pipeline creation failed: %w", err)
}
// Try to create a default trigger on pipeline creation.
// Default trigger operations are set on pull request created, reopened or updated.
// We log an error on failure but don't fail the op.
trigger := &types.Trigger{
Description: "auto-created trigger on pipeline conversion",
Created: nowMilli,
Updated: nowMilli,
PipelineID: pipeline.ID,
RepoID: pipeline.RepoID,
CreatedBy: principal.ID,
UID: "default",
Actions: []enum.TriggerAction{enum.TriggerActionPullReqCreated,
enum.TriggerActionPullReqReopened, enum.TriggerActionPullReqBranchUpdated},
Disabled: false,
Version: 0,
}
err = r.triggerStore.Create(ctx, trigger)
if err != nil {
return fmt.Errorf("failed to create auto trigger on pipeline creation: %w", err)
}
}
return nil
}, dbtx.TxDefault)
if err != nil {
return fmt.Errorf("failed to insert pipelines and triggers: %w", err)
}
return nil
}
// convertPipelines converts pipelines found in the repository.
// Note: For GitHub actions, there can be multiple.
func (r *Repository) convertPipelines(ctx context.Context,
principal *types.Principal,
repo *types.Repository,
) []pipelineFile {
const maxSize = 65536
match := func(dirPath, regExpDef string) []pipelineFile {
files, err := r.matchFiles(ctx, repo, repo.DefaultBranch, dirPath, regExpDef, maxSize)
if err != nil {
log.Ctx(ctx).Warn().Err(err).Msgf("failed to find pipeline file(s) '%s' in '%s'",
regExpDef, dirPath)
return nil
}
return files
}
if files := match("", ".drone.yml"); len(files) > 0 {
converted := convertPipelineFiles(ctx, files, func() pipelineConverter { return drone.New() })
if len(converted) > 0 {
return converted
}
}
if files := match("", "bitbucket-pipelines.yml"); len(files) > 0 {
converted := convertPipelineFiles(ctx, files, func() pipelineConverter { return bitbucket.New() })
if len(converted) > 0 {
return converted
}
}
if files := match("", ".gitlab.yml"); len(files) > 0 {
converted := convertPipelineFiles(ctx, files, func() pipelineConverter { return gitlab.New() })
if len(converted) > 0 {
return converted
}
}
if files := match(".circleci", "config.yml"); len(files) > 0 {
converted := convertPipelineFiles(ctx, files, func() pipelineConverter { return circle.New() })
if len(converted) > 0 {
return converted
}
}
filesYML := match(".github/workflows", "*.yml")
filesYAML := match(".github/workflows", "*.yaml")
files := append(filesYML, filesYAML...)
converted := convertPipelineFiles(ctx, files, func() pipelineConverter { return github.New() })
if len(converted) > 0 {
return converted
}
return nil
}
type pipelineConverter interface {
ConvertBytes([]byte) ([]byte, error)
}
func convertPipelineFiles(ctx context.Context,
files []pipelineFile,
gen func() pipelineConverter,
) []pipelineFile {
const (
harnessPipelineName = "pipeline"
harnessPipelineNameOnly = "default-" + harnessPipelineName
harnessPipelineDir = ".harness"
harnessPipelineFileOnly = harnessPipelineDir + "/pipeline.yaml"
)
result := make([]pipelineFile, 0, len(files))
for _, file := range files {
data, err := gen().ConvertBytes(file.Content)
if err != nil {
log.Ctx(ctx).Warn().Err(err).Msgf("failed to convert pipeline file %s", file.OriginalPath)
continue
}
var pipelineName string
var pipelinePath string
if len(files) == 1 {
pipelineName = harnessPipelineNameOnly
pipelinePath = harnessPipelineFileOnly
} else {
base := path.Base(file.OriginalPath)
base = strings.TrimSuffix(base, path.Ext(base))
pipelineName = harnessPipelineName + "-" + base
pipelinePath = harnessPipelineDir + "/" + base + ".yaml"
}
result = append(result, pipelineFile{
Name: pipelineName,
OriginalPath: file.OriginalPath,
ConvertedPath: pipelinePath,
Content: data,
})
}
return result
}

View File

@ -26,6 +26,7 @@ import (
"github.com/harness/gitness/types"
"github.com/harness/gitness/types/enum"
"github.com/jmoiron/sqlx"
"github.com/rs/zerolog/log"
)
@ -38,7 +39,10 @@ type Repository struct {
defaultBranch string
urlProvider *gitnessurl.Provider
git gitrpc.Interface
db *sqlx.DB
repoStore store.RepoStore
pipelineStore store.PipelineStore
triggerStore store.TriggerStore
encrypter encrypt.Encrypter
scheduler *job.Scheduler
sseStreamer sse.Streamer
@ -234,6 +238,12 @@ func (r *Repository) Handle(ctx context.Context, data string, _ job.ProgressRepo
return fmt.Errorf("failed to update repository after import: %w", err)
}
const convertPipelinesCommitMessage = "autoconvert pipeline"
err = r.processPipelines(ctx, &systemPrincipal, repo, convertPipelinesCommitMessage)
if err != nil {
log.Warn().Err(err).Msg("failed to convert pipelines")
}
return nil
}()
if err != nil {
@ -366,6 +376,37 @@ func (r *Repository) deleteGitRepository(ctx context.Context,
return nil
}
func (r *Repository) matchFiles(ctx context.Context,
repo *types.Repository,
ref string,
dirPath string,
pattern string,
maxSize int,
) ([]pipelineFile, error) {
resp, err := r.git.MatchFiles(ctx, &gitrpc.MatchFilesParams{
ReadParams: gitrpc.ReadParams{RepoUID: repo.GitUID},
Ref: ref,
DirPath: dirPath,
Pattern: pattern,
MaxSize: maxSize,
})
if err != nil {
return nil, fmt.Errorf("failed to convert pipelines: %w", err)
}
pipelines := make([]pipelineFile, len(resp.Files))
for i, pipeline := range resp.Files {
pipelines[i] = pipelineFile{
Name: "",
OriginalPath: pipeline.Path,
ConvertedPath: "",
Content: pipeline.Content,
}
}
return pipelines, nil
}
func (r *Repository) createRPCWriteParams(ctx context.Context,
principal *types.Principal,
repo *types.Repository,

View File

@ -12,6 +12,7 @@ import (
"github.com/harness/gitness/internal/store"
"github.com/harness/gitness/internal/url"
"github.com/harness/gitness/types"
"github.com/jmoiron/sqlx"
"github.com/google/wire"
)
@ -24,7 +25,10 @@ func ProvideRepoImporter(
config *types.Config,
urlProvider *url.Provider,
git gitrpc.Interface,
db *sqlx.DB,
repoStore store.RepoStore,
pipelineStore store.PipelineStore,
triggerStore store.TriggerStore,
encrypter encrypt.Encrypter,
scheduler *job.Scheduler,
executor *job.Executor,
@ -34,7 +38,10 @@ func ProvideRepoImporter(
defaultBranch: config.Git.DefaultBranch,
urlProvider: urlProvider,
git: git,
db: db,
repoStore: repoStore,
pipelineStore: pipelineStore,
triggerStore: triggerStore,
encrypter: encrypter,
scheduler: scheduler,
sseStreamer: sseStreamer,