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

Function preprocessBoolFieldAsString

pkg/workflow/config_preprocessing.go:20–42  ·  view source on GitHub ↗

preprocessBoolFieldAsString converts the value of a boolean config field to a string before YAML unmarshaling. This lets struct fields typed as *string accept both literal boolean values (true/false) and GitHub Actions expression strings (e.g. "${{ inputs.draft-prs }}"). If the value is a bool it i

(configData map[string]any, fieldName string, debugLog *logger.Logger)

Source from the content-addressed store, hash-verified

18// with "${{" and ends with "}}"); any other free-form string is rejected
19// and an error is returned.
20func preprocessBoolFieldAsString(configData map[string]any, fieldName string, debugLog *logger.Logger) error {
21 if configData == nil {
22 return nil
23 }
24 if val, exists := configData[fieldName]; exists {
25 switch v := val.(type) {
26 case bool:
27 if v {
28 configData[fieldName] = "true"
29 } else {
30 configData[fieldName] = "false"
31 }
32 if debugLog != nil {
33 debugLog.Printf("Converted %s bool to string before unmarshaling", fieldName)
34 }
35 case string:
36 if !isExpression(v) {
37 return fmt.Errorf("field %q must be a boolean or a GitHub Actions expression (e.g. '${{ inputs.flag }}'), got string %q", fieldName, v)
38 }
39 }
40 }
41 return nil
42}
43
44// preprocessIntFieldAsString converts the value of an integer config field
45// to a string before YAML unmarshaling. This lets struct fields typed as

Calls 3

isExpressionFunction · 0.85
PrintfMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected