Skip to content

Commit

Permalink
fix: helm yaml template parsing issues when using external dbs (#37)
Browse files Browse the repository at this point in the history
* fix helm yaml template parsing issues when using external dbs

* Refactor postgres helper function

* Refactor env vars in values.yaml

* add a helper func for redis.password

* Rename env var POSTGRES_DB to POSTGRES_DATABASE

Rails is looking for POSTGRES_DATABASE env variable. This was
causing failures if a different db name other than
chatwoot_production was used.
  • Loading branch information
vishnu-narayanan authored Sep 29, 2021
1 parent e9ab81a commit b019837
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 48 deletions.
2 changes: 1 addition & 1 deletion charts/chatwoot/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ sources:
- http://www.chatwoot.com

# This is the chart version.
version: 0.6.5
version: 0.6.6

# This is the application version.
appVersion: "v1.20.0"
47 changes: 24 additions & 23 deletions charts/chatwoot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,29 +55,30 @@ The command removes all the Kubernetes components associated with the chart and

### Chatwoot Environment Variables

| Name | Type | Default Value |
| ----------------------------------- | ------------------------------------------------------------------- | ---------------------------------------------------------- |
| `env.ACTIVE_STORAGE_SERVICE` | Storage service. `local` for disk. `amazon` for s3. | `"local"` |
| `env.ASSET_CDN_HOST` | Set if CDN is used for asset delivery. | `""` |
| `env.INSTALLATION_ENV` | Sets chatwoot installation method. | `"helm"` |
| `env.ENABLE_ACCOUNT_SIGNUP` | `true` : default option, allows sign ups, `false` : disables all the end points related to sign ups, `api_only`: disables the UI for signup but you can create sign ups via the account apis. | `"false"` |
| `env.FORCE_SSL` | Force all access to the app over SSL, default is set to false. | `"false"` |
| `env.FRONTEND_URL` | Replace with the URL you are planning to use for your app. | `"http://0.0.0.0:3000/"` |
| `env.IOS_APP_ID` | Change this variable only if you are using a custom build for mobile app. | `"6C953F3RX2.com.chatwoot.app"` |
| `env.ANDROID_BUNDLE_ID` | Change this variable only if you are using a custom build for mobile app. | `"com.chatwoot.app"` |
| `env.MAILER_SENDER_EMAIL` | The email from which all outgoing emails are sent. | `""` |
| `env.RAILS_ENV` | Sets rails environment. | `"production"` |
| `env.RAILS_MAX_THREADS` | Number of threads each worker will use. | `"5"` |
| `env.SECRET_KEY_BASE` | Used to verify the integrity of signed cookies. Ensure a secure value is set. | `"wsedrfghjhygtfrdecfvbhnygtfvbtyftctdrxresxcygvujhb"` |
| `env.SENTRY_DSN` | Sentry data source name. | `""` |
| `env.SMTP_ADDRESS` | Set your smtp address. |`""` |
| `env.SMTP_AUTHENTICATION` | Allowed values: `plain`,`login`,`cram_md5` | `"plain"` |
| `env.SMTP_ENABLE_STARTTLS_AUTO` | Defaults to true. | `"true"` |
| `env.SMTP_OPENSSL_VERIFY_MODE` | Can be: `none`, `peer`, `client_once`, `fail_if_no_peer_cert` | `"none"` |
| `env.SMTP_PASSWORD` | SMTP password | `""` |
| `env.SMTP_PORT` | SMTP port | `"587"` |
| `env.SMTP_USERNAME` | SMTP username | `""` |
| `env.USE_INBOX_AVATAR_FOR_BOT` | Bot customizations | `"true"` |
| Name | Type | Default Value |
| ------------------------------------ | ------------------------------------------------------------------- | ---------------------------------------------------------- |
| `env.ACTIVE_STORAGE_SERVICE` | Storage service. `local` for disk. `amazon` for s3. | `"local"` |
| `env.ASSET_CDN_HOST` | Set if CDN is used for asset delivery. | `""` |
| `env.INSTALLATION_ENV` | Sets chatwoot installation method. | `"helm"` |
| `env.ENABLE_ACCOUNT_SIGNUP` | `true` : default option, allows sign ups, `false` : disables all the end points related to sign ups, `api_only`: disables the UI for signup but you can create sign ups via the account apis. | `"false"` |
| `env.FORCE_SSL` | Force all access to the app over SSL, default is set to false. | `"false"` |
| `env.FRONTEND_URL` | Replace with the URL you are planning to use for your app. | `"http://0.0.0.0:3000/"` |
| `env.IOS_APP_ID` | Change this variable only if you are using a custom build for mobile app. | `"6C953F3RX2.com.chatwoot.app"` |
| `env.ANDROID_BUNDLE_ID` | Change this variable only if you are using a custom build for mobile app. | `"com.chatwoot.app"` |
| `env.ANDROID_SHA256_CERT_FINGERPRINT`| Change this variable only if you are using a custom build for mobile app. | `"AC:73:8E:DE:EB:5............"` |
| `env.MAILER_SENDER_EMAIL` | The email from which all outgoing emails are sent. | `""` |
| `env.RAILS_ENV` | Sets rails environment. | `"production"` |
| `env.RAILS_MAX_THREADS` | Number of threads each worker will use. | `"5"` |
| `env.SECRET_KEY_BASE` | Used to verify the integrity of signed cookies. Ensure a secure value is set. | `replace_with_your_super_duper_secret_key_base` |
| `env.SENTRY_DSN` | Sentry data source name. | `""` |
| `env.SMTP_ADDRESS` | Set your smtp address. |`""` |
| `env.SMTP_AUTHENTICATION` | Allowed values: `plain`,`login`,`cram_md5` | `"plain"` |
| `env.SMTP_ENABLE_STARTTLS_AUTO` | Defaults to true. | `"true"` |
| `env.SMTP_OPENSSL_VERIFY_MODE` | Can be: `none`, `peer`, `client_once`, `fail_if_no_peer_cert` | `"none"` |
| `env.SMTP_PASSWORD` | SMTP password | `""` |
| `env.SMTP_PORT` | SMTP port | `"587"` |
| `env.SMTP_USERNAME` | SMTP username | `""` |
| `env.USE_INBOX_AVATAR_FOR_BOT` | Bot customizations | `"true"` |
### Email setup for conversation continuity (Incoming emails)

Expand Down
24 changes: 18 additions & 6 deletions charts/chatwoot/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
Expand the name of the chart.
*/}}
{{- define "chatwoot.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create a default fully qualified app name.
Expand Down Expand Up @@ -88,14 +88,15 @@ Create the name of the service account to use
{{- end -}}
{{- end -}}


{{/*
Set postgres host
*/}}
{{- define "chatwoot.postgresql.host" -}}
{{- if .Values.postgresql.enabled -}}
{{- template "chatwoot.postgresql.fullname" . -}}
{{- else -}}
{{- .Values.postgresql.postgresqlHost | quote -}}
{{- .Values.postgresql.postgresqlHost -}}
{{- end -}}
{{- end -}}

Expand Down Expand Up @@ -126,9 +127,9 @@ Set postgres port
*/}}
{{- define "chatwoot.postgresql.port" -}}
{{- if .Values.postgresql.enabled -}}
"5432"
5432
{{- else -}}
{{- default "5432" .Values.postgresql.postgresqlPort | quote -}}
{{- default 5432 .Values.postgresql.postgresqlPort -}}
{{- end -}}
{{- end -}}

