Skip to content

Commit

Permalink
Integrate Helm
Browse files Browse the repository at this point in the history
  • Loading branch information
Danielius1922 committed Aug 15, 2024
1 parent 6c29c6d commit 3b09c6b
Show file tree
Hide file tree
Showing 23 changed files with 1,233 additions and 26 deletions.
114 changes: 114 additions & 0 deletions charts/plgd-hub/templates/device-provisioning-service/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
{{- define "plgd-hub.deviceprovisioningservice.fullname" -}}
{{- if .Values.deviceprovisioningservice.fullnameOverride }}
{{- .Values.deviceprovisioningservice.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Values.deviceprovisioningservice.name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s-%s" .Release.Name $name .Values.deviceprovisioningservice.name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{- define "plgd-hub.deviceprovisioningservice.configName" -}}
{{- $fullName := include "plgd-hub.deviceprovisioningservice.fullname" . -}}
{{- printf "%s-cfg" $fullName }}
{{- end -}}

{{- define "plgd-hub.deviceprovisioningservice.apiDomain" -}}
{{- if .Values.deviceprovisioningservice.apiDomain }}
{{- printf "%s" .Values.deviceprovisioningservice.apiDomain }}
{{- else }}
{{- printf "api.%s" .Values.global.domain }}
{{- end }}
{{- end }}

{{- define "plgd-hub.deviceprovisioningservice.image" -}}
{{- $registryName := .Values.deviceprovisioningservice.image.registry | default "" -}}
{{- $repositoryName := .Values.deviceprovisioningservice.image.repository -}}
{{- $tag := .Values.deviceprovisioningservice.image.tag | default .Chart.AppVersion | toString -}}
{{- printf "%s%s:%s" $registryName $repositoryName $tag -}}
{{- end -}}

{{- define "plgd-hub.deviceprovisioningservice.serviceCertificateMountPath" }}
{{- .Values.deviceprovisioningservice.service.certificate.mountPath | default "/certs" }}
{{- end }}

{{- define "plgd-hub.deviceprovisioningservice.clientCertName" -}}
{{- $fullName := include "plgd-hub.deviceprovisioningservice.fullname" . }}
{{- printf "%s-client-crt" $fullName -}}
{{- end }}

{{- define "plgd-hub.deviceprovisioningservice.serviceCertName" -}}
{{- $fullName := include "plgd-hub.deviceprovisioningservice.fullname" . }}
{{- printf "%s-crt" $fullName -}}
{{- end }}

{{- define "plgd-hub.deviceprovisioningservice.domainCertName" -}}
{{- $fullName := include "plgd-hub.deviceprovisioningservice.fullname" . }}
{{- if .Values.deviceprovisioningservice.ingress.domainCertName }}
{{- .Values.deviceprovisioningservice.ingress.domainCertName }}
{{- else }}
{{- printf "%s-domain-crt" $fullName -}}
{{- end }}
{{- end }}

{{- define "plgd-hub.deviceprovisioningservice.selectorLabels" -}}
app.kubernetes.io/name: {{ .Values.deviceprovisioningservice.name }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{- define "plgd-hub.deviceprovisioningservice.labels" -}}
helm.sh/chart: {{ include "plgd-hub.chart" . }}
{{ include "plgd-hub.deviceprovisioningservice.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}


{{- define "plgd-hub.deviceprovisioningservice.authority" }}
{{- $ := index . 0 }}
{{- $authProvider := index . 1 }}
{{- $authority := required "Authorization authority is required. Set global.authority or authority per enrollment group or in case you use the DPS with the mock OAuth Server, make sure global.domain is set." ( $authProvider.authority | default ( $.Values.global.authority | default $.Values.global.domain )) }}
{{- if hasPrefix "http" $authority }}
{{- $authority }}
{{- else }}
{{- printf "https://%s" $authority }}
{{- end }}
{{- end }}

{{- define "plgd-hub.deviceprovisioningservice.coapGateway" }}
{{- $ := index . 0 }}
{{- $hub := index . 1 }}
{{- $_ := required "CoAP Gateway address is required. Use global.domain or deviceprovisioningservice.enrollmentGroups[].hub.coapGateway. In case of using global domain, default port 5684 or coapgateway.service.nodePort.port if specified is used" ( $hub.coapGateway | default $.Values.global.domain ) }}
{{- if $hub.coapGateway }}
{{- $hub.coapGateway }}
{{- else }}
{{- printf "%s:%v" $.Values.global.domain ( $.Values.coapgateway.service.nodePort | default 5684 ) }}
{{- end }}
{{- end }}

{{- define "plgd-hub.deviceprovisioningservice.certificateAuthority" }}
{{- $ := index . 0 }}
{{- $certificateAuthority := index . 1 }}
{{- $ret := "" }}
{{- if $certificateAuthority }}
{{- if $certificateAuthority.grpc }}
{{- if $certificateAuthority.grpc.address }}
{{- $ret = $certificateAuthority.grpc.address }}
{{- end }}
{{- end }}
{{- end }}
{{- if and (empty $ret) $.Values.certificateauthority }}
{{- if $.Values.certificateauthority.domain }}
{{- $ret = printf "%s:443" $.Values.certificateauthority.domain }}
{{- end }}
{{- end }}
{{- if empty $ret }}
{{- $ret = printf "api.%s:443" $.Values.global.domain }}
{{- end }}
{{- $ret }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{{- $clientCertName := include "plgd-hub.deviceprovisioningservice.clientCertName" . }}
{{- if and $clientCertName .Values.certmanager.enabled }}
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: {{ $clientCertName }}-client
namespace: {{ .Release.Namespace }}
labels:
{{- include "plgd-hub.deviceprovisioningservice.labels" . | nindent 4 }}
{{- with .Values.certmanager.internal.labels }}
{{- . | toYaml | nindent 4 }}
{{- end }}
{{- with .Values.certmanager.internal.annotations }}
annotations:
{{- . | toYaml | nindent 4 }}
{{- end }}
spec:
secretName: {{ $clientCertName }}
commonName: {{ $clientCertName | quote }}
privateKey:
algorithm: {{ .Values.certmanager.internal.cert.key.algorithm | default .Values.certmanager.default.cert.key.algorithm }}
size: {{ .Values.certmanager.internal.cert.key.size | default .Values.certmanager.default.cert.key.size }}
usages:
- client auth
duration: {{ .Values.certmanager.internal.cert.duration | default .Values.certmanager.default.cert.duration }}
renewBefore: {{ .Values.certmanager.internal.cert.renewBefore | default .Values.certmanager.default.cert.renewBefore }}
issuerRef:
name: {{ .Values.certmanager.internal.issuer.name | default .Values.certmanager.default.issuer.name }}
kind: {{ .Values.certmanager.internal.issuer.kind | default .Values.certmanager.default.issuer.kind }}
group: {{ .Values.certmanager.internal.issuer.group | default .Values.certmanager.default.issuer.group }}
{{- end }}
Loading

0 comments on commit 3b09c6b

Please sign in to comment.