git: one generator per app, multiple instances

this allows locking for access for each org
This commit is contained in:
2025-04-13 23:30:21 +02:00
parent 51ba81f257
commit 2d044d5664
11 changed files with 115 additions and 112 deletions

View File

@@ -57,13 +57,6 @@ var PRID int64
var CurrentUser *models.User
func main() {
if err := common.RequireGiteaSecretToken(); err != nil {
log.Fatal(err)
}
if err := common.RequireRabbitSecrets(); err != nil {
log.Fatal(err)
}
workflowConfig := flag.String("config", "", "Repository and workflow definition file")
giteaUrl := flag.String("gitea-url", "https://src.opensuse.org", "Gitea instance")
rabbitUrl := flag.String("url", "amqps://rabbit.opensuse.org", "URL for RabbitMQ instance")
@@ -73,8 +66,16 @@ func main() {
flag.BoolVar(&ListPROnly, "list-prs-only", false, "Only lists PRs without acting on them")
flag.Int64Var(&PRID, "id", -1, "Process only the specific ID and ignore the rest. Use for debugging")
gitPath := flag.String("git-path", "", "Path to work location. Using temp path by default")
flag.Parse()
if err := common.RequireGiteaSecretToken(); err != nil {
log.Fatal(err)
}
if err := common.RequireRabbitSecrets(); err != nil {
log.Fatal(err)
}
if len(*workflowConfig) == 0 {
log.Fatalln("No configuratio file specified. Aborting")
}
@@ -85,7 +86,7 @@ func main() {
log.Fatal(err)
}
configs, err := common.ResolveWorkflowConfigs(gitea, config)
configs, err := common.ResolveWorkflowConfigs(gitea, config)
if err != nil {
log.Fatal(err)
}
@@ -93,7 +94,11 @@ func main() {
req := new(RequestProcessor)
req.configuredRepos = make(map[string][]*common.AutogitConfig)
req.git = &common.GitHandlerGeneratorImpl{}
req.git, err = common.AllocateGitWorkTree(*gitPath, GitAuthor, GitEmail)
if err != nil {
log.Fatal(err)
}
orgs := make([]string, 0, 1)
for _, c := range configs {
if slices.Contains(c.Workflows, "pr") {