package task import ( //"strings" //"github.com/google/go-github/v47/github" "edge-infra.dev/pkg/f8n/devinfra/jack/constants" //"edge-infra.dev/pkg/f8n/devinfra/jack/plugin" ) // handleNewComment handles new comment events for the task plugin /* func handleNewComment(hp plugin.HandlerParams, ce github.IssueCommentEvent, taskCommands []string) error { // Validate the kind/ label and if its not a valid label --> bounce tempCommand := taskCommands[0] kind, validKind := validateKindCommand(tempCommand) if !validKind { hp.Log.Info().Msg("command is not a valid kind") return nil } // Gather the label names // *task name labelNames := []string{} labels := ce.GetIssue().Labels for _, label := range labels { name := label.GetName() // if the kind command is for a kind thats already there exit if name == kind { hp.Log.Info().Msgf("%s label already exists. Exiting.", kind) return nil } // only add none kind labels to the list if !strings.Contains(name, "kind/") && name != string(constants.Task) { labelNames = append(labelNames, name) } } // remove the old kind and add the new labelNames = append(labelNames, kind) githubIssueBody := &github.IssueRequest{Labels: &labelNames} _, _, err := hp.Client.Issues().Edit(hp.Ctx, ce.Repo.GetOwner().GetLogin(), ce.Repo.GetName(), ce.GetIssue().GetNumber(), githubIssueBody) if err != nil { hp.Log.Error().Err(err).Msg("Failed to update issue desc") return err } return nil } */ // check if the given kind is valid return the constant for the appro kind func validateKindCommand(taskCommand string) (string, bool) { task := string(constants.Task) epic := string(constants.Epic) capability := string(constants.Capability) feature := string(constants.Feature) story := string(constants.Story) switch taskCommand { case "task", task: return task, true case "epic", epic: return epic, true case "capacity", capability: return capability, true case "feature", feature: return feature, true case "story", story: return story, true } return "", false }