From 1ff1ac0371f966c3a4d46b152e729a35edc5ad5c Mon Sep 17 00:00:00 2001 From: Kjeld Schouten-Lebbing Date: Tue, 7 Mar 2023 12:46:48 +0100 Subject: [PATCH] feat(blocky): add support for more query logging options, including postgresql (#7760) * feat(blocky): add support for more query logging options, including postgresql * std fix * handle database differently --- charts/enterprise/blocky/Chart.yaml | 4 +- .../blocky/ci/postgresql-values.yaml | 3 ++ charts/enterprise/blocky/questions.yaml | 42 +++++++++++++++++++ .../blocky/templates/_blockyConfig.tpl | 2 +- .../enterprise/blocky/templates/common.yaml | 3 ++ charts/enterprise/blocky/values.yaml | 4 +- 6 files changed, 53 insertions(+), 5 deletions(-) create mode 100644 charts/enterprise/blocky/ci/postgresql-values.yaml diff --git a/charts/enterprise/blocky/Chart.yaml b/charts/enterprise/blocky/Chart.yaml index ccf8eaa54ce..8283bdeff34 100644 --- a/charts/enterprise/blocky/Chart.yaml +++ b/charts/enterprise/blocky/Chart.yaml @@ -3,11 +3,11 @@ appVersion: "0.20.0" dependencies: - name: common repository: https://library-charts.truecharts.org - version: 12.2.20 + version: 12.2.22 - condition: redis.enabled name: redis repository: https://deps.truecharts.org - version: 6.0.11 + version: 6.0.13 description: Blocky is a DNS proxy, DNS enhancer and ad-blocker for the local network written in Go home: https://truecharts.org/charts/enterprise/blocky icon: https://truecharts.org/img/hotlink-ok/chart-icons/blocky.png diff --git a/charts/enterprise/blocky/ci/postgresql-values.yaml b/charts/enterprise/blocky/ci/postgresql-values.yaml new file mode 100644 index 00000000000..9dbe3e8c949 --- /dev/null +++ b/charts/enterprise/blocky/ci/postgresql-values.yaml @@ -0,0 +1,3 @@ +queryLog: + # optional one of: mysql, postgresql, csv, csv-client. If empty, log to console + type: "postgresql" diff --git a/charts/enterprise/blocky/questions.yaml b/charts/enterprise/blocky/questions.yaml index 62829074963..8040f2250fc 100644 --- a/charts/enterprise/blocky/questions.yaml +++ b/charts/enterprise/blocky/questions.yaml @@ -547,6 +547,48 @@ questions: schema: type: string default: 30m + - variable: queryLog + group: App Configuration + label: Query Logging configuration + schema: + additional_attrs: true + type: dict + attrs: + - variable: type + label: Type + schema: + type: string + default: "" + enum: + - value: "" + description: Console + - value: postgresql + description: postgresql + - value: csv + description: csv + - value: csv-client + description: csv-client + - variable: target + label: Target + schema: + type: string + show_if: [["type", "!=", "postgresql"]] + default: "/var/log/something" + - variable: logRetentionDays + label: Log Retention Days + schema: + type: int + default: 0 + - variable: creationAttempts + label: Creation Attempts + schema: + type: int + default: 3 + - variable: creationCooldown + label: Creation Cooldown + schema: + type: string + default: 2s - variable: k8sgateway group: App Configuration label: k8s-Gateway Configuration diff --git a/charts/enterprise/blocky/templates/_blockyConfig.tpl b/charts/enterprise/blocky/templates/_blockyConfig.tpl index d498a8a3b88..de2a61808ff 100644 --- a/charts/enterprise/blocky/templates/_blockyConfig.tpl +++ b/charts/enterprise/blocky/templates/_blockyConfig.tpl @@ -24,7 +24,7 @@ queryLog: # directory (should be mounted as volume in docker) for csv, db connection string for mysql/postgresql #postgresql target: postgres://user:password@db_host_or_ip:5432/db_name {{- if eq .Values.queryLog.type "postgresql" }} - target: {{ .Values.cnpg.creds.std }} + target: {{ .Values.cnpg.main.creds.std }} {{- else }} target: {{ .Values.queryLog.target }} {{- end }} diff --git a/charts/enterprise/blocky/templates/common.yaml b/charts/enterprise/blocky/templates/common.yaml index f8f297e8e64..40bf6d293a4 100644 --- a/charts/enterprise/blocky/templates/common.yaml +++ b/charts/enterprise/blocky/templates/common.yaml @@ -1,4 +1,7 @@ {{/* Make sure all variables are set properly */}} +{{- if eq .Values.queryLog.type "postgresql" -}} + {{- $_ := set .Values.cnpg.main "enabled" true -}} +{{- end }} {{- include "tc.v1.common.loader.init" . }} diff --git a/charts/enterprise/blocky/values.yaml b/charts/enterprise/blocky/values.yaml index a8709f606f9..da80f4bde2e 100644 --- a/charts/enterprise/blocky/values.yaml +++ b/charts/enterprise/blocky/values.yaml @@ -350,7 +350,7 @@ redis: queryLog: # optional one of: mysql, postgresql, csv, csv-client. If empty, log to console type: "" - # directory (should be mounted as volume in docker) for csv, db connection string for mysql/postgresql + # directory (should be mounted as volume in docker) for csv, db connection string for mysql, ignored for included postgresql # target: /var/log/something # postgresql target: postgres://user:password@db_host_or_ip:5432/db_name # if > 0, deletes log files which are older than ... days @@ -362,6 +362,6 @@ queryLog: cnpg: main: - enabled: true + enabled: false user: blocky database: blocky