@@ -2530,7 +2530,9 @@ This means pods only auto-restart if the non-excluded parts change.
2530
2530
2531
2531
Pass in root, me, configMapHelper, component, excludeSectionRegexList and excludeKeyList
2532
2532
excludeSectionRegexList is a list of regexp' s that filter out top-level sections, e.g. [".*spec.yaml$" ]
2533
- excludeKeyList is a list of key values to exclude from each section, e.g. [ "global", "esp.services" "esp.queues"]
2533
+ excludeKeyList is a list of key values with optional regex support (denoted by leading ' ~' ) to exclude from
2534
+ each section, each component of the key must be seperated by "::" due to the regex support.
2535
+ e.g. [ "global", "esp::services" "esp::queues", "~.*::loggging"]
2534
2536
2535
2537
The configMap data section is reconstructed based on filtering out matches.
2536
2538
@@ -2543,32 +2545,53 @@ e.g. a cache of secrets, with an auto reload/refresh mechanism, or 'replicas'.
2543
2545
{{- $excludeSectionRegexList := .excludeSectionRegexList -}}
2544
2546
{{- $excludeKeyList := .excludeKeyList -}}
2545
2547
{{- range $configElementName, $configElementDict := $config.data -}}
2546
- {{- $_ := set $configCtx "excludeSection" false -}}
2547
- {{- range $regex := $excludeSectionRegexList -}}
2548
- {{- if (regexMatch $regex $configElementName) -}}
2549
- {{- $_ := set $configCtx "excludeSection" true -}}
2550
- {{- end -}}
2548
+ {{- $_ := set $configCtx "excludeSection" false -}}
2549
+ {{- range $regex := $excludeSectionRegexList -}}
2550
+ {{- if (regexMatch $regex $configElementName) -}}
2551
+ {{- $_ := set $configCtx "excludeSection" true -}}
2551
2552
{{- end -}}
2552
- {{- if not $configCtx.excludeSection -}}
2553
- {{- $configDictCtx := dict -}}
2554
- {{- range $key := $excludeKeyList -}}
2555
- {{- $_ := set $configDictCtx "keyDictStr" (regexReplaceAll "(.*)\\ ..*$" $key "${1}") -}}
2556
- {{- if eq $configDictCtx.keyDictStr $key -}}{{/* single component key, e.g. "global"*/}}
2557
- {{- $configElementDict := (unset $configElementDict $key) -}}
2558
- {{- else -}}{{/* scopes component key, e.g. "eclccserver.queue"*/}}
2559
- {{- $_ := set $configDictCtx "keyKeyStr" (regexReplaceAll ".*\\ .(.*)$" $key "${1}") -}}
2560
- {{- $subDict := get $configElementDict $configDictCtx.keyDictStr -}}
2561
- {{- if $subDict -}}
2562
- {{- $_ := set $configElementDict $configDictCtx.keyDictStr (unset $subDict $configDictCtx.keyKeyStr) -}}
2553
+ {{- end -}}
2554
+ {{- if not $configCtx.excludeSection -}}
2555
+ {{- $configDictCtx := dict -}}
2556
+ {{- range $key := $excludeKeyList -}}
2557
+ {{- $keyParts := splitList "::" $key -}}
2558
+ {{- $outerRaw := index $keyParts 0 -}}
2559
+ {{- $outerIsWild := hasPrefix "~" $outerRaw -}}
2560
+ {{- $outerKey := trimPrefix "~" $outerRaw -}}
2561
+ {{- $hasSubKey := eq (len $keyParts) 2 -}}
2562
+ {{- $innerKey := "" -}}
2563
+ {{- $innerIsWild := false -}}
2564
+ {{- if $hasSubKey -}}
2565
+ {{- $innerRaw := index $keyParts 1 -}}
2566
+ {{- $innerIsWild = hasPrefix "~" $innerRaw -}}
2567
+ {{- $innerKey = trimPrefix "~" $innerRaw -}}
2568
+ {{- end -}}
2569
+ {{- range $topKey, $topVal := $configElementDict -}}
2570
+ {{- if or (and (not $outerIsWild) (eq $outerKey $topKey)) (and $outerIsWild (regexMatch $outerKey $topKey)) -}}
2571
+ {{- if not $hasSubKey -}}
2572
+ {{- $configElementDict = unset $configElementDict $topKey -}}
2573
+ {{- else -}}
2574
+ {{- $innerDict := get $configElementDict $topKey | default dict -}}
2575
+ {{- if (kindIs "map" $innerDict) -}}
2576
+ {{- if $innerIsWild -}}
2577
+ {{- range $k, $_ := $innerDict -}}
2578
+ {{- if regexMatch $innerKey $k -}}
2579
+ {{- $innerDict = unset $innerDict $k -}}
2580
+ {{- end -}}
2563
2581
{{- end -}}
2582
+ {{- else -}}
2583
+ {{- $innerDict = unset $innerDict $innerKey -}}
2584
+ {{- end -}}
2564
2585
{{- end -}}
2565
- {{- end -}}{{/*range $key*/}}
2566
- {{- $configYaml := toYaml $configElementDict -}}
2567
- {{- $_ := set $config.data $configElementName $configYaml -}}
2568
- {{- else -}}
2569
- {{- $configData := (unset $config.data $configElementName) -}}
2570
- {{- $_ := set $config "data" $configData -}}
2586
+ {{- $_ := set $configElementDict $topKey $innerDict -}}
2587
+ {{- end -}}
2588
+ {{- end -}}
2589
+ {{- end -}}
2571
2590
{{- end -}}
2591
+ {{- else -}}
2592
+ {{- $configData := (unset $config.data $configElementName) -}}
2593
+ {{- $_ := set $config "data" $configData -}}
2594
+ {{- end -}}
2572
2595
{{- end -}}{{/*range $configElementName*/}}
2573
2596
{{ toYaml $config }}
2574
2597
{{- end -}}
@@ -2598,9 +2621,10 @@ globalExcludeList below is a hard-coded list of global keys to exclude.
2598
2621
2599
2622
*/} }
2600
2623
{ {- define " hpcc.getConfigSHA" } }
2601
- { {- $globalExcludeList := list (printf " %s.replicas" .component) -} }
2602
- { {- $globalExcludeSectionRegexList := list " .*spec.yaml$" -} }
2603
- { {- $combinedExcludeKeyList := concat (splitList " ," (.excludeKeys | default " " )) $globalExcludeList -} }
2624
+ { {- $globalExcludeList := list " ~.*::replicas" -} }
2625
+ { {- $globalExcludeSectionRegexList := list " .*-job.yaml$" -} }
2626
+ { {- $componentExcludeList := ternary (splitList " ," (.excludeKeys | default " " )) list (hasKey . " excludeKeys" ) -} }
2627
+ { {- $combinedExcludeKeyList := concat $globalExcludeList $componentExcludeList -} }
2604
2628
{ {- $ctx := merge (omit . " excludeKeys" ) (dict " excludeSectionRegexList" $globalExcludeSectionRegexList " excludeKeyList" $combinedExcludeKeyList ) -} }
2605
2629
{ {- include " hpcc.filterConfig" $ctx | sha256sum } }
2606
2630
{ {- end -} }
0 commit comments