package task import ( "github.com/google/go-github/v47/github" "edge-infra.dev/pkg/f8n/devinfra/jack/plugin" ) const ( PluginName = "task" ) func init() { plugin.RegisterIssueHandler(PluginName, handleIssue) // plugin.RegisterIssueCommentHandler(PluginName, handleIssueComment) } /* func handleIssueComment(hp plugin.HandlerParams, ce github.IssueCommentEvent) { hp.Log = hp.Log.With().Str("plugin", PluginName).Logger() // check if there are any kind/task commands and bounce if not if ce.GetAction() != "created" { return } taskCommands := util.GetSpecificCommandFromBody(ce.Comment.GetBody(), "kind", false, false) hp.Log.Info().Msgf("handling a new kind/task command from a comment: %+v", taskCommands) err := handleNewComment(hp, ce, taskCommands) if err != nil { hp.Log.Error().Err(err) } } */ func handleIssue(hp plugin.HandlerParams, ie github.IssuesEvent) { hp.Log.WithName(PluginName) log := hp.Log ctx := hp.Ctx client := hp.Client log.Info("Running task plugin") switch action := ie.GetAction(); action { case "opened": if err := addKindToNewIssue(ctx, log, client, ie); err != nil { log.Error(err, "Failed to add kind to new issue") } case "labeled": if err := addTaskLabel(ctx, log, client, ie); err != nil { log.Error(err, "Failed to add task label") } case "unlabeled": if err := removeTaskLabel(ctx, log, client, ie); err != nil { log.Error(err, "Failed to remove task label") } } }