Skip to content

Commit

Permalink
Fix secrets usage and files cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
chinmaya-n committed Apr 24, 2024
1 parent a6ccb40 commit 615fae3
Show file tree
Hide file tree
Showing 14 changed files with 106 additions and 144 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/.idea/
/.cr-release-packages/
temp
38 changes: 0 additions & 38 deletions 1.0.0/index.yaml

This file was deleted.

38 changes: 0 additions & 38 deletions 1.0.1/index.yaml

This file was deleted.

38 changes: 0 additions & 38 deletions 1.0.2/index.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion charts/maildev/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
name: maildev
description: MailDev is a simple way to test your emails during development with an easy to use web interface.
type: application
version: 1.0.5
version: 1.1.0
appVersion: "2.1.0"
home: https://github.com/alluen/maildev-helm
maintainers:
Expand Down
11 changes: 11 additions & 0 deletions charts/maildev/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,17 @@ Get the name of the secret containing the web user password
{{- end -}}
{{- end -}}

{{/*
Get the name of the secret containing the oauth2_proxy config & credentials
*/}}
{{- define "maildev.oauth2_proxy.secretName" -}}
{{- if .Values.maildev.config.oauth2_proxy.existingSecret -}}
{{- printf "%s" .Values.maildev.config.oauth2_proxy.existingSecret -}}
{{- else -}}
{{- printf "%s" (include "maildev.fullname" .) -}}-oauth2-proxy
{{- end -}}
{{- end -}}

{{/*
Get the name of the secret containing the password for the incoming SMTP traffic
*/}}
Expand Down
38 changes: 15 additions & 23 deletions charts/maildev/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ spec:
- "--verbose"
{{- end }}
env:
{{- if .Values.maildev.config.https.enabled }}
# HTTPS Settings
{{- if .Values.maildev.config.https.enabled }}
{{- if .Values.maildev.config.https.cert }}
- name: MAILDEV_HTTPS_CERT
value: {{ .Values.maildev.config.https.cert | quote }}
Expand All @@ -82,9 +82,11 @@ spec:
- name: MAILDEV_HIDE_EXTENSIONS
value: {{ .Values.maildev.config.smtp.hideExtensions | quote }}
{{- end }}
{{- if .Values.maildev.config.smtp.incoming.authRequired }}
{{- if .Values.maildev.config.smtp.incoming.username }}
- name: MAILDEV_INCOMING_USER
value: {{ .Values.maildev.config.smtp.incoming.username | quote }}
{{- end }}
- name: MAILDEV_INCOMING_PASS
valueFrom:
secretKeyRef:
Expand All @@ -99,23 +101,23 @@ spec:
- name: MAILDEV_OUTGOING_PORT
value: {{ .Values.maildev.config.smtp.outgoing.port | quote }}
{{- end }}
{{- if .Values.maildev.config.smtp.outgoing.host }}
{{- if .Values.maildev.config.smtp.outgoing.authRequired }}
{{- if .Values.maildev.config.smtp.outgoing.username }}
- name: MAILDEV_OUTGOING_USER
value: {{ .Values.maildev.config.smtp.outgoing.username | quote }}
{{- end }}
- name: MAILDEV_OUTGOING_PASS
valueFrom:
secretKeyRef:
name: {{ include "maildev.smtp.outgoing.secretName" . }}
key: smtp-outgoing-password
{{- end }}
{{- if .Values.maildev.config.smtp.outgoing.username }}
- name: MAILDEV_OUTGOING_USER
value: {{ .Values.maildev.config.smtp.outgoing.username | quote }}
{{- end }}
# Web Settingss
# Web Settings
{{- if .Values.maildev.config.web.authRequired }}
{{- if .Values.maildev.config.web.username }}
- name: MAILDEV_WEB_USER
value: {{ .Values.maildev.config.web.username | quote }}
{{- end }}
{{- if or .Values.maildev.config.web.password .Values.maildev.config.web.existingSecret }}
- name: MAILDEV_WEB_PASS
valueFrom:
secretKeyRef:
Expand All @@ -125,7 +127,7 @@ spec:
- name: MAILDEV_WEB_PORT
value: {{ .Values.services.web.port | quote }}
{{- if .Values.extraEnv }}
## Additional Setings
## Additional Settings
{{- range .Values.extraEnv }}
{{- if and (.name) (.value) }}
- name: {{ .name | quote }}
Expand Down Expand Up @@ -188,17 +190,17 @@ spec:
- name: OAUTH2_PROXY_CLIENT_SECRET
valueFrom:
secretKeyRef:
name: maildev-app-resource
name: {{ include "maildev.oauth2_proxy.secretName" . }}
key: oauth2_proxy_client_secret
- name: OAUTH2_PROXY_CLIENT_ID
valueFrom:
secretKeyRef:
name: maildev-app-resource
name: {{ include "maildev.oauth2_proxy.secretName" . }}
key: oauth2_proxy_client_id
- name: OAUTH2_PROXY_COOKIE_SECRET
valueFrom:
secretKeyRef:
name: maildev-app-resource
name: {{ include "maildev.oauth2_proxy.secretName" . }}
key: oauth2_proxy_cookie_secret
- name: OAUTH2_PROXY_EMAIL_DOMAINS
value: ohio.edu
Expand All @@ -207,15 +209,10 @@ spec:
- name: OAUTH2_PROXY_OIDC_ISSUER_URL
valueFrom:
secretKeyRef:
name: oauth2-proxy-oidc-issuer-url
name: {{ include "maildev.oauth2_proxy.secretName" . }}
key: oauth2_proxy_oidc_issuer_url
- name: OAUTH2_PROXY_SESSION_COOKIE_MINIMAL
value: "true"
volumeMounts:
- mountPath: /var/run/secrets/maildev-app-resource
name: secrets-maildev-app-resource
readOnly: true

