...
1 package project
2
3 import (
4 "fmt"
5
6 "github.com/google/go-github/v47/github"
7
8 "edge-infra.dev/pkg/f8n/devinfra/jack/constants"
9
10 "edge-infra.dev/pkg/f8n/devinfra/jack/plugin"
11 )
12
13 func init() {
14 plugin.RegisterIssueHandler(constants.PluginProject, handleIssue)
15 }
16
17 func handleIssue(hp plugin.HandlerParams, ce github.IssuesEvent) {
18 hp.Log.WithName(constants.PluginProject)
19
20 switch action := ce.GetAction(); action {
21 case "opened":
22 hp.Log.Info("Running project plugin")
23 executeNewIssue(hp, ce)
24 }
25 }
26
27 func executeNewIssue(hp plugin.HandlerParams, ce github.IssuesEvent) {
28
29 ids := hp.Params.Project.IDs
30 for _, id := range ids {
31 hp.Log.Info(fmt.Sprintf("attempting to create a new issue for project #%d", id))
32 err := addIssueToProject(hp, ce, id)
33 if err != nil {
34 hp.Log.Error(err, "Failed to add issue to project")
35 }
36 }
37 }
38
View as plain text