mirror of
https://github.com/bjw-s-labs/helm-charts.git
synced 2025-07-04 08:57:04 +02:00
feat(common): Release 2.0.0-beta.2 (#176)
This commit is contained in:
parent
ed407c00df
commit
9928235b84
80 changed files with 1306 additions and 161 deletions
|
@ -0,0 +1,22 @@
|
|||
{{/*
|
||||
Validate networkPolicy values
|
||||
*/}}
|
||||
{{- define "bjw-s.common.lib.networkpolicy.validate" -}}
|
||||
{{- $rootContext := .rootContext -}}
|
||||
{{- $networkpolicyObject := .object -}}
|
||||
|
||||
{{- if and (not (hasKey $networkpolicyObject "podSelector")) (empty (get $networkpolicyObject "controller")) -}}
|
||||
{{- fail (printf "controller reference or podSelector is required for NetworkPolicy. (NetworkPolicy %s)" $networkpolicyObject.identifier) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if empty (get $networkpolicyObject "policyTypes") -}}
|
||||
{{- fail (printf "policyTypes is required for NetworkPolicy. (NetworkPolicy %s)" $networkpolicyObject.identifier) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $allowedpolicyTypes := list "Ingress" "Egress" -}}
|
||||
{{- range $networkpolicyObject.policyTypes -}}
|
||||
{{- if not (has . $allowedpolicyTypes) -}}
|
||||
{{- fail (printf "Not a valid policyType for NetworkPolicy. (NetworkPolicy %s, value %s)" $networkpolicyObject.identifier .) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
|
@ -0,0 +1,24 @@
|
|||
{{/*
|
||||
Convert networkPolicy values to an object
|
||||
*/}}
|
||||
{{- define "bjw-s.common.lib.networkpolicy.valuesToObject" -}}
|
||||
{{- $rootContext := .rootContext -}}
|
||||
{{- $identifier := .id -}}
|
||||
{{- $objectValues := .values -}}
|
||||
|
||||
{{- /* Determine and inject the networkPolicy name */ -}}
|
||||
{{- $objectName := (include "bjw-s.common.lib.chart.names.fullname" $rootContext) -}}
|
||||
|
||||
{{- if $objectValues.nameOverride -}}
|
||||
{{- $objectName = printf "%s-%s" $objectName $objectValues.nameOverride -}}
|
||||
{{- else -}}
|
||||
{{- if ne $identifier "main" -}}
|
||||
{{- $objectName = printf "%s-%s" $objectName $identifier -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- $_ := set $objectValues "name" $objectName -}}
|
||||
{{- $_ := set $objectValues "identifier" $identifier -}}
|
||||
|
||||
{{- /* Return the networkPolicy object */ -}}
|
||||
{{- $objectValues | toYaml -}}
|
||||
{{- end -}}
|
Loading…
Add table
Add a link
Reference in a new issue