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

Method parseCloseEntityConfig

pkg/workflow/close_entity_helpers.go:104–142  ·  view source on GitHub ↗

parseCloseEntityConfig is a generic function to parse close entity configurations

(outputMap map[string]any, params CloseEntityJobParams, logger *logger.Logger)

Source from the content-addressed store, hash-verified

102
103// parseCloseEntityConfig is a generic function to parse close entity configurations
104func (c *Compiler) parseCloseEntityConfig(outputMap map[string]any, params CloseEntityJobParams, logger *logger.Logger) *CloseEntityConfig {
105 // Check if the key exists
106 if _, exists := outputMap[params.ConfigKey]; !exists {
107 return nil
108 }
109
110 // Get config data for pre-processing before YAML unmarshaling
111 configData, _ := outputMap[params.ConfigKey].(map[string]any)
112
113 // Pre-process templatable int fields
114 if err := preprocessIntFieldAsString(configData, "max", logger); err != nil {
115 logger.Printf("Invalid max value for %s: %v", params.ConfigKey, err)
116 return nil
117 }
118
119 config := parseConfigScaffold(outputMap, params.ConfigKey, logger, func(err error) *CloseEntityConfig {
120 logger.Printf("Failed to unmarshal config: %v", err)
121 // For backward compatibility, handle nil/empty config
122 return &CloseEntityConfig{}
123 })
124 if config == nil {
125 return nil
126 }
127
128 // Set default max if not specified
129 if config.Max == nil {
130 config.Max = defaultIntStr(1)
131 logger.Printf("Set default max to 1 for %s", params.ConfigKey)
132 }
133
134 // Backward compatibility: map deprecated title-prefix to required-title-prefix.
135 if config.RequiredTitlePrefix == "" && config.TitlePrefix != "" {
136 config.RequiredTitlePrefix = config.TitlePrefix
137 }
138
139 logger.Printf("Parsed %s configuration: max=%s, target=%s", params.ConfigKey, *config.Max, config.Target)
140
141 return config
142}
143
144// closeEntityDefinition holds all parameters for a close entity type
145type closeEntityDefinition struct {

Calls 4

parseConfigScaffoldFunction · 0.85
defaultIntStrFunction · 0.85
PrintfMethod · 0.45

Tested by

no test coverage detected