with action creator

This commit is contained in:
2022-09-13 22:54:49 +02:00
parent 564147eb6a
commit ce55f6523c
9 changed files with 208 additions and 77 deletions

View File

@@ -16,7 +16,9 @@ func CommandRoute(logger *zap.Logger, app *gin.Engine, deps *serverdeps.ServerDe
commandRoute := app.Group("commands")
commandRoute.POST("processRepos", func(c *gin.Context) {
type processReposRequest struct {
RepositoryUrls []string `json:"repositoryUrls"`
Repository string `json:"repository"`
Branch string `json:"branch"`
Path string `json:"path"`
}
var request processReposRequest
err := c.BindJSON(&request)
@@ -28,11 +30,11 @@ func CommandRoute(logger *zap.Logger, app *gin.Engine, deps *serverdeps.ServerDe
jobId := uuid.New().String()
go func(repositoryUrls []string, jobId string) {
go func(repository string, branch string, path string, jobId string) {
ctx := context.WithValue(context.Background(), jobs.JobId{}, jobId)
processRepos := commands.NewProcessRepos(logger, deps)
err = processRepos.Process(ctx, repositoryUrls)
}(request.RepositoryUrls, jobId)
err = processRepos.Process(ctx, repository, branch, path)
}(request.Repository, request.Branch, request.Path, jobId)
c.Status(http.StatusAccepted)
})