Skip to content

Commit b2514f3

Browse files
authored
Merge pull request #2 from duhow/main
feat: major rework of Helm Chart
2 parents cf09a22 + 7a29f0f commit b2514f3

File tree

10 files changed

+269
-246
lines changed

10 files changed

+269
-246
lines changed

charts/part-db/Chart.yaml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
apiVersion: v1
1+
apiVersion: v2
22
name: part-db
33

4-
version: 0.0.3
4+
version: 0.1.0
5+
type: application
56

67
description: Part-DB inventory management system
78
keywords:
@@ -10,12 +11,12 @@ keywords:
1011
- electronics
1112
- php
1213
- opensource
13-
engine: gotpl
14-
type: application
15-
home: https://github.com/Part-DB/Part-DB-server
14+
15+
home: https://github.com/Part-DB/helm-charts
1616
sources:
1717
- https://github.com/Part-DB/Part-DB-server
1818
icon: https://part-db.github.io/helm-charts/icon.svg
19+
1920
maintainers:
2021
2122
name: Jan Böhmer

charts/part-db/templates/_helpers.tpl

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,16 @@ Create a default fully qualified app name.
1111
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
1212
*/}}
1313
{{- define "app.fullname" -}}
14-
{{- $name := default .Chart.Name .Values.nameOverride -}}
15-
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
14+
{{- if .Values.fullnameOverride }}
15+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
16+
{{- else }}
17+
{{- $name := default .Chart.Name .Values.nameOverride }}
18+
{{- if contains $name .Release.Name }}
19+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
20+
{{- else }}
21+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
22+
{{- end }}
23+
{{- end }}
1624
{{- end -}}
1725

1826
{{/*
@@ -22,17 +30,6 @@ Create chart name and version as used by the chart label.
2230
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
2331
{{- end -}}
2432

25-
{{/*
26-
Return the appropriate apiVersion for deployment.
27-
*/}}
28-
{{- define "app.deployment.apiVersion" -}}
29-
{{- if semverCompare "<1.14-0" .Capabilities.KubeVersion.GitVersion -}}
30-
{{- print "extensions/v1beta1" -}}
31-
{{- else -}}
32-
{{- print "apps/v1" -}}
33-
{{- end -}}
34-
{{- end -}}
35-
3633
{{/*
3734
Common labels
3835
*/}}
@@ -50,3 +47,11 @@ Labels to use on deploy.spec.selector.matchLabels and svc.spec.selector
5047
app.kubernetes.io/name: {{ template "app.name" . }}
5148
app.kubernetes.io/instance: {{ .Release.Name }}
5249
{{- end -}}
50+
51+
{{- define "app.url" -}}
52+
{{- if .Values.ingress.enabled -}}
53+
{{ empty .Values.ingress.tls | ternary "http" "https" }}://{{ .Values.ingress.hostname }}
54+
{{- else -}}
55+
http://{{ include "app.name" . }}
56+
{{- end -}}
57+
{{- end -}}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
apiVersion: v1
2+
kind: Secret
3+
type: Opaque
4+
metadata:
5+
name: {{ template "app.fullname" . }}-config
6+
labels: {{ include "app.labels" . | nindent 4 }}
7+
stringData:
8+
{{- with .Values.app }}
9+
APP_ENV: docker
10+
DEFAULT_URI: "{{ .url | default ( include "app.url" $ ) }}"
11+
BASE_CURRENCY: {{ .currency | quote }}
12+
ALLOW_ATTACHMENT_DOWNLOADS: {{ .attachment_downloads | int | quote }}
13+
USE_GRAVATAR: {{ .gravatar | int | quote }}
14+
DEFAULT_LANG: {{ .lang }}
15+
DEFAULT_TIMEZONE: {{ .tz | quote }}
16+
ENFORCE_CHANGE_COMMENTS_FOR: {{ .enforce_change_comments | quote }}
17+
MAX_ATTACHMENT_FILE_SIZE: "100M"
18+
CHECK_FOR_UPDATES: "0"
19+
HISTORY_SAVE_CHANGED_FIELDS: "true"
20+
HISTORY_SAVE_CHANGED_DATA: "true"
21+
HISTORY_SAVE_REMOVED_DATA: "true"
22+
{{- end }}
23+
{{- with .Values.db }}
24+
DB_TYPE: {{ .type }}
25+
{{- if eq .type "sqlite" }}
26+
DATABASE_URL: "sqlite:///%kernel.project_dir%/var/db/app.db"
27+
{{- else }}
28+
DATABASE_URL: "$(DB_TYPE)://$(DB_USERNAME):$(DB_PASSWORD)@$(DB_HOSTNAME)/$(DB_DATABASE)"
29+
DB_USERNAME: {{ .user | quote }}
30+
DB_PASSWORD: {{ .password | quote }}
31+
DB_HOSTNAME: {{ .host | quote }}
32+
DB_DATABASE: {{ .db | quote }}
33+
{{- end }}
34+
{{- end }}
35+
36+
{{- if .Values.smtp.user }}
37+
MAILER_DSN: "$(SMTP_PROTOCOL)://$(SMTP_USERNAME):$(SMTP_PASSWORD)@$(SMTP_HOST):$(SMTP_PORT)"
38+
{{- else }}
39+
MAILER_DSN: "$(SMTP_PROTOCOL)://$(SMTP_HOST):$(SMTP_PORT)"
40+
{{- end }}
41+
42+
{{- with .Values.smtp }}
43+
SMTP_HOST: {{ .host | quote }}
44+
SMTP_PORT: {{ required "SMTP port value required" .port | quote }}
45+
{{- if .user }}
46+
SMTP_USERNAME: {{ .user | quote }}
47+
SMTP_PASSWORD: {{ .password | quote }}
48+
{{- end }}
49+
{{- end }}
50+
51+
{{- if .Values.service.LoadBalancerSourceRanges }}
52+
TRUSTED_PROXIES: "{{ join "," .Values.service.LoadBalancerSourceRanges }}"
53+
{{- end }}

