Skip to content

Commit

Permalink
Allow mongo connection string based on type
Browse files Browse the repository at this point in the history
  • Loading branch information
maidul98 committed Jan 18, 2023
1 parent fd29666 commit 375412b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 21 deletions.
19 changes: 6 additions & 13 deletions helm-charts/infisical/templates/_helpers.tpl
Expand Up @@ -120,19 +120,12 @@ Create the mongodb connection string.
{{- $port := 27017 -}}
{{- $user := "root" -}}
{{- $pass := "root" -}}
{{- if .Values.mongodbConnection -}}
{{- if .Values.mongodbConnection.host -}}
{{- $host = .Values.mongodbConnection.host -}}
{{- $connectionString := printf "mongodb://%s:%s@%s:%d/" $user $pass $host $port -}}
{{- if .Values.mongodbConnection.standardConnectionStringFormat -}}
{{- $connectionString = .Values.mongodbConnection.standardConnectionStringFormat -}}
{{- end -}}
{{- if .Values.mongodbConnection.port -}}
{{- $port = .Values.mongodbConnection.port -}}
{{- if .Values.mongodbConnection.dnsSeedListConnectionFormat -}}
{{- $connectionString = .Values.mongodbConnection.dnsSeedListConnectionFormat -}}
{{- end -}}
{{- if .Values.mongodbConnection.username -}}
{{- $user = .Values.mongodbConnection.username -}}
{{- end -}}
{{- if .Values.mongodbConnection.password -}}
{{- $pass = .Values.mongodbConnection.password -}}
{{- end -}}
{{- end -}}
{{- printf "mongodb://%s:%s@%s:%d/" $user $pass $host $port -}}

This comment has been minimized.

Copy link
@jon4hz

jon4hz Jan 19, 2023

Contributor

I wouldn't have deleted these. Because now you can't override the host, port, user or password only anymore.
Also what's the difference between standardConnectionStringFormat and dnsSeedListConnectionFormat? Both seem to be returned 1:1, so there is no point in having two variables imo.

{{- printf "%s" $connectionString -}}
{{- end -}}
15 changes: 7 additions & 8 deletions helm-charts/infisical/values.yaml
Expand Up @@ -43,19 +43,18 @@ mongodb:
service:
annotations: {}


# Recommended to replace with Mongo Cloud URI as the DB instance in the cluster does not have persistence yet
# By default the backend will be connected to a Mongo instance in the cluster.
# However, it is recommended to add a Mongo Cloud connection string as the DB instance in the cluster does not have persistence yet.
# Learn about connection string type here https://www.mongodb.com/docs/manual/reference/connection-string/
mongodbConnection: {}
# host: mymongodb.com # defaults to the internal mongo service
# port: 27017
# username: root
# password: root
# standardConnectionStringFormat: <>
# dnsSeedListConnectionFormat: <>

ingress:
enabled: true
annotations:
kubernetes.io/ingress.class: "nginx"
hostName: example.com
hostName: example.com # replace with your domain
frontend:
path: /
pathType: Prefix
Expand Down Expand Up @@ -98,7 +97,7 @@ backendEnvironmentVariables:

# Mail/SMTP
# Required to send emails
SMTP_HOST: MUST_REPLACE
SMTP_HOST: MUST_REPLACE
SMTP_NAME: MUST_REPLACE
SMTP_USERNAME: MUST_REPLACE
SMTP_PASSWORD: MUST_REPLACE
Expand Down

0 comments on commit 375412b

Please sign in to comment.