MCPcopy Create free account
hub / github.com/github/gh-aw / parseReactionConfig

Function parseReactionConfig

pkg/workflow/reactions.go:90–128  ·  view source on GitHub ↗

parseReactionConfig parses reaction configuration from frontmatter. Supported formats: - scalar (string/int): reaction type only - object: {type, issues, pull-requests, discussions}

(value any)

Source from the content-addressed store, hash-verified

88// - scalar (string/int): reaction type only
89// - object: {type, issues, pull-requests, discussions}
90func parseReactionConfig(value any) (string, *bool, *bool, *bool, error) {
91 if reactionMap, ok := value.(map[string]any); ok {
92 reactionType := "eyes"
93 if typeValue, hasType := reactionMap["type"]; hasType {
94 parsedType, err := parseReactionValue(typeValue)
95 if err != nil {
96 return "", nil, nil, nil, err
97 }
98 reactionType = parsedType
99 }
100
101 reactionIssues, err := parseBoolReactionField(reactionMap, "issues")
102 if err != nil {
103 return "", nil, nil, nil, err
104 }
105
106 reactionPullRequests, err := parseBoolReactionField(reactionMap, "pull-requests")
107 if err != nil {
108 return "", nil, nil, nil, err
109 }
110
111 reactionDiscussions, err := parseBoolReactionField(reactionMap, "discussions")
112 if err != nil {
113 return "", nil, nil, nil, err
114 }
115
116 if !reactionIssues && !reactionPullRequests && !reactionDiscussions {
117 return "", nil, nil, nil, errors.New("reaction object requires at least one target to be enabled (issues, pull-requests, or discussions)")
118 }
119
120 return reactionType, &reactionIssues, &reactionPullRequests, &reactionDiscussions, nil
121 }
122
123 reactionType, err := parseReactionValue(value)
124 if err != nil {
125 return "", nil, nil, nil, err
126 }
127 return reactionType, nil, nil, nil, nil
128}
129
130// parseBoolReactionField reads a boolean field from a reaction config map.
131// Returns true if the key is absent (defaults to enabled), or the parsed bool value.

Calls 2

parseReactionValueFunction · 0.85
parseBoolReactionFieldFunction · 0.85