charts/part-db/templates/deployment.yaml

Lines changed: 0 additions & 125 deletions
This file was deleted.
Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,38 @@
11
{{- if .Values.ingress.enabled }}
2-
apiVersion: {{ required "A valid .Values.networkPolicyApiVersion entry required!" .Values.networkPolicyApiVersion }}
2+
apiVersion: networking.k8s.io/v1
33
kind: Ingress
44
metadata:
5-
{{- if .Values.ingress.annotations }}
6-
annotations:
7-
{{ toYaml .Values.ingress.annotations | indent 4 }}
8-
{{- end }}
9-
{{- if .Values.ingress.labels }}
10-
labels:
11-
{{ toYaml .Values.ingress.labels | indent 4 }}
12-
{{- end }}
135
name: {{ template "app.fullname" . }}
6+
labels: {{ include "app.labels" . | nindent 4 }}
7+
{{- with .Values.ingress.annotations }}
8+
annotations:
9+
{{- toYaml . | nindent 4 }}
10+
{{- end }}
1411
spec:
15-
{{- if .Values.ingress.ingressClassName }}
16-
ingressClassName: {{ .Values.ingress.ingressClassName }}
17-
{{- end }}
12+
{{- with .Values.ingress }}
13+
{{- if .className }}
14+
ingressClassName: {{ .className }}
15+
{{- end }}
16+
{{- if .tls }}
17+
tls:
18+
{{- range .tls }}
19+
- hosts:
20+
{{- range .hosts }}
21+
- {{ . | quote }}
22+
{{- end }}
23+
secretName: {{ .secretName }}
24+
{{- end }}
25+
{{- end }}
1826
rules:
19-
- host: {{ .Values.ingress.hostname | quote }}
27+
- host: {{ .hostname | quote }}
2028
http:
2129
paths:
2230
- path: /
31+
pathType: Prefix
2332
backend:
2433
service:
25-
name: {{ template "app.fullname" . }}
34+
name: {{ template "app.fullname" $ }}
2635
port:
27-
number: 80
28-
pathType: Prefix
29-
{{- if .Values.ingress.tls }}
30-
tls:
31-
{{ toYaml .Values.ingress.tls | indent 4 }}
32-
{{- end -}}
36+
name: http
37+
{{- end }}
3338
{{- end }}

charts/part-db/templates/pvc.yaml

Lines changed: 0 additions & 24 deletions
This file was deleted.

charts/part-db/templates/secrets.yaml

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)