Skip to content

Commit

Permalink
feat: don't duplicate dsn if its provided by extraEnvs (#689)
Browse files Browse the repository at this point in the history
  • Loading branch information
Demonsthere committed Jun 11, 2024
1 parent 8e29657 commit e2798e0
Show file tree
Hide file tree
Showing 25 changed files with 140 additions and 4 deletions.
7 changes: 5 additions & 2 deletions helm/charts/hydra/Chart.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
dependencies:
- name: ory-commons
repository: file://../ory-commons
version: 0.1.0
- name: hydra-maester
repository: file://../hydra-maester
version: 0.43.1
digest: sha256:d28f966a3e6b68126e932e9a6357aa1aea15496b5b6006f2d1d4f2f62e219a64
generated: "2024-05-23T11:52:47.4059612Z"
digest: sha256:3ec061d9abc96913b4991d2f57557d144829945e669329e4d8723d896c9a523f
generated: "2024-06-11T14:58:01.616059+02:00"
5 changes: 4 additions & 1 deletion helm/charts/hydra/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@ maintainers: # (optional)
url: https://www.ory.sh/
type: application
dependencies:
- name: ory-commons
version: 0.1.0
repository: file://../ory-commons
alias: ory
- name: hydra-maester
version: 0.43.1
condition: maester.enabled
alias: hydra-maester
repository: file://../hydra-maester
# repository: https://k8s.ory.sh/helm/charts
1 change: 1 addition & 0 deletions helm/charts/hydra/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ A Helm chart for deploying ORY Hydra in Kubernetes
| Repository | Name | Version |
|------------|------|---------|
| file://../hydra-maester | hydra-maester(hydra-maester) | 0.43.1 |
| file://../ory-commons | ory(ory-commons) | 0.1.0 |

## Values

Expand Down
Binary file modified helm/charts/hydra/charts/hydra-maester-0.43.1.tgz
Binary file not shown.
Binary file added helm/charts/hydra/charts/ory-commons-0.1.0.tgz
Binary file not shown.
4 changes: 4 additions & 0 deletions helm/charts/hydra/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,13 @@ spec:
value: {{ $issuer | quote }}
{{- end }}
{{- if not (empty ( include "hydra.dsn" . )) }}
{{- if not (include "ory.extraEnvContainsEnvName" (list .Values.deployment.extraEnv "DSN")) }}
- name: DSN
valueFrom:
secretKeyRef:
name: {{ include "hydra.secretname" . }}
key: dsn
{{- end }}
{{- end }}
- name: SECRETS_SYSTEM
valueFrom:
Expand Down Expand Up @@ -193,11 +195,13 @@ spec:
{{- end }}
env:
{{- if not (empty ( include "hydra.dsn" . )) }}
{{- if not (include "ory.extraEnvContainsEnvName" (list $migrationExtraEnv "DSN")) }}
- name: DSN
valueFrom:
secretKeyRef:
name: {{ include "hydra.secretname" . }}
key: dsn
{{- end }}
{{- end }}
{{- with $migrationExtraEnv }}
{{- toYaml . | nindent 12 }}
Expand Down
2 changes: 2 additions & 0 deletions helm/charts/hydra/templates/janitor-cron-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,13 @@ spec:
{{- end }}
env:
{{- if not (empty ( include "hydra.dsn" . )) }}
{{- if not (include "ory.extraEnvContainsEnvName" (list $janitorExtraEnv "DSN")) }}
- name: DSN
valueFrom:
secretKeyRef:
name: {{ include "hydra.secretname" . }}
key: dsn
{{- end }}
{{- end }}
{{- with $janitorExtraEnv }}
{{- toYaml . | nindent 16 }}
Expand Down
2 changes: 2 additions & 0 deletions helm/charts/hydra/templates/job-migration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,13 @@ spec:
{{- end }}
env:
{{- if not (empty ( include "hydra.dsn" . )) }}
{{- if not (include "ory.extraEnvContainsEnvName" (list $migrationExtraEnv "DSN")) }}
- name: DSN
valueFrom:
secretKeyRef:
name: {{ include "hydra.secretname" . }}
key: dsn
{{- end }}
{{- end }}
{{- with $migrationExtraEnv }}
{{- toYaml . | nindent 10 }}
Expand Down
6 changes: 6 additions & 0 deletions helm/charts/keto/Chart.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dependencies:
- name: ory-commons
repository: file://../ory-commons
version: 0.1.0
digest: sha256:eec8978215334aad38275f0171681f1200220dccef4762ddeb197679fd287abb
generated: "2024-06-11T14:47:42.552973+02:00"
5 changes: 5 additions & 0 deletions helm/charts/keto/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,8 @@ version: 0.43.1
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
appVersion: "v0.12.0"
dependencies:
- name: ory-commons
version: 0.1.0
repository: file://../ory-commons
alias: ory
6 changes: 6 additions & 0 deletions helm/charts/keto/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ Access Control Policies as a Server
* <https://github.com/ory/keto>
* <https://github.com/ory/k8s>

