Skip to content

Commit

Permalink
feat: initial version of ejabberd chart (#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
JuniorJPDJ authored Jun 6, 2024
1 parent 4fc107a commit 4f2d829
Show file tree
Hide file tree
Showing 6 changed files with 445 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
charts/*/charts/
.idea/
charts/*/output/
25 changes: 25 additions & 0 deletions charts/ejabberd/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
# helm-docs templates
*.gotmpl
31 changes: 31 additions & 0 deletions charts/ejabberd/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
apiVersion: v2
name: ejabberd
description: Robust, Ubiquitous and Massively Scalable Messaging Platform (XMPP, MQTT, SIP Server)
type: application
version: 0.1.0
# renovate: image=ghcr.io/juniorjpdj/containers/ejabberd-captcha
appVersion: 24.02-r1
kubeVersion: ">=1.22.0-0"
keywords:
- ejabberd
- jabber
- xmpp
- communication
- IM
- instant-messenger
dependencies:
- name: common
repository: https://bjw-s.github.io/helm-charts
version: 3.1.0
sources:
- https://github.com/processone/ejabberd
- https://github.com/JuniorJPDJ/containers
- https://github.com/JuniorJPDJ/charts/tree/master/charts/ejabberd
annotations:
artifacthub.io/links: |-
- name: App Source
url: https://github.com/processone/ejabberd
- name: Dockerfile Source
url: https://github.com/JuniorJPDJ/containers
- name: Chart Source
url: https://github.com/JuniorJPDJ/charts/tree/master/charts/ejabberd
18 changes: 18 additions & 0 deletions charts/ejabberd/templates/certificates.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{{- include "bjw-s.common.loader.init" . }}
{{- $dot := . }}
{{- range $name, $v := .Values.certificates }}
{{- if dig "enabled" true $v }}
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: {{ include "bjw-s.common.lib.chart.names.fullname" $dot }}-{{ $name }}
spec:
dnsNames:
{{- toYaml $v.dnsNames | nindent 4 }}
issuerRef:
{{- toYaml $v.issuerRef | nindent 4 }}
secretName: {{ include "bjw-s.common.lib.chart.names.fullname" $dot }}-{{ $name }}-cert
---

{{- end }}
{{- end }}
53 changes: 53 additions & 0 deletions charts/ejabberd/templates/common.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{{/* Preprocess values and prepare config file */}}
{{- include "bjw-s.common.loader.init" . }}
{{- define "ejabberd.preprocess" -}}
controllers:
main:
containers:
main:
image:
{{- toYaml .Values.image | nindent 10 }}

persistence:
{{- $dot := . }}
{{- range $name, $v := .Values.certificates }}
{{- if dig "enabled" true $v }}
{{- printf "%s-cert" $name | nindent 2 }}:
type: secret
name: {{ include "bjw-s.common.lib.chart.names.fullname" $dot }}-{{ $name }}-cert
globalMounts:
- path: /home/ejabberd/conf/certs/{{ $name }}
readOnly: true
{{- end }}
{{- end }}

configMaps:
config:
data:
{{- range $name, $cfg := .Values.configs }}
{{ quote $name }}: |-
{{- toYaml $cfg | nindent 8 }}
{{- end }}
{{- end -}}

{{/* Template for generating certfiles from certificates */}}
{{- define "ejabberd.dynamic_certfiles" -}}
{{- range $name, $v := .Values.certificates }}
{{- if dig "enabled" true $v }}
- /home/ejabberd/conf/certs/{{ $name }}/tls.crt
- /home/ejabberd/conf/certs/{{ $name }}/tls.key
{{- end }}
{{- end }}
{{- end -}}

{{/* Concatenate certfiles from certificates and provided by user */}}
{{- $ejabberdyml := get .Values.configs "ejabberd.yml" }}
{{- $certfiles := concat (dig "certfiles" (list) $ejabberdyml) (include "ejabberd.dynamic_certfiles" . | fromYamlArray) }}
{{- $_ := set $ejabberdyml "certfiles" (default (list) $certfiles) }}
{{- $_ = set .Values.configs "ejabberd.yml" $ejabberdyml }}

{{/* Merge values provided by user with those generated by preprocessing */}}
{{- $_ = mustMerge .Values (include "ejabberd.preprocess" . | fromYaml) -}}

{{/* Render the templates */}}
{{- include "bjw-s.common.loader.all" . }}
Loading

0 comments on commit 4f2d829

Please sign in to comment.