-
Notifications
You must be signed in to change notification settings - Fork 501
Expand file tree
/
Copy pathupdate_discussion.go
More file actions
44 lines (39 loc) · 2.06 KB
/
Copy pathupdate_discussion.go
File metadata and controls
44 lines (39 loc) · 2.06 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
44
// This file provides configuration types and parsing for the update-discussion 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 updateDiscussionLog = logger.New("workflow:update_discussion")
// UpdateDiscussionsConfig holds configuration for updating GitHub discussions from agent output
type UpdateDiscussionsConfig struct {
UpdateEntityConfig `yaml:",inline"`
SafeOutputAllowedLabelsConfig `yaml:",inline"`
Title *bool `yaml:"title,omitempty"` // Allow updating discussion title - presence indicates field can be updated
Body *bool `yaml:"body,omitempty"` // Allow updating discussion body - presence indicates field can be updated
Labels *bool `yaml:"labels,omitempty"` // Allow updating discussion labels - presence indicates field can be updated
}
// parseUpdateDiscussionsConfig handles update-discussion configuration
func (c *Compiler) parseUpdateDiscussionsConfig(outputMap map[string]any) *UpdateDiscussionsConfig {
return parseUpdateEntityConfigTyped(c, outputMap,
UpdateEntityDiscussion, "update-discussion", updateDiscussionLog,
func(cfg *UpdateDiscussionsConfig) []UpdateEntityFieldSpec {
return []UpdateEntityFieldSpec{
{Name: "title", Mode: FieldParsingKeyExistence, Dest: &cfg.Title},
{Name: "body", Mode: FieldParsingKeyExistence, Dest: &cfg.Body},
{Name: "labels", Mode: FieldParsingKeyExistence, Dest: &cfg.Labels},
updateEntityFooterField(&cfg.Footer),
}
},
func(cm map[string]any, cfg *UpdateDiscussionsConfig) {
// Parse allowed-labels using shared helper
cfg.AllowedLabels = ParseStringArrayFromConfig(cm, "allowed-labels", updateDiscussionLog)
if len(cfg.AllowedLabels) > 0 {
updateDiscussionLog.Printf("Allowed labels configured: %v", cfg.AllowedLabels)
// If allowed-labels is specified, implicitly enable labels
if cfg.Labels == nil {
cfg.Labels = new(bool)
}
}
})
}