Skip to content

Commit

Permalink
fix(plausible): migrate to new common chart and upgrade to v2 (#11186)
Browse files Browse the repository at this point in the history
**Description**

* cherry-picked changes from my PR that were never merged into from
`port/incubator` into `master`:
#7810
* Added config options for Plausible v2.0.0
* Migrated to new common chart

TODO:

- [x] upgrade questions.yaml to new common chart
- [x] migrate common.yaml / _env.tpl to new common chart format

⚒️ Fixes  # <!--(issue)-->

**⚙️ Type of change**

- [ ] ⚙️ Feature/App addition
- [X] 🪛 Bugfix
- [X] ⚠️ Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [X] 🔃 Refactor of current code

**🧪 How Has This Been Tested?**
<!--
Please describe the tests that you ran to verify your changes. Provide
instructions so we can reproduce. Please also list any relevant details
for your test configuration
-->

**📃 Notes:**
<!-- Please enter any other relevant information here -->

**✔️ Checklist:**

- [X] ⚖️ My code follows the style guidelines of this project
- [X] 👀 I have performed a self-review of my own code
- [X] #️⃣ I have commented my code, particularly in hard-to-understand
areas
- [ ] 📄 I have made corresponding changes to the documentation
- [ ] ⚠️ My changes generate no new warnings
- [ ] 🧪 I have added tests to this description that prove my fix is
effective or that my feature works
- [X] ⬆️ I increased versions for any altered app according to semantic
versioning

**➕ App addition**

If this PR is an app addition please make sure you have done the
following.

- [ ] 🪞 I have opened a PR on
[truecharts/containers](https://github.com/truecharts/containers) adding
the container to TrueCharts mirror repo.
- [ ] 🖼️ I have added an icon in the Chart's root directory called
`icon.png`

---

_Please don't blindly check all the boxes. Read them and only check
those that apply.
Those checkboxes are there for the reviewer to see what is this all
about and
the status of this PR with a quick glance._

---------

Signed-off-by: Stavros Kois <47820033+stavros-k@users.noreply.github.com>
Co-authored-by: Stavros Kois <47820033+stavros-k@users.noreply.github.com>
  • Loading branch information
schnerring and stavros-k authored Aug 12, 2023
1 parent b29c953 commit 5b1058a
Show file tree
Hide file tree
Showing 8 changed files with 244 additions and 180 deletions.
12 changes: 4 additions & 8 deletions charts/incubator/plausible/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
apiVersion: v2
appVersion: "1.5.1"
appVersion: "2.0.0"
dependencies:
- name: common
repository: https://library-charts.truecharts.org
version: 11.1.2
- condition: postgresql.enabled
name: postgresql
repository: https://deps.truecharts.org/
version: 11.0.31
version: 14.0.2
- condition: clickhouse.enabled
name: clickhouse
repository: https://deps.truecharts.org/
version: 3.0.21
version: 7.0.1
deprecated: false
description: Plausible is lightweight and open source web analytics. No cookies and fully compliant with GDPR, CCPA and PECR.
home: https://truecharts.org/charts/incubator/plausible
Expand All @@ -32,7 +28,7 @@ sources:
- https://github.com/plausible/analytics
- https://github.com/plausible/hosting
type: application
version: 4.0.25
version: 5.0.0
annotations:
truecharts.org/catagories: |
- analytics
Expand Down
139 changes: 96 additions & 43 deletions charts/incubator/plausible/questions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,43 +27,29 @@ questions:
type: string
default: http://localhost
required: true
- variable: DISABLE_AUTH
label: DISABLE_AUTH
description: Disables authentication completely, no registration, login will be shown.
schema:
type: boolean
default: false
- variable: DISABLE_REGISTRATION
label: DISABLE_REGISTRATION
description: Disables registration of new users, keep your admin credentials handy ;)
schema:
type: boolean
default: false
- variable: ADMIN_USER_NAME
label: ADMIN_USER_NAME
description: Admin user's name (First Install Only)
schema:
type: string
default: admin
required: true
- variable: ADMIN_USER_EMAIL
label: ADMIN_USER_EMAIL
description: The default ("admin") user email (First Install Only)
description: Restricts registration of new users.
schema:
type: string
default: admin@example.com
required: true
- variable: ADMIN_USER_PWD
label: ADMIN_USER_PWD
description: The default ("admin") user password (First Install Only)
default: "true"
enum:
- value: "true"
description: Full restriction
- value: "false"
description: No restriction
- value: invite_only
description: Only invited users can register
- variable: LOG_FAILED_LOGIN_ATTEMPTS
label: LOG_FAILED_LOGIN_ATTEMPTS
description: Controls whether to log warnings about failed login attempts.
schema:
type: string
default: ""
required: true
private: true
type: boolean
default: false
- variable: CLICKHOUSE_FLUSH_INTERVAL_MS
label: CLICKHOUSE_FLUSH_INTERVAL_MS
description: nterval (in milliseconds) between flushing events and sessions data to Clickhouse. Consult Clickhouse docs before changing it.
description: Interval (in milliseconds) between flushing events and sessions data to Clickhouse. Consult Clickhouse docs before changing it.
schema:
type: int
default: 5000
Expand All @@ -82,6 +68,12 @@ questions:
type: string
default: hello@plausible.local
required: true
- variable: MAILER_NAME
label: MAILER_NAME
description: The display name for the sender (from).
schema:
type: string
default: ""
- variable: SMTP_HOST_ADDR
label: SMTP_HOST_ADDR
description: The host address of your smtp server.
Expand Down Expand Up @@ -134,13 +126,78 @@ questions:
description: Bamboo.SMTPAdapter
- value: Bamboo.PostmarkAdapter
description: Bamboo.PostmarkAdapter
- value: Bamboo.MailgunAdapter
description: Bamboo.MailgunAdapter
- value: Bamboo.MandrillAdapter
description: Bamboo.MandrillAdapter
- value: Bamboo.SendGridAdapter
description: Bamboo.SendGridAdapter
- variable: POSTMARK_API_KEY
label: POSTMARK_API_KEY
description: Enter your API key.
description: Required. Enter your API key.
schema:
show_if: [["MAILER_ADAPTER", "=", "Bamboo.PostmarkAdapter"]]
type: string
default: ""
private: true
- variable: MAILGUN_API_KEY
label: MAILGUN_API_KEY
description: Required. Enter your API key.
schema:
show_if: [["MAILER_ADAPTER", "=", "Bamboo.MailgunAdapter"]]
type: string
default: ""
private: true
- variable: MAILGUN_DOMAIN
label: MAILGUN_DOMAIN
description: Required. Enter your Mailgun domain.
schema:
show_if: [["MAILER_ADAPTER", "=", "Bamboo.MailgunAdapter"]]
type: string
default: ""
- variable: MAILGUN_BASE_URI
label: MAILGUN_BASE_URI
description: This is optional. Mailgun makes a difference in the API base URL between sender domains from within the EU and outside. By default, the base URL is set to https://api.mailgun.net/v3. To override this you can pass https://api.eu.mailgun.net/v3 if you are using an EU domain.
schema:
show_if: [["MAILER_ADAPTER", "=", "Bamboo.MailgunAdapter"]]
type: string
default: ""
- variable: MANDRILL_API_KEY
label: MANDRILL_API_KEY
description: Required. Enter your API key.
schema:
show_if: [["MAILER_ADAPTER", "=", "Bamboo.MandrillAdapter"]]
type: string
default: ""
private: true
- variable: SENDGRID_API_KEY
label: SENDGRID_API_KEY
description: Required. Enter your API key.
schema:
show_if: [["MAILER_ADAPTER", "=", "Bamboo.SendGridAdapter"]]
type: string
default: ""
private: true
- variable: MAXMIND_LICENSE_KEY
label: MAXMIND_LICENSE_KEY
description: MaxMind license key to automatically download and update the database
schema:
type: string
default: ""
private: true
- variable: MAXMIND_EDITION
label: MAXMIND_EDITION
description: MaxMind database edition to use (only if MAXMIND_LICENSE_KEY is set)
schema:
show_if: [["MAXMIND_LICENSE_KEY", "!=", ""]]
type: string
required: true
default: GeoLite2-City
enum:
- value: GeoLite2-City
description: GeoLite2-City
- value: GeoLite2-Country
description: GeoLite2-Country
- variable: GOOGLE_CLIENT_ID
label: GOOGLE_CLIENT_ID
description: The Client ID from the Google API Console for your Plausible Analytics project
Expand Down Expand Up @@ -170,15 +227,11 @@ questions:
description: warn
- value: error
description: error

# Include{containerConfig}
# Include{podOptions}
# Include{serviceRoot}
- variable: main
label: "Main Service"
description: "The Primary service on which the healthcheck runs, often the webUI"
schema:
additional_attrs: true
type: dict
attrs:
# Include{serviceMain}
# Include{serviceSelectorLoadBalancer}
# Include{serviceSelectorExtras}
- variable: main
Expand Down Expand Up @@ -218,12 +271,12 @@ questions:
schema:
type: int
default: 1000
- variable: runAsGroup
label: "runAsGroup"
description: "The groupID this App of the user running the application"
schema:
type: int
default: 1000
- variable: runAsGroup
label: "runAsGroup"
description: "The groupID this App of the user running the application"
schema:
type: int
default: 1000
# Include{securityContextContainer}
# Include{securityContextAdvanced}
# Include{securityContextPod}
Expand Down
21 changes: 21 additions & 0 deletions charts/incubator/plausible/templates/_configmap.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{{- define "plausible.configmap" -}}
enabled: true
data:
BASE_URL: {{ .Values.plausible.BASE_URL | quote }}
DISABLE_REGISTRATION: {{ .Values.plausible.DISABLE_REGISTRATION | quote }}
LOG_FAILED_LOGIN_ATTEMPTS: {{ .Values.plausible.LOG_FAILED_LOGIN_ATTEMPTS | quote }}

CLICKHOUSE_FLUSH_INTERVAL_MS: {{ .Values.plausible.CLICKHOUSE_FLUSH_INTERVAL_MS | quote }}
CLICKHOUSE_MAX_BUFFER_SIZE: {{ .Values.plausible.CLICKHOUSE_MAX_BUFFER_SIZE | quote }}

SMTP_HOST_ADDR: {{ .Values.plausible.SMTP_HOST_ADDR | quote }}
SMTP_HOST_PORT: {{ .Values.plausible.SMTP_HOST_PORT | quote }}
SMTP_HOST_SSL_ENABLED: {{ .Values.plausible.SMTP_HOST_SSL_ENABLED | quote }}
SMTP_RETRIES: {{ .Values.plausible.SMTP_RETRIES | quote }}
MAILER_ADAPTER: {{ .Values.plausible.MAILER_ADAPTER | quote }}
MAILGUN_BASE_URI: {{ .Values.plausible.MAILGUN_BASE_URI | quote }}

MAXMIND_EDITION: {{ .Values.plausible.MAXMIND_EDITION | quote }}

LOG_LEVEL: {{ .Values.plausible.LOG_LEVEL | quote }}
{{- end }}
56 changes: 0 additions & 56 deletions charts/incubator/plausible/templates/_env.tpl

This file was deleted.

28 changes: 28 additions & 0 deletions charts/incubator/plausible/templates/_secret.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{{- define "plausible.secret" -}}
enabled: true
data:
{{- with (lookup "v1" "Secret" .Release.Namespace "plausible-secret") }}
SECRET_KEY_BASE: {{ index .data "SECRET_KEY_BASE" | b64dec }}
{{- else }}
{{- /* The plain value of SECRET_KEY_BASE is also base64 encoded */}}
SECRET_KEY_BASE: {{ randAlphaNum 86 | b64enc }}
{{- end }}

DATABASE_URL: {{ .Values.cnpg.main.creds.std }}
CLICKHOUSE_DATABASE_URL: {{ .Values.clickhouse.creds.complete }}

MAILER_EMAIL: {{ .Values.plausible.MAILER_EMAIL | quote }}
MAILER_NAME: {{ .Values.plausible.MAILER_NAME | quote }}
SMTP_USER_NAME: {{ .Values.plausible.SMTP_USER_NAME | quote }}
SMTP_USER_PWD: {{ .Values.plausible.SMTP_USER_PWD | quote }}
POSTMARK_API_KEY: {{ .Values.plausible.POSTMARK_API_KEY | quote }}
MAILGUN_API_KEY: {{ .Values.plausible.MAILGUN_API_KEY | quote }}
MAILGUN_DOMAIN: {{ .Values.plausible.MAILGUN_DOMAIN | quote }}
MANDRILL_API_KEY: {{ .Values.plausible.MANDRILL_API_KEY | quote }}
SENDGRID_API_KEY: {{ .Values.plausible.SENDGRID_API_KEY | quote }}

MAXMIND_LICENSE_KEY: {{ .Values.plausible.MAXMIND_LICENSE_KEY | quote }}

GOOGLE_CLIENT_ID: {{ .Values.plausible.GOOGLE_CLIENT_ID | quote }}
GOOGLE_CLIENT_SECRET: {{ .Values.plausible.GOOGLE_CLIENT_SECRET | quote }}
{{- end }}
17 changes: 13 additions & 4 deletions charts/incubator/plausible/templates/common.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
{{/* Make sure all variables are set properly */}}
{{- include "tc.common.loader.init" . }}
{{- include "tc.v1.common.loader.init" . }}

{{/* Plausible environment variables */}}
{{- include "plausible.env" . }}
{{/* Render Plausible configmap */}}
{{- $config := include "plausible.configmap" . | fromYaml -}}
{{- if $config -}}
{{- $_ := set .Values.configmap "plausible-config" $config -}}
{{- end -}}

{{/* Render Plausible secret */}}
{{- $secret := include "plausible.secret" . | fromYaml -}}
{{- if $secret -}}
{{- $_ := set .Values.secret "plausible-secret" $secret -}}
{{- end -}}

{{/* Render the templates */}}
{{ include "tc.common.loader.apply" . }}
{{ include "tc.v1.common.loader.apply" . }}
Loading

0 comments on commit 5b1058a

Please sign in to comment.