workflow-direct: fix building
This commit is contained in:
parent
b9e70132ae
commit
f77e35731c
@ -58,7 +58,9 @@ func concatenateErrors(err1, err2 error) error {
|
||||
return fmt.Errorf("%w\n%w", err1, err2)
|
||||
}
|
||||
|
||||
func processRepositoryAction(request *common.Request) error {
|
||||
type RepositoryActionProcessor struct{}
|
||||
|
||||
func (*RepositoryActionProcessor) ProcessFunc(request *common.Request) error {
|
||||
action := request.Data.(*common.RepositoryWebhookEvent)
|
||||
configs, configFound := configuredRepos[action.Organization.Username]
|
||||
|
||||
@ -84,7 +86,8 @@ func processRepositoryAction(request *common.Request) error {
|
||||
|
||||
func processConfiguredRepositoryAction(action *common.RepositoryWebhookEvent, config *common.AutogitConfig) error {
|
||||
prjgit := config.GitProjectName
|
||||
git, err := common.CreateGitHandler(GitAuthor, GitEmail, AppName)
|
||||
ghi := common.GitHandlerGeneratorImpl{}
|
||||
git, err := ghi.CreateGitHandler(GitAuthor, GitEmail, AppName)
|
||||
common.PanicOnError(err)
|
||||
if !DebugMode {
|
||||
defer git.Close()
|
||||
@ -114,8 +117,8 @@ func processConfiguredRepositoryAction(action *common.RepositoryWebhookEvent, co
|
||||
common.PanicOnError(git.GitExec(prjgit, "push"))
|
||||
|
||||
case "deleted":
|
||||
if stat, err := os.Stat(filepath.Join(git.GitPath, prjgit, action.Repository.Name)); err != nil || !stat.IsDir() {
|
||||
if git.DebugLogger {
|
||||
if stat, err := os.Stat(filepath.Join(git.GetPath(), prjgit, action.Repository.Name)); err != nil || !stat.IsDir() {
|
||||
if DebugMode {
|
||||
log.Println("delete event for", action.Repository.Name, "-- not in project. Ignoring")
|
||||
}
|
||||
return nil
|
||||
@ -131,7 +134,9 @@ func processConfiguredRepositoryAction(action *common.RepositoryWebhookEvent, co
|
||||
return nil
|
||||
}
|
||||
|
||||
func processPushAction(request *common.Request) error {
|
||||
type PushActionProcessor struct{}
|
||||
|
||||
func (*PushActionProcessor) ProcessFunc(request *common.Request) error {
|
||||
action := request.Data.(*common.PushWebhookEvent)
|
||||
configs, configFound := configuredRepos[action.Repository.Owner.Username]
|
||||
|
||||
@ -157,7 +162,8 @@ func processPushAction(request *common.Request) error {
|
||||
|
||||
func processConfiguredPushAction(action *common.PushWebhookEvent, config *common.AutogitConfig) error {
|
||||
prjgit := config.GitProjectName
|
||||
git, err := common.CreateGitHandler(GitAuthor, GitEmail, AppName)
|
||||
ghi := common.GitHandlerGeneratorImpl{}
|
||||
git, err := ghi.CreateGitHandler(GitAuthor, GitEmail, AppName)
|
||||
common.PanicOnError(err)
|
||||
if !DebugMode {
|
||||
defer git.Close()
|
||||
@ -174,8 +180,8 @@ func processConfiguredPushAction(action *common.PushWebhookEvent, config *common
|
||||
}
|
||||
|
||||
common.PanicOnError(git.GitExec("", "clone", "--depth", "1", prjGitRepo.SSHURL, prjgit))
|
||||
if stat, err := os.Stat(filepath.Join(git.GitPath, prjgit, action.Repository.Name)); err != nil || !stat.IsDir() {
|
||||
if git.DebugLogger {
|
||||
if stat, err := os.Stat(filepath.Join(git.GetPath(), prjgit, action.Repository.Name)); err != nil || !stat.IsDir() {
|
||||
if DebugMode {
|
||||
log.Println("Pushed to package that is not part of the project. Ignoring:", err)
|
||||
}
|
||||
return nil
|
||||
@ -200,7 +206,7 @@ func processConfiguredPushAction(action *common.PushWebhookEvent, config *common
|
||||
return nil
|
||||
}
|
||||
|
||||
func verifyProjectState(git *common.GitHandler, orgName string, config *common.AutogitConfig, configs []*common.AutogitConfig) (err error) {
|
||||
func verifyProjectState(git common.Git, orgName string, config *common.AutogitConfig, configs []*common.AutogitConfig) (err error) {
|
||||
defer func() {
|
||||
e := recover()
|
||||
if e != nil {
|
||||
@ -353,7 +359,8 @@ func checkRepos() {
|
||||
}
|
||||
|
||||
log.Printf(" ++ starting verification, org: `%s` config: `%s`\n", org, config.GitProjectName)
|
||||
git, err := common.CreateGitHandler(GitAuthor, GitEmail, AppName)
|
||||
ghi := common.GitHandlerGeneratorImpl{}
|
||||
git, err := ghi.CreateGitHandler(GitAuthor, GitEmail, AppName)
|
||||
if err != nil {
|
||||
log.Println("Faield to allocate GitHandler:", err)
|
||||
return
|
||||
@ -437,8 +444,8 @@ func main() {
|
||||
defs.RabbitURL = *rabbitUrl
|
||||
|
||||
defs.Handlers = make(map[string]common.RequestProcessor)
|
||||
defs.Handlers[common.RequestType_Push] = processPushAction
|
||||
defs.Handlers[common.RequestType_Repository] = processRepositoryAction
|
||||
defs.Handlers[common.RequestType_Push] = &PushActionProcessor{}
|
||||
defs.Handlers[common.RequestType_Repository] = &RepositoryActionProcessor{}
|
||||
|
||||
log.Fatal(common.ProcessRabbitMQEvents(defs, orgs))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user