parseUpdateEntityConfig is a generic function to parse update entity configurations
(outputMap map[string]any, params UpdateEntityJobParams, logger *logger.Logger, parseSpecificFields func(map[string]any, *UpdateEntityConfig))
| 124 | |
| 125 | // parseUpdateEntityConfig is a generic function to parse update entity configurations |
| 126 | func (c *Compiler) parseUpdateEntityConfig(outputMap map[string]any, params UpdateEntityJobParams, logger *logger.Logger, parseSpecificFields func(map[string]any, *UpdateEntityConfig)) *UpdateEntityConfig { |
| 127 | if configData, exists := outputMap[params.ConfigKey]; exists { |
| 128 | logger.Printf("Parsing %s configuration", params.ConfigKey) |
| 129 | config := &UpdateEntityConfig{} |
| 130 | |
| 131 | if configMap, ok := configData.(map[string]any); ok { |
| 132 | // Parse target config (target, target-repo) with validation |
| 133 | targetConfig, isInvalid := ParseTargetConfig(configMap) |
| 134 | if isInvalid { |
| 135 | logger.Printf("Invalid target-repo configuration for %s", params.ConfigKey) |
| 136 | return nil |
| 137 | } |
| 138 | config.SafeOutputTargetConfig = targetConfig |
| 139 | updateEntityHelpersLog.Printf("Parsed target config for %s: target=%s", params.ConfigKey, targetConfig.Target) |
| 140 | |
| 141 | // Parse type-specific fields if provided |
| 142 | if parseSpecificFields != nil { |
| 143 | parseSpecificFields(configMap, config) |
| 144 | } |
| 145 | |
| 146 | // Parse common base fields with default max of 1 |
| 147 | c.parseBaseSafeOutputConfig(configMap, &config.BaseSafeOutputConfig, 1) |
| 148 | } else { |
| 149 | // If configData is nil or not a map, still set the default max |
| 150 | config.Max = defaultIntStr(1) |
| 151 | } |
| 152 | |
| 153 | return config |
| 154 | } |
| 155 | |
| 156 | return nil |
| 157 | } |
| 158 | |
| 159 | // parseUpdateEntityBase is a helper that reduces scaffolding duplication across update entity parsers. |
| 160 | // It handles the common pattern of: |
no test coverage detected