feat(common): Release 2.0.0-beta.2 (#176)

This commit is contained in:
Bᴇʀɴᴅ Sᴄʜᴏʀɢᴇʀs 2023-09-14 15:40:49 +02:00 committed by GitHub
parent ed407c00df
commit 9928235b84
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
80 changed files with 1306 additions and 161 deletions

View file

@ -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 -}}

View file

@ -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 -}}