Skip to content

Commit

Permalink
fix: maildev value compiler (#457)
Browse files Browse the repository at this point in the history
  • Loading branch information
matmut7 authored Feb 7, 2024
1 parent 5a0c2b9 commit 0e27dcb
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 42 deletions.
18 changes: 9 additions & 9 deletions packages/kontinuous/tests/__snapshots__/maildev.dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,16 @@ metadata:
app.kubernetes.io/manifest-managed-by: kontinuous
app.kubernetes.io/manifest-created-by: kontinuous
annotations:
kontinuous/chartPath: project.fabrique.maildev.maildev
kontinuous/source: project/charts/fabrique/charts/maildev/charts/maildev/templates/deployment.yaml
kontinuous/chartPath: project.fabrique.contrib.maildev
kontinuous/source: project/charts/fabrique/charts/contrib/charts/maildev/templates/deployment.yaml
kontinuous/deployment: test-maildev-feature-branch-1-ffac537e6cbbf934b08745a-5iniqvup
kontinuous/depname.full: project.fabrique.maildev.maildev.deployment.maildev
kontinuous/depname.full: project.fabrique.contrib.maildev.deployment.maildev
kontinuous/depname.chartResource: maildev.deployment.maildev
kontinuous/depname.chartName: maildev
kontinuous/depname.chartPath: project.fabrique.maildev.maildev
kontinuous/depname.chartPath: project.fabrique.contrib.maildev
kontinuous/depname.resourcePath: deployment.maildev
kontinuous/depname.resourceName: maildev
kontinuous/depname.chartNameTopFull: maildev.maildev
kontinuous/depname.chartNameTopFull: maildev
kontinuous/depname.chartNameTop: maildev
kontinuous/plugin.log: \\"false\\"
reloader.stakater.com/auto: \\"true\\"
Expand Down Expand Up @@ -182,8 +182,8 @@ metadata:
app.kubernetes.io/manifest-created-by: kontinuous
name: maildev
annotations:
kontinuous/chartPath: project.fabrique.maildev.maildev
kontinuous/source: project/charts/fabrique/charts/maildev/charts/maildev/templates/service.yaml
kontinuous/chartPath: project.fabrique.contrib.maildev
kontinuous/source: project/charts/fabrique/charts/contrib/charts/maildev/templates/service.yaml
kontinuous/deployment: test-maildev-feature-branch-1-ffac537e6cbbf934b08745a-5iniqvup
namespace: test-maildev-feature-branch-1
spec:
Expand All @@ -203,8 +203,8 @@ kind: Ingress
metadata:
annotations:
kubernetes.io/ingress.class: nginx
kontinuous/chartPath: project.fabrique.maildev.maildev
kontinuous/source: project/charts/fabrique/charts/maildev/charts/maildev/templates/ingress.yaml
kontinuous/chartPath: project.fabrique.contrib.maildev
kontinuous/source: project/charts/fabrique/charts/contrib/charts/maildev/templates/ingress.yaml
kontinuous/deployment: test-maildev-feature-branch-1-ffac537e6cbbf934b08745a-5iniqvup
labels:
component: maildev
Expand Down
18 changes: 9 additions & 9 deletions packages/kontinuous/tests/__snapshots__/maildev.prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,16 @@ metadata:
app.kubernetes.io/manifest-managed-by: kontinuous
app.kubernetes.io/manifest-created-by: kontinuous
annotations:
kontinuous/chartPath: project.fabrique.maildev.maildev
kontinuous/source: project/charts/fabrique/charts/maildev/charts/maildev/templates/deployment.yaml
kontinuous/chartPath: project.fabrique.contrib.maildev
kontinuous/source: project/charts/fabrique/charts/contrib/charts/maildev/templates/deployment.yaml
kontinuous/deployment: test-maildev-feature-branch-1-ffac537e6cbbf934b08745a-5iniqvup
kontinuous/depname.full: project.fabrique.maildev.maildev.deployment.maildev
kontinuous/depname.full: project.fabrique.contrib.maildev.deployment.maildev
kontinuous/depname.chartResource: maildev.deployment.maildev
kontinuous/depname.chartName: maildev
kontinuous/depname.chartPath: project.fabrique.maildev.maildev
kontinuous/depname.chartPath: project.fabrique.contrib.maildev
kontinuous/depname.resourcePath: deployment.maildev
kontinuous/depname.resourceName: maildev
kontinuous/depname.chartNameTopFull: maildev.maildev
kontinuous/depname.chartNameTopFull: maildev
kontinuous/depname.chartNameTop: maildev
kontinuous/plugin.log: \\"false\\"
reloader.stakater.com/auto: \\"true\\"
Expand Down Expand Up @@ -180,8 +180,8 @@ metadata:
app.kubernetes.io/manifest-created-by: kontinuous
name: maildev
annotations:
kontinuous/chartPath: project.fabrique.maildev.maildev
kontinuous/source: project/charts/fabrique/charts/maildev/charts/maildev/templates/service.yaml
kontinuous/chartPath: project.fabrique.contrib.maildev
kontinuous/source: project/charts/fabrique/charts/contrib/charts/maildev/templates/service.yaml
kontinuous/deployment: test-maildev-feature-branch-1-ffac537e6cbbf934b08745a-5iniqvup
namespace: test-maildev
spec:
Expand All @@ -201,8 +201,8 @@ kind: Ingress
metadata:
annotations:
kubernetes.io/ingress.class: nginx
kontinuous/chartPath: project.fabrique.maildev.maildev
kontinuous/source: project/charts/fabrique/charts/maildev/charts/maildev/templates/ingress.yaml
kontinuous/chartPath: project.fabrique.contrib.maildev
kontinuous/source: project/charts/fabrique/charts/contrib/charts/maildev/templates/ingress.yaml
kontinuous/deployment: test-maildev-feature-branch-1-ffac537e6cbbf934b08745a-5iniqvup
cert-manager.io: cluster-issuer
cert-manager.io/cluster-issuer: letsencrypt-prod
Expand Down
4 changes: 4 additions & 0 deletions plugins/contrib/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,7 @@ dependencies:
repository: file://./charts/redis
version: 1.169.6
condition: redis.enabled
- name: maildev
degit: socialgouv/helm-charts/charts/maildev@v1
condition: maildev.enabled
version: "1"
47 changes: 47 additions & 0 deletions plugins/contrib/values-compilers/09-maildev.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
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 }) => {
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
4 changes: 0 additions & 4 deletions plugins/fabrique/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ dependencies:
repository: file://./charts/pgweb
version: 1.169.6
condition: pgweb.enabled
- name: maildev
repository: file://./charts/maildev
version: 1.169.6
condition: maildev.enabled
- name: keycloakx
repository: https://codecentric.github.io/helm-charts
version: 2.1.1
Expand Down
8 changes: 0 additions & 8 deletions plugins/fabrique/charts/maildev/Chart.yaml

This file was deleted.

10 changes: 0 additions & 10 deletions plugins/fabrique/charts/maildev/values.yaml

This file was deleted.

1 change: 1 addition & 0 deletions plugins/fabrique/values-compilers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ module.exports = [

"./global-defaults.js",

"../charts/contrib/values-compilers/09-maildev.js",
"../charts/contrib/values-compilers/10-tpl-meta-values",
]
2 changes: 0 additions & 2 deletions plugins/fabrique/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ pg:
enabled: false
pgweb:
enabled: false
maildev:
enabled: false
keycloakx:
enabled: false
contrib:
Expand Down

0 comments on commit 0e27dcb

Please sign in to comment.