From f29fa76685d9f553bc46c352b57b00801c7a0325 Mon Sep 17 00:00:00 2001 From: Swordsteel Date: Wed, 1 Oct 2025 11:01:48 +0200 Subject: [PATCH] initial commit --- .editorconfig | 10 ++++++++++ .gitea/workflows/release.yaml | 11 +++++++++++ .gitignore | 1 + README.md | 28 ++++++++++++++++++++++++++++ helm/.helmignore | 26 ++++++++++++++++++++++++++ helm/Chart.yaml | 12 ++++++++++++ helm/templates/_labels.tpl | 15 +++++++++++++++ helm/templates/_names.tpl | 31 +++++++++++++++++++++++++++++++ 8 files changed, 134 insertions(+) create mode 100644 .editorconfig create mode 100644 .gitea/workflows/release.yaml create mode 100644 .gitignore create mode 100644 README.md create mode 100644 helm/.helmignore create mode 100644 helm/Chart.yaml create mode 100644 helm/templates/_labels.tpl create mode 100644 helm/templates/_names.tpl diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..c84a12f --- /dev/null +++ b/.editorconfig @@ -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 diff --git a/.gitea/workflows/release.yaml b/.gitea/workflows/release.yaml new file mode 100644 index 0000000..0dced27 --- /dev/null +++ b/.gitea/workflows/release.yaml @@ -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 }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9f11b75 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea/ diff --git a/README.md b/README.md new file mode 100644 index 0000000..4247e3c --- /dev/null +++ b/README.md @@ -0,0 +1,28 @@ +# 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 | diff --git a/helm/.helmignore b/helm/.helmignore new file mode 100644 index 0000000..d0e1084 --- /dev/null +++ b/helm/.helmignore @@ -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 diff --git a/helm/Chart.yaml b/helm/Chart.yaml new file mode 100644 index 0000000..887105e --- /dev/null +++ b/helm/Chart.yaml @@ -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 diff --git a/helm/templates/_labels.tpl b/helm/templates/_labels.tpl new file mode 100644 index 0000000..5198e93 --- /dev/null +++ b/helm/templates/_labels.tpl @@ -0,0 +1,15 @@ + +{{- define "common.labels.standard" }} +app.kubernetes.io/name: {{ include "common.names.name" . }} +helm.sh/chart: {{ include "common.names.chart" . }} +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 }} diff --git a/helm/templates/_names.tpl b/helm/templates/_names.tpl new file mode 100644 index 0000000..ebbeda9 --- /dev/null +++ b/helm/templates/_names.tpl @@ -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 }}