Skip to content

Commit 7d3749d

Browse files
committed
refactor: logrotate field change from domains to files
1 parent 1d156bf commit 7d3749d

2 files changed

Lines changed: 22 additions & 20 deletions

File tree

charts/bunkerweb/templates/ui-logrotate.yaml

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{{- if and .Values.ui.logs.enabled .Values.ui.logs.logrotate.enabled -}}
2-
{{- $domains := default (list) .Values.ui.logs.logrotate.domains -}}
2+
{{- $files := default (list) .Values.ui.logs.logrotate.files -}}
33
---
44
apiVersion: batch/v1
55
kind: CronJob
@@ -51,14 +51,15 @@ spec:
5151
- /bin/sh
5252
- -c
5353
- |
54-
{{- if gt (len $domains) 0 }}
54+
{{- if gt (len $files) 0 }}
5555
apk add --no-cache logrotate
5656
logrotate -f /etc/logrotate.d/bunkerweb
57-
for f in {{- range $domains }} /var/log/bunkerweb/{{ . }}.log{{- end }}; do
58-
find /var/log/bunkerweb/ -type f -name "$(basename "$f")" -mtime +{{ .Values.ui.logs.logrotate.rotate | default "2" }} -delete
59-
done
57+
58+
{{- range $files }}
59+
find /var/log/bunkerweb/ -type f -name "{{ . }}" -mtime +{{ $.Values.ui.logs.logrotate.rotate | default "2" }} -delete
60+
{{- end }}
6061
{{- else }}
61-
echo "ui.logs.logrotate.domains is empty; skip logrotate."
62+
echo "ui.logs.logrotate.files is empty; skip logrotate."
6263
exit 0
6364
{{- end }}
6465
volumeMounts:
@@ -85,9 +86,9 @@ metadata:
8586
{{- include "bunkerweb.labels" . | nindent 4 }}
8687
data:
8788
bunkerweb: |
88-
{{- if gt (len $domains) 0 }}
89-
{{- range $domains }}
90-
/var/log/bunkerweb/{{ . }}.log{{- end }} {
89+
{{- if gt (len $files) 0 -}}
90+
{{- range $files }}
91+
/var/log/bunkerweb/{{ . }}{{- end }} {
9192
daily
9293
rotate {{ add (.Values.ui.logs.logrotate.rotate | default "2") 1 }}
9394
dateext
@@ -106,5 +107,5 @@ data:
106107
done
107108
endscript
108109
}
109-
{{- end }}
110+
{{- end -}}
110111
{{- end }}

charts/bunkerweb/values.yaml

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,18 +1102,19 @@ ui:
11021102
# Log files older than this value will be automatically removed
11031103
rotate: 2
11041104

1105-
# Log file patterns to rotate.
1105+
# Log file patterns to rotate (required when logrotate.enabled=true).
11061106
#
1107-
# REQUIRED: if this list is empty, no logrotate rules are generated and no logs will be rotated.
1107+
# This list is matched against log file names under /var/log/bunkerweb/.
1108+
# You can use glob patterns:
1109+
# - *.com.log
11081110
#
1109-
# Use wildcard patterns with an explicit TLD to keep the config short and clear:
1110-
# - "*.com"
1111-
# - "*.net"
1112-
# - "*.co.kr"
1113-
# - "*.example.com"
1114-
#
1115-
# Patterns are matched against UI log file names under /var/log/bunkerweb/ (e.g., "example.com.log").
1116-
domains: []
1111+
# If this list is empty, no logrotate rules are generated and nothing will be rotated.
1112+
files:
1113+
- bw-autoconf.log
1114+
- bw-scheduler.log
1115+
- bw-ui-access.log
1116+
- bw-ui.log
1117+
# - '*.com.log'
11171118

11181119
# Liveness probe configuration
11191120
livenessProbe:

0 commit comments

Comments
 (0)