...
1 package task
2
3 import (
4 "github.com/google/go-github/v47/github"
5
6 "edge-infra.dev/pkg/f8n/devinfra/jack/plugin"
7 )
8
9 const (
10 PluginName = "task"
11 )
12
13 func init() {
14 plugin.RegisterIssueHandler(PluginName, handleIssue)
15
16 }
17
18
34
35 func handleIssue(hp plugin.HandlerParams, ie github.IssuesEvent) {
36 hp.Log.WithName(PluginName)
37
38 log := hp.Log
39 ctx := hp.Ctx
40 client := hp.Client
41 log.Info("Running task plugin")
42
43 switch action := ie.GetAction(); action {
44 case "opened":
45 if err := addKindToNewIssue(ctx, log, client, ie); err != nil {
46 log.Error(err, "Failed to add kind to new issue")
47 }
48 case "labeled":
49 if err := addTaskLabel(ctx, log, client, ie); err != nil {
50 log.Error(err, "Failed to add task label")
51 }
52 case "unlabeled":
53 if err := removeTaskLabel(ctx, log, client, ie); err != nil {
54 log.Error(err, "Failed to remove task label")
55 }
56 }
57 }
58
View as plain text