@@ -22,13 +22,12 @@ create
22
22
{ {- define " secrets.getSecretFromRef" -} }
23
23
{ {- $value := .object -} }
24
24
{ {- range $pathPart := (regexSplit " \\ ." (printf " %sFrom" .key) -1) -} } { {/* " path.to.auth.password" --> [" path" , " to" , " auth" " passwordFrom" ] */} }
25
- { {- if not $pathPart -} }
26
- { {- continue -} }
27
- { {- else if hasKey $value $pathPart -} }
28
- { {- $value = (index $value $pathPart ) -} }
29
- { {- else -} }
30
- { {- $value = " " -} }
31
- { {- break -} }
25
+ { {- if $pathPart -} }
26
+ { {- if and (not (kindIs " string" $value )) (hasKey $value $pathPart ) -} }
27
+ { {- $value = (index $value $pathPart ) -} }
28
+ { {- else -} }
29
+ { {- $value = " " -} }
30
+ { {- end -} }
32
31
{ {- end -} }
33
32
{ {- end -} }
34
33
{ {- $value -} }
@@ -40,13 +39,12 @@ create
40
39
{ {- $value := .object -} }
41
40
{ {- $defaultKey := (( regexSplit " \\ ." .key -1) | last) -} } { {/* " path.to.auth.password" --> " password" */} }
42
41
{ {- range $pathPart := (regexSplit " \\ ." (printf " %sKey" .key) -1) -} } { {/* " path.to.auth.password" --> [" path" , " to" , " auth" " passwordKey" ] */} }
43
- { {- if not $pathPart -} }
44
- { {- continue -} }
45
- { {- else if hasKey $value $pathPart -} }
46
- { {- $value = (index $value $pathPart ) -} }
47
- { {- else -} }
48
- { {- $value = $defaultKey -} }
49
- { {- break -} }
42
+ { {- if $pathPart -} }
43
+ { {- if and (not (kindIs " string" $value )) (hasKey $value $pathPart ) -} }
44
+ { {- $value = (index $value $pathPart ) -} }
45
+ { {- else -} }
46
+ { {- $value = $defaultKey -} }
47
+ { {- end -} }
50
48
{ {- end -} }
51
49
{ {- end -} }
52
50
{ {- $value -} }
@@ -58,13 +56,12 @@ create
58
56
{ {- $found := true } }
59
57
{ {- $value := .object -} }
60
58
{ {- range $pathPart := (regexSplit " \\ ." (printf " %sKey" .key) -1) -} } { {/* " path.to.auth.password" --> [" path" , " to" , " auth" " passwordKey" ] */} }
61
- { {- if not $pathPart -} }
62
- { {- continue -} }
63
- { {- else if hasKey $value $pathPart -} }
64
- { {- $value = (index $value $pathPart ) -} }
65
- { {- else -} }
66
- { {- $found = false -} }
67
- { {- break -} }
59
+ { {- if $pathPart -} }
60
+ { {- if and (not (kindIs " string" $value )) (hasKey $value $pathPart ) -} }
61
+ { {- $value = (index $value $pathPart ) -} }
62
+ { {- else -} }
63
+ { {- $found = false -} }
64
+ { {- end -} }
68
65
{ {- end -} }
69
66
{ {- end -} }
70
67
{ {- $found -} }
@@ -75,13 +72,12 @@ create
75
72
{ {- define " secrets.getSecretValue" } }
76
73
{ {- $value := .object -} }
77
74
{ {- range $pathPart := (regexSplit " \\ ." .key -1) -} } { {/* " path.to.auth.password" --> [" path" , " to" , " auth" " password" ] */} }
78
- { {- if not $pathPart -} }
79
- { {- continue -} }
80
- { {- else if hasKey $value $pathPart -} }
81
- { {- $value = (index $value $pathPart ) -} }
82
- { {- else -} }
83
- { {- $value = " " -} }
84
- { {- break -} }
75
+ { {- if $pathPart -} }
76
+ { {- if and (not (kindIs " string" $value )) (hasKey $value $pathPart ) -} }
77
+ { {- $value = (index $value $pathPart ) -} }
78
+ { {- else -} }
79
+ { {- $value = " " -} }
80
+ { {- end -} }
85
81
{ {- end -} }
86
82
{ {- end -} }
87
83
{ {- $value -} }
@@ -129,9 +125,9 @@ remote.kubernetes.secret.{{ include "helper.alloy_name" .object.name }}.data[{{
129
125
{ {- $keyDefined := include " secrets.isSecretKeyDefined" (dict " object" $ " key" $secret ) -} }
130
126
{ {- $value := include " secrets.getSecretValue" (dict " object" $ " key" $secret ) -} }
131
127
{ {- if (eq $secretType " external" ) } }
132
- { {- if eq $keyDefined " true" } }{ {- $usesK8sSecret = true } }{ { break } } { { - end } }
128
+ { {- if eq $keyDefined " true" } }{ {- $usesK8sSecret = true } }{ {- end } }
133
129
{ {- else } }
134
- { {- if and $value (not $ref ) } }{ {- $usesK8sSecret = true } }{ { break } } { { - end } }
130
+ { {- if and $value (not $ref ) } }{ {- $usesK8sSecret = true } }{ {- end } }
135
131
{ {- end } }
136
132
{ {- end } }
137
133
{ {- $usesK8sSecret -} }
0 commit comments