Expand All @@ -139,7 +140,7 @@ Set redis host
{{- if .Values.redis.enabled -}}
{{- template "chatwoot.redis.fullname" . -}}-master
{{- else -}}
{{- .Values.redis.host | quote -}}
{{- .Values.redis.host }}
{{- end -}}
{{- end -}}

Expand Down Expand Up @@ -176,6 +177,17 @@ Set redis port
{{- end -}}
{{- end -}}

{{/*
Set redis password
*/}}
{{- define "chatwoot.redis.password" -}}
{{- if .Values.redis.enabled -}}
{{- default "redis" .Values.redis.auth.password | quote -}}
{{- else -}}
{{- default "redis" .Values.redis.password | quote -}}
{{- end -}}
{{- end -}}

{{/*
Set redis URL
*/}}
Expand Down
14 changes: 7 additions & 7 deletions charts/chatwoot/templates/env-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ metadata:
heritage: "{{ .Release.Service }}"
name: {{ template "chatwoot.fullname" . }}-env
data:
POSTGRES_HOST: "{{ template "chatwoot.postgresql.host" . }}"
POSTGRES_PORT: {{ template "chatwoot.postgresql.port" . }}
POSTGRES_HOST: {{ include "chatwoot.postgresql.host" . | quote }}
POSTGRES_PORT: {{ include "chatwoot.postgresql.port" . | quote }}
POSTGRES_USERNAME: {{ default "postgres" .Values.postgresql.postgresqlUsername | quote }}
POSTGRES_PASSWORD: {{ default "postgres" .Values.postgresql.postgresqlPassword | quote }}
POSTGRES_DB: {{ default "chatwoot_production" .Values.postgresql.postgresqlDatabase | quote }}
REDIS_HOST: "{{ template "chatwoot.redis.host" . }}"
REDIS_PORT: "{{ template "chatwoot.redis.port" . }}"
REDIS_PASSWORD: {{ default "redis" .Values.redis.auth.password | quote }}
REDIS_URL: {{template "chatwoot.redis.url" . }}
POSTGRES_DATABASE: {{ default "chatwoot_production" .Values.postgresql.postgresqlDatabase | quote }}
REDIS_HOST: {{ include "chatwoot.redis.host" . | quote }}
REDIS_PORT: {{ include "chatwoot.redis.port" . | quote }}
REDIS_PASSWORD: {{ include "chatwoot.redis.password" . }}
REDIS_URL: {{ template "chatwoot.redis.url" . }}
{{- range $key, $value := .Values.env}}
{{ $key }}: {{ $value | quote }}
{{- end }}
24 changes: 13 additions & 11 deletions charts/chatwoot/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -146,46 +146,48 @@ hooks:
# ENVIRONMENT VARIABLES
env:
ACTIVE_STORAGE_SERVICE: local
ANDROID_BUNDLE_ID: com.chatwoot.app
ANDROID_SHA256_CERT_FINGERPRINT: "AC:73:8E:DE:EB:56:EA:CC:10:87:02:A7:65:37:7B:38:D4:5D:D4:53:F8:3B:FB:D3:C6:28:64:1D:AA:08:1E:D8"
ASSET_CDN_HOST: ""
AWS_ACCESS_KEY_ID: ""
AWS_REGION: ""
AWS_SECRET_ACCESS_KEY: ""
ENABLE_ACCOUNT_SIGNUP: "false"
ENABLE_ACCOUNT_SIGNUP: false
FB_APP_ID: ""
FB_APP_SECRET: ""
FB_VERIFY_TOKEN: ""
FORCE_SSL: "false"
FRONTEND_URL: "http://0.0.0.0:3000/"
INSTALLATION_ENV: "helm"
FORCE_SSL: false
FRONTEND_URL: "http://0.0.0.0:3000"
INSTALLATION_ENV: helm
IOS_APP_ID: 6C953F3RX2.com.chatwoot.app
LOG_LEVEL: info
LOG_SIZE: "500"
LOG_SIZE: 500
MAILER_INBOUND_EMAIL_DOMAIN: ""
MAILER_SENDER_EMAIL: ""
MAILGUN_INGRESS_SIGNING_KEY: ""
MANDRILL_INGRESS_API_KEY: ""
RAILS_ENV: production
RAILS_INBOUND_EMAIL_PASSWORD: ""
RAILS_INBOUND_EMAIL_SERVICE: ""
RAILS_LOG_TO_STDOUT: "true"
RAILS_MAX_THREADS: "5"
RAILS_LOG_TO_STDOUT: true
RAILS_MAX_THREADS: 5
REDIS_SENTINEL_MASTER_NAME: ""
REDIS_SENTINELS: ""
REDIS_TLS: false
S3_BUCKET_NAME: ""
SECRET_KEY_BASE: wsedrfghjhygtfrdecfvbhnygtfvbtyftctdrxresxcygvujhb
SECRET_KEY_BASE: replace_with_your_super_duper_secret_key_base
SENTRY_DSN: ""
SLACK_CLIENT_ID: ""
SLACK_CLIENT_SECRET: ""
SMTP_ADDRESS: ""
SMTP_AUTHENTICATION: plain
SMTP_ENABLE_STARTTLS_AUTO: "true"
SMTP_ENABLE_STARTTLS_AUTO: true
SMTP_OPENSSL_VERIFY_MODE: none
SMTP_PASSWORD: ""
SMTP_PORT: "587"
SMTP_PORT: 587
SMTP_USERNAME: ""
TWITTER_APP_ID: ""
TWITTER_CONSUMER_KEY: ""
TWITTER_CONSUMER_SECRET: ""
TWITTER_ENVIRONMENT: ""
USE_INBOX_AVATAR_FOR_BOT: "true"
USE_INBOX_AVATAR_FOR_BOT: true

0 comments on commit b019837

Please sign in to comment.