mirror of
https://github.com/truecharts/library-charts.git
synced 2026-07-05 11:26:22 -03:00
merge validation
This commit is contained in:
@@ -1,29 +0,0 @@
|
||||
{{- define "ix.v1.common.externalInterface.validate" -}}
|
||||
{{- $iface := .iface -}}
|
||||
|
||||
{{- if not $iface.hostInterface -}}
|
||||
{{- fail "<hostInterface> is required when configuring External Interfaces." -}}
|
||||
{{- end -}}
|
||||
{{- if not $iface.ipam.type -}}
|
||||
{{- fail (printf "<ipam.type> is required. Interface (%s)" $iface.hostInterface) -}}
|
||||
{{- else if not (mustHas $iface.ipam.type (list "static" "dhcp")) -}}
|
||||
{{- fail (printf "Invalid option for <ipam.type> (%s). Valid options are static and dhcp. Interface (%s)" $iface.ipam.type $iface.hostInterface) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if and (or $iface.staticIPConfigurations $iface.staticRoutes) (ne $iface.ipam.type "static") -}}
|
||||
{{- fail (printf "<staticIPConfigurations> and <staticRoutes> cannot be used with <ipam.type> of (%s). Interface (%s)" $iface.ipam.type $iface.hostInterface) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if eq $iface.ipam.type "static" -}}
|
||||
{{- if not $iface.staticIPConfigurations -}}
|
||||
{{- fail (printf "Static IP is required when <ipam.type> is static. Interface (%s)" $iface.hostInterface) -}}
|
||||
{{- end -}}
|
||||
{{- with $iface.staticRoutes -}}
|
||||
{{- range . -}}
|
||||
{{- if or (not .destination) (not .gateway) -}}
|
||||
{{- fail (printf "<destination> and <gateway> are required when <staticRoutes> are defined. Interface (%s)" $iface.hostInterface) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
@@ -1,8 +1,34 @@
|
||||
{{- define "ix.v1.common.spawner.externalInterface" -}}
|
||||
{{/* Validate that data from externalInterfaces are correct before start creating objects */}}
|
||||
{{- range .Values.externalInterfaces -}}
|
||||
{{- include "ix.v1.common.externalInterface.validate" (dict "iface" .) -}}
|
||||
{{- range $iface := .Values.externalInterfaces -}}
|
||||
{{- if not $iface.hostInterface -}}
|
||||
{{- fail "<hostInterface> is required when configuring External Interfaces." -}}
|
||||
{{- end -}}
|
||||
{{- if not $iface.ipam.type -}}
|
||||
{{- fail (printf "<ipam.type> is required. Interface (%s)" $iface.hostInterface) -}}
|
||||
{{- else if not (mustHas $iface.ipam.type (list "static" "dhcp")) -}}
|
||||
{{- fail (printf "Invalid option for <ipam.type> (%s). Valid options are static and dhcp. Interface (%s)" $iface.ipam.type $iface.hostInterface) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if and (or $iface.staticIPConfigurations $iface.staticRoutes) (ne $iface.ipam.type "static") -}}
|
||||
{{- fail (printf "<staticIPConfigurations> and <staticRoutes> cannot be used with <ipam.type> of (%s). Interface (%s)" $iface.ipam.type $iface.hostInterface) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if eq $iface.ipam.type "static" -}}
|
||||
{{- if not $iface.staticIPConfigurations -}}
|
||||
{{- fail (printf "Static IP is required when <ipam.type> is static. Interface (%s)" $iface.hostInterface) -}}
|
||||
{{- end -}}
|
||||
{{- with $iface.staticRoutes -}}
|
||||
{{- range . -}}
|
||||
{{- if or (not .destination) (not .gateway) -}}
|
||||
{{- fail (printf "<destination> and <gateway> are required when <staticRoutes> are defined. Interface (%s)" $iface.hostInterface) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* Now we are sure data is validated, spawn the objects */}}
|
||||
{{- range $index, $iface := .Values.ixExternalInterfacesConfiguration -}}
|
||||
{{- include "ix.v1.common.class.externalInterface" (dict "iface" $iface "index" $index "root" $) -}}
|
||||
{{- end -}}
|
||||
|
||||
Reference in New Issue
Block a user