-
Notifications
You must be signed in to change notification settings - Fork 501
Expand file tree
/
Copy pathupdate_issue.go
More file actions
43 lines (38 loc) · 2.58 KB
/
Copy pathupdate_issue.go
File metadata and controls
43 lines (38 loc) · 2.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// This file provides configuration types and parsing for the update-issue safe output.
//
// For shared update entity infrastructure (types, generic parsers, field parsing modes),
// see update_entity_helpers.go.
package workflow
import "github.com/github/gh-aw/pkg/logger"
var updateIssueLog = logger.New("workflow:update_issue")
// UpdateIssuesConfig holds configuration for updating GitHub issues from agent output
type UpdateIssuesConfig struct {
UpdateEntityConfig `yaml:",inline"`
Status *bool `yaml:"status,omitempty"` // Allow updating issue status (open/closed) - presence indicates field can be updated
Title *bool `yaml:"title,omitempty"` // Allow updating issue title - presence indicates field can be updated
Body *bool `yaml:"body,omitempty"` // Allow updating issue body - boolean value controls permission (defaults to true)
TitlePrefix string `yaml:"title-prefix,omitempty"` // Required title prefix for issue validation - only issues with this prefix can be updated (deprecated: use required-title-prefix)
RequiredTitlePrefix string `yaml:"required-title-prefix,omitempty"` // Title prefix the issue must have (preferred over title-prefix)
RequiredLabels []string `yaml:"required-labels,omitempty"` // Labels that must ALL be present on the issue
}
// parseUpdateIssuesConfig handles update-issue configuration
func (c *Compiler) parseUpdateIssuesConfig(outputMap map[string]any) *UpdateIssuesConfig {
updateIssueLog.Print("Parsing update-issue config")
return parseUpdateEntityConfigTyped(c, outputMap,
UpdateEntityIssue, "update-issue", updateIssueLog,
func(cfg *UpdateIssuesConfig) []UpdateEntityFieldSpec {
return []UpdateEntityFieldSpec{
{Name: "status", Mode: FieldParsingKeyExistence, Dest: &cfg.Status},
{Name: "title", Mode: FieldParsingKeyExistence, Dest: &cfg.Title},
{Name: "body", Mode: FieldParsingBoolValue, Dest: &cfg.Body},
updateEntityFooterField(&cfg.Footer),
}
}, func(configMap map[string]any, cfg *UpdateIssuesConfig) {
cfg.TitlePrefix = extractStringFromMap(configMap, "title-prefix", updateIssueLog)
// Parse required-labels and required-title-prefix directly to avoid the
// deprecated title-prefix fallback in ParseFilterConfig double-populating
// RequiredTitlePrefix when only title-prefix is set.
cfg.RequiredLabels = ParseStringArrayFromConfig(configMap, "required-labels", updateIssueLog)
cfg.RequiredTitlePrefix = extractStringFromMap(configMap, "required-title-prefix", updateIssueLog)
})
}