applyRuntimeOverrides applies runtime version overrides from frontmatter
(runtimes map[string]any, requirements map[string]*RuntimeRequirement)
| 7 | |
| 8 | // applyRuntimeOverrides applies runtime version overrides from frontmatter |
| 9 | func applyRuntimeOverrides(runtimes map[string]any, requirements map[string]*RuntimeRequirement) { |
| 10 | runtimeSetupLog.Printf("Applying runtime overrides for %d configured runtimes", len(runtimes)) |
| 11 | for runtimeID, configAny := range runtimes { |
| 12 | // Parse runtime configuration |
| 13 | configMap, ok := configAny.(map[string]any) |
| 14 | if !ok { |
| 15 | continue |
| 16 | } |
| 17 | |
| 18 | // Extract version from config |
| 19 | versionAny, hasVersion := configMap["version"] |
| 20 | var version string |
| 21 | if hasVersion { |
| 22 | // Convert version to string (handle both string and numeric types) |
| 23 | switch v := versionAny.(type) { |
| 24 | case string: |
| 25 | version = v |
| 26 | case int: |
| 27 | version = strconv.Itoa(v) |
| 28 | case float64: |
| 29 | // Check if it's a whole number |
| 30 | if v == float64(int(v)) { |
| 31 | version = strconv.Itoa(int(v)) |
| 32 | } else { |
| 33 | version = fmt.Sprintf("%g", v) |
| 34 | } |
| 35 | default: |
| 36 | continue |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | // Extract action-repo and action-version from config |
| 41 | actionRepo, _ := configMap["action-repo"].(string) |
| 42 | actionVersion, _ := configMap["action-version"].(string) |
| 43 | |
| 44 | // Extract if condition from config |
| 45 | ifCondition, _ := configMap["if"].(string) |
| 46 | |
| 47 | // Extract cooldown flag from config (optional) |
| 48 | cooldown, hasCooldown := configMap["cooldown"].(bool) |
| 49 | |
| 50 | // Find or create runtime requirement |
| 51 | if existing, exists := requirements[runtimeID]; exists { |
| 52 | // Override version for existing requirement |
| 53 | if hasVersion { |
| 54 | runtimeSetupLog.Printf("Overriding version for runtime %s: %s", runtimeID, version) |
| 55 | existing.Version = version |
| 56 | } |
| 57 | |
| 58 | // Override if condition if specified |
| 59 | if ifCondition != "" { |
| 60 | runtimeSetupLog.Printf("Setting if condition for runtime %s: %s", runtimeID, ifCondition) |
| 61 | existing.IfCondition = ifCondition |
| 62 | } |
| 63 | |
| 64 | // Override cooldown setting if specified |
| 65 | if hasCooldown { |
| 66 | runtimeSetupLog.Printf("Setting cooldown for runtime %s: %v", runtimeID, cooldown) |