feature/gitea-integration #10

Merged
kjuulh merged 10 commits from feature/gitea-integration into v0.1 2022-09-18 00:10:44 +02:00
2 changed files with 27 additions and 2 deletions
Showing only changes of commit 04d1ffc971 - Show all commits

View File

@ -22,7 +22,7 @@ func CreateKrakenProcessCmd() *cobra.Command {
Path string `json:"path"`
}{
Repository: "git@git.front.kjuulh.io:kjuulh/kraken.git",
Branch: "feature/add-actions",
Branch: "feature/process_repos",
Path: "_examples/actions/write_a_readme/",
})
if err != nil {

View File

@ -7,6 +7,8 @@ import (
"time"
"git.front.kjuulh.io/kjuulh/kraken/internal/actions"
"git.front.kjuulh.io/kjuulh/kraken/internal/gitproviders"
"git.front.kjuulh.io/kjuulh/kraken/internal/schema"
"git.front.kjuulh.io/kjuulh/kraken/internal/services/providers"
"git.front.kjuulh.io/kjuulh/kraken/internal/services/storage"
"go.uber.org/zap"
@ -18,12 +20,14 @@ type (
storage *storage.Service
git *providers.Git
actionCreator *actions.ActionCreator
gitea *gitproviders.Gitea
}
ProcessReposDeps interface {
GetStorageService() *storage.Service
GetGitProvider() *providers.Git
GetActionCreator() *actions.ActionCreator
GetGitea() *gitproviders.Gitea
}
)
@ -33,6 +37,7 @@ func NewProcessRepos(logger *zap.Logger, deps ProcessReposDeps) *ProcessRepos {
storage: deps.GetStorageService(),
git: deps.GetGitProvider(),
actionCreator: deps.GetActionCreator(),
gitea: deps.GetGitea(),
}
}
@ -48,7 +53,10 @@ func (pr *ProcessRepos) Process(ctx context.Context, repository string, branch s
return err
}
repositoryUrls := action.Schema.Select.Repositories
repositoryUrls, err := pr.getRepoUrls(ctx, action.Schema)
if err != nil {
return err
}
wg := sync.WaitGroup{}
wg.Add(len(repositoryUrls))
@ -76,6 +84,23 @@ func (pr *ProcessRepos) Process(ctx context.Context, repository string, branch s
return nil
}
func (pr *ProcessRepos) getRepoUrls(ctx context.Context, schema *schema.KrakenSchema) ([]string, error) {
repoUrls := make([]string, 0)
repoUrls = append(repoUrls, schema.Select.Repositories...)
for _, provider := range schema.Select.Providers {
repos, err := pr.gitea.ListRepositoriesForOrganization(ctx, provider.Gitea, provider.Organisation)
if err != nil {
return nil, err
}
repoUrls = append(repoUrls, repos...)
}
return repoUrls, nil
}
func (pr *ProcessRepos) processRepo(ctx context.Context, repoUrl string, action *actions.Action) error {
cleanup, area, err := pr.prepareAction(ctx)
defer func() {