Skip to content

Commit 3fd6504

Browse files
committed
fix(templates): add lookup guard for BondConfig generation
Add nil check for lookup result before accessing .spec.bondMaster in the multi-doc BondConfig template. While is_bond already validates the resource exists, this defensive check prevents template errors if the resource becomes unavailable between the two lookups. Assisted-By: Claude <[email protected]> Signed-off-by: Aleksei Sviridkin <[email protected]>
1 parent da0a22b commit 3fd6504

2 files changed

Lines changed: 4 additions & 0 deletions

File tree

‎charts/cozystack/templates/_helpers.tpl‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ nameservers:
159159
{{- $isBondInterface := include "talm.discovered.is_bond" $interfaceName }}
160160
{{- if $isBondInterface }}
161161
{{- $link := lookup "links" "" $interfaceName }}
162+
{{- if $link }}
162163
{{- $bondMaster := $link.spec.bondMaster }}
163164
{{- $slaves := fromJsonArray (include "talm.discovered.bond_slaves" $link.spec.index) }}
164165
---
@@ -194,6 +195,7 @@ routes:
194195
- gateway: {{ include "talm.discovered.default_gateway" . }}
195196
{{- end }}
196197
{{- end }}
198+
{{- end }}
197199
{{- if $isVlan }}
198200
---
199201
apiVersion: v1alpha1

‎charts/generic/templates/_helpers.tpl‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ nameservers:
8282
{{- $isBondInterface := include "talm.discovered.is_bond" $interfaceName }}
8383
{{- if $isBondInterface }}
8484
{{- $link := lookup "links" "" $interfaceName }}
85+
{{- if $link }}
8586
{{- $bondMaster := $link.spec.bondMaster }}
8687
{{- $slaves := fromJsonArray (include "talm.discovered.bond_slaves" $link.spec.index) }}
8788
---
@@ -117,6 +118,7 @@ routes:
117118
- gateway: {{ include "talm.discovered.default_gateway" . }}
118119
{{- end }}
119120
{{- end }}
121+
{{- end }}
120122
{{- if $isVlan }}
121123
---
122124
apiVersion: v1alpha1

0 commit comments

Comments
 (0)