## Requirements

| Repository | Name | Version |
|------------|------|---------|
| file://../ory-commons | ory(ory-commons) | 0.1.0 |

## Values

| Key | Type | Default | Description |
Expand Down
Binary file added helm/charts/keto/charts/ory-commons-0.1.0.tgz
Binary file not shown.
4 changes: 4 additions & 0 deletions helm/charts/keto/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,13 @@ spec:
{{- end }}
env:
{{- if not (empty ( include "keto.dsn" . )) }}
{{- if not (include "ory.extraEnvContainsEnvName" (list $migrationExtraEnv "DSN")) }}
- name: DSN
valueFrom:
secretKeyRef:
name: {{ include "keto.secretname" . }}
key: dsn
{{- end }}
{{- end }}
{{- with $migrationExtraEnv }}
{{- toYaml . | nindent 12 }}
Expand Down Expand Up @@ -185,11 +187,13 @@ spec:
{{- toYaml $resources | nindent 12 }}
env:
{{- if not (empty ( include "keto.dsn" . )) }}
{{- if not (include "ory.extraEnvContainsEnvName" (list .Values.deployment.extraEnv "DSN")) }}
- name: DSN
valueFrom:
secretKeyRef:
name: {{ include "keto.secretname" . }}
key: dsn
{{- end }}
{{- end }}
{{- with .Values.deployment.extraEnv }}
{{- toYaml . | nindent 12 }}
Expand Down
2 changes: 2 additions & 0 deletions helm/charts/keto/templates/job-migration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,13 @@ spec:
{{- end }}
env:
{{- if not (empty ( include "keto.dsn" . )) }}
{{- if not (include "ory.extraEnvContainsEnvName" (list $migrationExtraEnv "DSN")) }}
- name: DSN
valueFrom:
secretKeyRef:
name: {{ include "keto.secretname" . }}
key: dsn
{{- end }}
{{- end }}
{{- with $migrationExtraEnv }}
{{- toYaml . | nindent 10 }}
Expand Down
6 changes: 6 additions & 0 deletions helm/charts/kratos/Chart.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dependencies:
- name: ory-commons
repository: file://../ory-commons
version: 0.1.0
digest: sha256:eec8978215334aad38275f0171681f1200220dccef4762ddeb197679fd287abb
generated: "2024-06-11T14:37:29.230884+02:00"
5 changes: 5 additions & 0 deletions helm/charts/kratos/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,8 @@ name: kratos
icon: https://raw.githubusercontent.com/ory/docs/master/docs/static/img/logo-kratos.svg
version: 0.43.1
type: application
dependencies:
- name: ory-commons
version: 0.1.0
repository: file://../ory-commons
alias: ory
6 changes: 6 additions & 0 deletions helm/charts/kratos/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@

A ORY Kratos Helm chart for Kubernetes

## Requirements

| Repository | Name | Version |
|------------|------|---------|
| file://../ory-commons | ory(ory-commons) | 0.1.0 |

## Values

