diff --git a/plugins/contrib/values-compilers/09-maildev.js b/plugins/contrib/values-compilers/09-maildev.js new file mode 100644 index 0000000000..d10b2cc49a --- /dev/null +++ b/plugins/contrib/values-compilers/09-maildev.js @@ -0,0 +1,48 @@ +function isMaildevComponent(component) { + return component[`~chart`]?.endsWith(".contrib.maildev") +} + +function extractMaildevComponents(values, acc = []) { + Object.entries(values).forEach(([key, component]) => { + if (typeof component === "object" && component !== null) { + extractMaildevComponents(component, acc) + if (component._isChartValues && isMaildevComponent(component)) { + acc.push([key, component]) + } + } + }) + return acc +} + +const maildev = async (values, _options, { _config, utils, _ctx }) => { + console.log("maildev", values) + const { deepmerge } = utils + + const components = extractMaildevComponents(values) + + components.forEach(([key, component]) => { + const persistenceEnabled = + component.persistence.enabled !== null + ? component.persistence.enabled + : !!values.global.env.preprod + + /** @type {import("./09-maildev-schema").MailDevSchema} */ + const maildevValues = { + host: component.host || `${key}-${values.global.host}`, + repositoryName: values.global.repositoryName, + ingress: { + annotations: values.global.ingress.annotations, + }, + persistence: { + enabled: persistenceEnabled, + }, + cron: { + enabled: persistenceEnabled, + }, + } + + deepmerge(component, maildevValues) + }) +} + +module.exports = maildev diff --git a/plugins/fabrique/charts/maildev/Chart.yaml b/plugins/fabrique/charts/maildev/Chart.yaml deleted file mode 100644 index 7ce07e5da5..0000000000 --- a/plugins/fabrique/charts/maildev/Chart.yaml +++ /dev/null @@ -1,8 +0,0 @@ -apiVersion: v2 -name: maildev -version: 1.136.3 -dependencies: - - name: maildev - degit: socialgouv/helm-charts/charts/maildev@v1 - condition: maildev.enabled - version: "1" \ No newline at end of file diff --git a/plugins/fabrique/charts/maildev/values.yaml b/plugins/fabrique/charts/maildev/values.yaml deleted file mode 100644 index efb7039fbc..0000000000 --- a/plugins/fabrique/charts/maildev/values.yaml +++ /dev/null @@ -1,10 +0,0 @@ -maildev: - enabled: true - ~tpl~host: '{{ tpl (or .Values.host (print (or .Values.component (index .Values.kontinuous.chartContext 2)) "-" (or .Values.global.host ""))) $ }}' - ~tpl~repositoryName: "{{ .Values.global.repositoryName }}" - ingress: - ~tpl~annotations: "{{ .Values.global.ingress.annotations | toJson }}" - persistence: - ~tpl~enabled: "{{ if (eq .Values.global.env `preprod`) }}true{{ else }}false{{ end }}" - cron: - ~tpl~enabled: "{{ if (eq .Values.global.env `preprod`) }}true{{ else }}false{{ end }}" \ No newline at end of file diff --git a/plugins/fabrique/values-compilers/index.js b/plugins/fabrique/values-compilers/index.js index acc01d1414..397653da6d 100644 --- a/plugins/fabrique/values-compilers/index.js +++ b/plugins/fabrique/values-compilers/index.js @@ -9,5 +9,6 @@ module.exports = [ "./global-defaults.js", + "../charts/contrib/values-compilers/09-maildev.js", "../charts/contrib/values-compilers/10-tpl-meta-values", ] diff --git a/plugins/fabrique/values.yaml b/plugins/fabrique/values.yaml index 8aef2dd17d..440e46d05e 100644 --- a/plugins/fabrique/values.yaml +++ b/plugins/fabrique/values.yaml @@ -2,8 +2,6 @@ pg: enabled: false pgweb: enabled: false -maildev: - enabled: false keycloakx: enabled: false contrib: