1111
1212 { {- if gt (len .) 3 } } { {- $currentDir = index . 3 } } { {- else } } { {- $currentDir = $rootDir } } { {- end } }
1313 { {- if gt (len .) 4 } } { {- $fileList = index . 4 } } { {- end } }
14-
14+
1515 { {- $currentDirIndex := (sub ($currentDir | splitList " /" | len) 1) } }
1616 { {- $rootDirIndex := (sub ($rootDir | splitList " /" | len) 1) } }
1717 { {- $folderNamesIndex := (add1 $rootDirIndex ) } }
2222 { {- if gt (len $fileList ) 0 } }
2323 { {- $shouldProcess = has $path $fileList } }
2424 { {- end } }
25-
25+
2626 { {- if $shouldProcess } }
2727 { {- $fileName := ($path | splitList " /" | last ) } }
2828 { {- $definition := " " } }
6262 { {- $useObservabilityRules := has " observability.deckhouse.io/v1alpha1/ClusterObservabilityMetricsRulesGroup" $context .Values.global.discovery.apiVersions } }
6363 { {- if and $hasObservabilityModule $useObservabilityRules } }
6464 { {- range $idx , $group := $definitionStruct .Rules } }
65- { {- $_ := unset $group " name" } }
66- { {- $resourceName = $resourceName | replace " propagated-" " " } }
67- { {- $groupResourceName := printf " %s-%d" $resourceName $idx } }
65+ { {- if $group .rules } }
66+ { {- $_ := unset $group " name" } }
67+ { {- $resourceName = $resourceName | replace " propagated-" " " } }
68+ { {- $groupResourceName := printf " %s-%d" $resourceName $idx } }
6869---
6970apiVersion: observability.deckhouse.io/v1alpha1
7071kind: { { $propagated | ternary " ClusterObservabilityPropagatedMetricsRulesGroup" " ClusterObservabilityMetricsRulesGroup" } }
@@ -73,6 +74,7 @@ metadata:
7374 { {- include " helm_lib_module_labels" (list $context (dict " app" " prometheus" " prometheus" " main" " component" " rules" )) | nindent 2 } }
7475spec:
7576 { {- $group | toYaml | nindent 2 } }
77+ { {- end } }
7678 { {- end } }
7779 { {- else } }
7880 { {- if $definitionStruct .Rules } }
@@ -87,7 +89,7 @@ metadata:
8789spec:
8890 groups:
8991 { {- $definition | nindent 4 } }
90- { {- end } }
92+ { {- end } }
9193 { {- end } }
9294 { {- end } }
9395 { {- end } }
@@ -130,4 +132,4 @@ spec:
130132 { {- else -} }
131133{ { $timeout } }s
132134 { {- end } }
133- { {- end } }
135+ { {- end } }
0 commit comments