| Key | Type | Default | Description |
Expand Down
Binary file added helm/charts/kratos/charts/ory-commons-0.1.0.tgz
Binary file not shown.
13 changes: 13 additions & 0 deletions helm/charts/kratos/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -213,3 +213,16 @@ Common labels for the cleanup cron job
"app.kubernetes.io/component": cleanup
"helm.sh/chart": {{ include "kratos.chart" . | quote }}
{{- end -}}

{{/*
Check if list contains object
*/}}
{{- define "kratos.extraEnvContainsEnvName" -}}
{{- $extraEnvs := index . 0 -}}
{{- $envName := index . 1 -}}
{{- range $k, $v := $extraEnvs -}}
{{- if eq $v.name $envName -}}
found
{{- end -}}
{{- end -}}
{{- end -}}
6 changes: 5 additions & 1 deletion helm/charts/kratos/templates/deployment-kratos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,13 @@ spec:
{{- end }}
env:
{{- if not (empty ( include "kratos.dsn" . )) }}
{{- if not (include "ory.extraEnvContainsEnvName" (list $migrationExtraEnv "DSN")) }}
- name: DSN
valueFrom:
secretKeyRef:
name: {{ include "kratos.secretname" . }}
key: dsn
{{- end }}
{{- end }}
{{- if $migrationExtraEnv }}
{{- toYaml $migrationExtraEnv | nindent 12 }}
Expand All @@ -104,7 +106,7 @@ spec:
{{- end }}
volumes:
{{- if .Values.deployment.extraVolumes }}
{{ toYaml .Values.deployment.extraVolumes | indent 8 }}
{{- toYaml .Values.deployment.extraVolumes | nindent 8 }}
{{- end }}
- name: {{ include "kratos.name" . }}-config-volume
configMap:
Expand Down Expand Up @@ -154,11 +156,13 @@ spec:
{{- end }}
env:
{{- if not (empty ( include "kratos.dsn" . )) }}
{{- if not (include "ory.extraEnvContainsEnvName" (list .Values.deployment.extraEnv "DSN")) }}
- name: DSN
valueFrom:
secretKeyRef:
name: {{ include "kratos.secretname" . }}
key: dsn
{{- end }}
{{- end }}
- name: SECRETS_DEFAULT
valueFrom:
Expand Down
2 changes: 2 additions & 0 deletions helm/charts/kratos/templates/job-migration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,13 @@ spec:
{{- end }}
env:
{{- if not (empty ( include "kratos.dsn" . )) }}
{{- if not (include "ory.extraEnvContainsEnvName" (list $migrationExtraEnv "DSN")) }}
- name: DSN
valueFrom:
secretKeyRef:
name: {{ include "kratos.secretname" . }}
key: dsn
{{- end }}
{{- end }}
{{- if $migrationExtraEnv }}
{{- toYaml $migrationExtraEnv | nindent 10 }}
Expand Down
2 changes: 2 additions & 0 deletions helm/charts/kratos/templates/statefulset-mail.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,13 @@ spec:
- name: LOG_LEVEL
value: {{ .Values.statefulSet.log.level }}
{{- if not (empty ( include "kratos.dsn" . )) }}
{{- if not (include "ory.extraEnvContainsEnvName" (list $extraEnv "DSN")) }}
- name: DSN
valueFrom:
secretKeyRef:
name: {{ include "kratos.secretname" . }}
key: dsn
{{- end }}
{{- end }}
- name: SECRETS_DEFAULT
valueFrom:
Expand Down
23 changes: 23 additions & 0 deletions helm/charts/ory-commons/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# 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/
25 changes: 25 additions & 0 deletions helm/charts/ory-commons/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
apiVersion: v2
name: ory-commons
description: |
Collection of helper function for the Ory Helm environment
# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: library

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "0.0.0"
12 changes: 12 additions & 0 deletions helm/charts/ory-commons/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{{/*
Check if list contains object
*/}}
{{- define "ory.extraEnvContainsEnvName" -}}
{{- $extraEnvs := index . 0 -}}
{{- $envName := index . 1 -}}
{{- range $k, $v := $extraEnvs -}}
{{- if eq $v.name $envName -}}
found
{{- end -}}
{{- end -}}
{{- end -}}

0 comments on commit e2798e0

Please sign in to comment.