{{- /* Copyright (c) 2025 Firmansyah Nainggolan. All Rights Reserved. SPDX-License-Identifier: APACHE-2.0 */}} {{/* Create the name of the service account to use */}} {{- define "freeradius.serviceAccountName" -}} {{- if .Values.serviceAccount.create }} {{- default (include "st-common.names.fullname" .) .Values.serviceAccount.name }} {{- else }} {{- default "default" .Values.serviceAccount.name }} {{- end }} {{- end }} {{/* Return the path to the cert file. */}} {{- define "freeradius.tlsCert" -}} {{- if and .Values.tls.enabled .Values.tls.autoGenerated }} {{- printf "/opt/startechnica/freeradius/certs/tls.crt" -}} {{- else -}} {{- printf "/opt/startechnica/freeradius/certs/%s" .Values.tls.certFilename -}} {{- end -}} {{- end -}} {{/* Return the path to the cert key file. */}} {{- define "freeradius.tlsCertKey" -}} {{- if and .Values.tls.enabled .Values.tls.autoGenerated }} {{- printf "/opt/startechnica/freeradius/certs/tls.key" -}} {{- else -}} {{- printf "/opt/startechnica/freeradius/certs/%s" .Values.tls.certKeyFilename -}} {{- end -}} {{- end -}} {{/* Return the path to the CA cert file. */}} {{- define "freeradius.tlsCACert" -}} {{- if and .Values.tls.enabled .Values.tls.autoGenerated }} {{- printf "/opt/startechnica/freeradius/certs/ca.crt" -}} {{- else -}} {{- printf "/opt/startechnica/freeradius/certs/%s" .Values.tls.certCAFilename -}} {{- end -}} {{- end -}} {{/* Create the name of the SSL certificate to use */}} {{- define "freeradius.tlsSecretName" -}} {{- if .Values.tls.certificatesSecret }} {{ .Values.tls.certificatesSecret }} {{- else }} {{- default (printf "%s-tls" (include "st-common.names.fullname" .)) }} {{- end }} {{- end -}} {{/* Return true if a TLS secret object should be created */}} {{- define "freeradius.createTlsSecret" -}} {{- if and .Values.tls.enabled .Values.tls.autoGenerated (not .Values.tls.certificatesSecret) }} {{- true }} {{- end }} {{- end -}} {{/* Validate values of FreeRADIUS - Auth TLS enabled */}} {{- define "freeradius.validateValues.tls" -}} {{- if and .Values.tls.enabled (not .Values.tls.autoGenerated) (not .Values.tls.certificatesSecret) }} freeradius: tls.enabled In order to enable TLS, you also need to provide an existing secret containing the Keystore and Truststore or enable auto-generated certificates. {{- end }} {{- end -}} {{/* Return the path to the SQL cert file. */}} {{- define "freeradius.sqlTlsCert" -}} {{- if and .Values.modsEnabled.sql.tls.enabled }} {{- if .Values.modsEnabled.sql.tls.autoGenerated }} {{- printf "/opt/startechnica/freeradius/certs/sql-tls.crt" -}} {{- else if not (empty .Values.modsEnabled.sql.tls.certFilename) }} {{- printf "/opt/startechnica/freeradius/certs/%s" .Values.modsEnabled.sql.tls.certFilename -}} {{- end }} {{- else }} {{- printf "" -}} {{- end }} {{- end -}} {{/* Return the path to the SQL cert key file. */}} {{- define "freeradius.sqlTlsCertKey" -}} {{- if and .Values.modsEnabled.sql.tls.enabled }} {{- if .Values.modsEnabled.sql.tls.autoGenerated }} {{- printf "/opt/startechnica/freeradius/certs/sql-tls.key" -}} {{- else if not (empty .Values.modsEnabled.sql.tls.certKeyFilename) }} {{- printf "/opt/startechnica/freeradius/certs/%s" .Values.modsEnabled.sql.tls.certKeyFilename -}} {{- end }} {{- else }} {{- printf "" -}} {{- end }} {{- end -}} {{/* Return the path to the SQL CA cert file. */}} {{- define "freeradius.sqlTlsCACert" -}} {{- if and .Values.modsEnabled.sql.tls.enabled }} {{- if .Values.modsEnabled.sql.tls.autoGenerated }} {{- printf "/opt/startechnica/freeradius/certs/sql-ca.crt" -}} {{- else if not (empty .Values.modsEnabled.sql.tls.certCAFilename)}} {{- printf "/opt/startechnica/freeradius/certs/%s" .Values.modsEnabled.sql.tls.certCAFilename -}} {{- end }} {{- else }} {{- printf "" -}} {{- end }} {{- end -}} {{/* Create the name of the secret for SQL SSL certificate to use */}} {{- define "freeradius.sqlTlsSecretName" -}} {{- if .Values.modsEnabled.sql.tls.certificatesSecret }} {{ .Values.modsEnabled.sql.tls.certificatesSecret }} {{- else }} {{- default (printf "%s-sql-tls" (include "st-common.names.fullname" .)) }} {{- end }} {{- end -}} {{/* Return true if a TLS secret object should be created */}} {{- define "freeradius.createSqlTlsSecret" -}} {{- if and .Values.modsEnabled.sql.tls.enabled .Values.modsEnabled.sql.tls.autoGenerated (not .Values.modsEnabled.sql.tls.certificatesSecret) }} {{- true }} {{- end }} {{- end -}} {{/* Get the configuration ConfigMap name. */}} {{- define "freeradius.configurationCM" -}} {{- if .Values.configurationConfigMap -}} {{- printf "%s" (tpl .Values.configurationConfigMap $) -}} {{- else -}} {{- printf "%s-configuration" (include "st-common.names.fullname" .) -}} {{- end -}} {{- end -}} {{/* Get the initialization scripts ConfigMap name. */}} {{- define "freeradius.initdbScriptsCM" -}} {{- if .Values.initdbScriptsConfigMap -}} {{- printf "%s" .Values.initdbScriptsConfigMap -}} {{- else -}} {{- printf "%s-init-scripts" (include "st-common.names.fullname" .) -}} {{- end -}} {{- end -}}