resources:
requests:
cpu: 5m
Expand Down Expand Up @@ -245,11 +242,6 @@ spec:
timeoutSeconds: 2
{{- end }}
volumes:
{{- if .Values.maildev.config.oauth2_proxy.enabled }}
- name: secrets-maildev-app-resource
secret:
secretName: maildev-app-resource
{{- end }}
- name: data
{{- if .Values.maildev.persistence.enabled }}
persistentVolumeClaim:
Expand Down
13 changes: 13 additions & 0 deletions charts/maildev/templates/oauth2_proxy/secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{{- if .Values.maildev.config.oauth2_proxy.enabled }}
{{- if (not .Values.maildev.config.oauth2_proxy.existingSecret) }}
apiVersion: v1
kind: Secret
metadata:
name: {{ include "maildev.oauth2_proxy.secretName" . }}
data:
oauth2_proxy_client_id: {{ .Values.maildev.config.oauth2_proxy.clientId | b64enc }}
oauth2_proxy_client_secret: {{ .Values.maildev.config.oauth2_proxy.clientSecret | b64enc }}
oauth2_proxy_cookie_secret: {{ .Values.maildev.config.oauth2_proxy.cookieSecret | b64enc }}
oauth2_proxy_oidc_issuer_url: {{ .Values.maildev.config.oauth2_proxy.oidcIssuerURL | b64enc }}
{{- end }}
{{- end }}
4 changes: 3 additions & 1 deletion charts/maildev/templates/smtp/incoming-secret.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
{{- if (not .Values.maildev.config.smtp.incoming.existingSecret) -}}
{{- if .Values.maildev.config.smtp.incoming.authRequired }}
{{- if (not .Values.maildev.config.smtp.incoming.existingSecret) }}
apiVersion: v1
kind: Secret
metadata:
name: {{ include "maildev.smtp.incoming.secretName" . }}
data:
smtp-incoming-password: {{ .Values.maildev.config.smtp.incoming.password | b64enc }}
{{- end }}
{{- end }}
4 changes: 3 additions & 1 deletion charts/maildev/templates/smtp/outgoing-secret.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
{{- if (not .Values.maildev.config.smtp.outgoing.existingSecret) -}}
{{- if .Values.maildev.config.smtp.outgoing.authRequired }}
{{- if (not .Values.maildev.config.smtp.outgoing.existingSecret) }}
apiVersion: v1
kind: Secret
metadata:
name: {{ include "maildev.smtp.outgoing.secretName" . }}
data:
smtp-outgoing-password: {{ .Values.maildev.config.smtp.outgoing.password | b64enc }}
{{- end }}
{{- end }}
8 changes: 5 additions & 3 deletions charts/maildev/templates/smtp/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ spec:
targetPort: smtp
protocol: TCP
name: smtp
{{ if and (eq .Values.services.smtp.type "NodePort") .Values.services.smtp.nodePort }}
nodePort: {{ .Values.services.smtp.nodePort }}
{{ end }}
{{- if (eq .Values.services.smtp.type "NodePort") }}
{{- if .Values.services.smtp.nodePort }}
nodePort: {{ .Values.services.smtp.nodePort }}
{{- end }}
{{- end }}
selector:
{{- include "maildev.selectorLabels" . | nindent 4 }}
4 changes: 3 additions & 1 deletion charts/maildev/templates/web/secret.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
{{- if (not .Values.maildev.config.web.existingSecret) -}}
{{- if .Values.maildev.config.web.authRequired }}
{{- if (not .Values.maildev.config.web.existingSecret) }}
apiVersion: v1
kind: Secret
metadata:
name: {{ include "maildev.web.secretName" . }}
data:
web-password: {{ .Values.maildev.config.web.password | b64enc }}
{{- end }}
{{- end }}
32 changes: 32 additions & 0 deletions charts/maildev/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@
"incoming": {
"type": "object",
"properties": {
"authRequired": {
"type": "boolean"
},
"existingSecret": {
"type": "string"
},
Expand Down Expand Up @@ -173,6 +176,9 @@
"host": {
"type": "string"
},
"authRequired": {
"type": "boolean"
},
"password": {
"type": "string"
},
Expand All @@ -195,6 +201,9 @@
"disabled": {
"type": "boolean"
},
"authRequired": {
"type": "boolean"
},
"existingSecret": {
"type": "string"
},
Expand All @@ -205,6 +214,29 @@
"type": "string"
}
}
},
"oauth2_proxy": {
"type": "object",
"properties": {
"clientId": {
"type": "string"
},
"clientSecret": {
"type": "string"
},
"cookieSecret": {
"type": "string"
},
"enabled": {
"type": "boolean"
},
"existingSecret": {
"type": "string"
},
"oidcIssuerURL": {
"type": "string"
}
}
}
}
},
Expand Down
Loading

0 comments on commit 615fae3

Please sign in to comment.