initial commit

This commit is contained in:
2025-10-01 11:01:48 +02:00
commit c5408f5e17
9 changed files with 169 additions and 0 deletions

10
.editorconfig Normal file
View File

@@ -0,0 +1,10 @@
root = true
[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
max_line_length = 1024
tab_width = 2

View File

@@ -0,0 +1,11 @@
name: Publish Helm Chart
on:
workflow_dispatch:
jobs:
call-helm-ci:
uses: helm/common-workflows/.gitea/workflows/release.yaml@master
secrets:
CI_BOT_USERNAME: ${{ secrets.CI_BOT_USERNAME }}
CI_BOT_TOKEN: ${{ secrets.CI_BOT_TOKEN }}

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
.idea/

36
README.md Normal file
View File

@@ -0,0 +1,36 @@
# Lulz Ltd Common Library Chart
A [Helm Library Chart](https://helm.sh/docs/topics/library_charts/#helm) for grouping common logic between charts.
## Introduction
This chart provides a common template helpers which can be used to develop new charts using [Helm](https://helm.sh) package manager.
## Parameters
The following table lists the helpers available in the library which are scoped in different sections.
### Labels
| Helper identifier | Description | Expected Input |
|-----------------------------|-----------------------------------------------------------------------------|-------------------|
| `common.labels.matchLabels` | Labels to use on `deploy.spec.selector.matchLabels` and `svc.spec.selector` | `.` Chart context |
| `common.labels.standard` | Return Kubernetes standard labels | `.` Chart context |
### Names
| Helper identifier | Description | Expected Input |
|-----------------------------------|-----------------------------------------------------------------------|-------------------|
| `common.names.chart` | Chart name plus version | `.` Chart context |
| `common.names.fullname` | Create a default fully qualified app name. | `.` Chart context |
| `common.names.fullname.namespace` | Create a fully qualified app name adding the installation's namespace | `.` Chart context |
| `common.names.name` | Expand the name of the chart or use `.Values.nameOverride` | `.` Chart context |
| `common.names.namespace` | Allow the release namespace to be overridden | `.` Chart context |
### TplValues
| Helper identifier | Description | Expected Input |
|------------------------------------|---------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------|
| `common.tplvalues.render` | Renders a value that contains template | `dict "value" .Values.path.to.the.Value "context" $`, value is the value should rendered as template, context frequently is the chart context `$` or `.` |
| `common.tplvalues.merge` | Merge a list of values that contains template after rendering them. | `dict "values" (list .Values.path.to.the.Value1 .Values.path.to.the.Value2) "context" $` |
| `common.tplvalues.merge-overwrite` | Merge a list of values that contains template after rendering them. | `dict "values" (list .Values.path.to.the.Value1 .Values.path.to.the.Value2) "context" $` |

26
helm/.helmignore Normal file
View File

@@ -0,0 +1,26 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
# img folder
img/
# Changelog
CHANGELOG.md

12
helm/Chart.yaml Normal file
View File

@@ -0,0 +1,12 @@
# Always have the same value for appVersion and version.
apiVersion: v2
appVersion: 0.1.0
description: A Library Helm Chart for grouping common logic between bitnami charts. This chart is not deployable by itself.
keywords:
- common
- helper
- template
- function
name: common
type: library
version: 0.1.0

View File

@@ -0,0 +1,14 @@
{{- define "common.labels.standard" }}
helm.sh/chart: {{ include "common.names.chart" . }}
app.kubernetes.io/name: {{ include "common.names.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- with .Chart.AppVersion }}
app.kubernetes.io/version: {{ . | quote }}
{{- end }}
{{- end }}
{{- define "common.labels.matchLabels" }}
app.kubernetes.io/name: {{ include "common.names.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

31
helm/templates/_names.tpl Normal file
View File

@@ -0,0 +1,31 @@
{{/* We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). */}}
{{- define "common.names.chart" }}
{{ printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- define "common.names.name" }}
{{ default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- define "common.names.namespace" }}
{{ default .Release.Namespace .Values.namespaceOverride | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- define "common.names.fullname" }}
{{- if .Values.fullnameOverride }}
{{ .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{ $name := default .Chart.Name .Values.nameOverride }}
{{- $releaseName := regexReplaceAll "(-?[^a-z\\d\\-])+-?" (lower .Release.Name) "-" }}
{{- if contains $name $releaseName }}
{{ $releaseName | trunc 63 | trimSuffix "-" }}
{{- else }}
{{ printf "%s-%s" $releaseName $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}
{{- define "common.names.fullname.namespace" }}
{{ printf "%s-%s" (include "common.names.fullname" .) (include "common.names.namespace" .) | trunc 63 | trimSuffix "-" }}
{{- end }}

View File

@@ -0,0 +1,28 @@
{{- define "common.tplvalues.render" -}}
{{- $value := typeIs "string" .value | ternary .value (.value | toYaml) }}
{{- if contains "{{" (toJson .value) }}
{{- if .scope }}
{{ tpl (cat "{{- with $.RelativeScope -}}" $value "{{- end }}") (merge (dict "RelativeScope" .scope) .context) }}
{{- else }}
{{ tpl $value .context }}
{{- end }}
{{- else }}
{{ $value }}
{{- end }}
{{- end }}
{{- define "common.tplvalues.merge" }}
{{- $dst := dict }}
{{- range .values }}
{{- $dst = include "common.tplvalues.render" (dict "value" . "context" $.context "scope" $.scope) | fromYaml | merge $dst }}
{{- end }}
{{ $dst | toYaml }}
{{- end }}
{{- define "common.tplvalues.merge-overwrite" }}
{{- $dst := dict }}
{{- range .values }}
{{- $dst = include "common.tplvalues.render" (dict "value" . "context" $.context "scope" $.scope) | fromYaml | mergeOverwrite $dst }}
{{- end }}
{{ $dst | toYaml }}
{{- end }}