mirror of
https://gitea.com/gitea/helm-actions.git
synced 2025-10-21 15:08:14 +00:00

<!-- Before you open the request please review the following guidelines and tips to help it be more easily integrated: - Describe the scope of your change - i.e. what the change does. - Describe any known limitations with your change. - Please run any tests or examples that can exercise your modified code. Thank you for contributing! We will try to review, test and integrate the change as soon as we can. --> ### Description of the change <!-- Describe the scope of your change - i.e. what the change does. --> The change modifies how container images are managed in the Gitea Helm chart for Gitea Actions. Instead of using a simple string concatenation for image names, the patch introduces a more flexible templating approach. It adds three new templates in `_helpers.tpl`: * `gitea.actions.actRunner.image`: Constructs the full image name for the Gitea Actions Act Runner. * `gitea.actions.dind.image`: Creates the image name for the DinD (Docker-in-Docker) container. * `gitea.actions.init.image`: Generates the image name for the Init container. These templates build the image name dynamically using values from `values.yaml` and the chart's metadata. The logic prioritizes a full image override, a specified registry, or a default repository and tag. The patch also updates `statefulset.yaml` to use these new templates for the `init-gitea`, `act-runner`, and `dind` containers. Additionally, `values.yaml` is updated to include new, optional parameters for each image, such as `registry`, `digest`, and `fullOverride`, providing more granular control over the image source. ### Tests and Examples To test this change, you can use `helm template` with different configurations in a `values.yaml` file to observe the resulting Kubernetes manifest. #### Example 1: Default configuration With no changes to the new fields in `values.yaml`, the image names should resolve to the defaults: * **Act Runner**: `docker.gitea.com/gitea/act_runner:0.2.13` * **DinD**: `docker:28.3.3-dind` * **Init**: `busybox:1.37.0` #### Example 2: Using a `fullOverride` If you set `fullOverride` for the `actRunner` like this via CLI ```shell helm template test . \ --set giteaRootURL=https://localhost/gitea \ --set existingSecret=test --set existingSecretKey=test \ --set enabled=true \ --set statefulset.actRunner.fullOverride="my.private.registry/custom-gitea-runner:latest" ``` The `statefulset.yaml` for the `act-runner` container will have its image field set to `my.private.registry/custom-gitea-runner:latest`. ``` - name: act-runner image: "my.private.registry/custom-gitea-runner:latest" ``` #### Example 3: Using a custom `registry` and `digest` ```shell helm template test . \ --set giteaRootURL=https://localhost/gitea \ --set existingSecret=test --set existingSecretKey=test \ --set enabled=true \ --set statefulset.dind.registry="quay.io" \ --set statefulset.dind.digest="sha256:abcdef123456" ``` The `statefulset.yaml` for the `dind` container will have its image field set to `quay.io/docker:28.3.3-dind@sha256:abcdef123456`. ``` - name: dind image: "quay.io/docker:28.3.3-dind@sha256:abcdef123456" ``` #### Example 4: Using the `global.imageRegistry` If you set global.imageRegistry ```shell helm template test . \ --set giteaRootURL=https://localhost/gitea \ --set existingSecret=test --set existingSecretKey=test \ --set enabled=true \ --set global.imageRegistry=quay.io ``` The `statefulset.yaml` for each container will have the following values * **Act Runner**: `quay.io/gitea/act_runner:0.2.13` * **DinD**: `quay.io/docker:28.3.3-dind` * **Init**: `quay.io/busybox:1.37.0` ### Benefits <!-- What benefits will be realized by the code change? --> There are no known limitations with this change. The new templating approach makes the chart more adaptable and configurable, offering more control than the previous method. ### Possible drawbacks <!-- Describe any known limitations with your change --> Increased configuration complexity ### Applicable issues <!-- Enter any applicable Issues here (You can reference an issue using #). Please remove this section if there is no referenced issue. --> - Fixes #58 ### Additional information <!-- If there's anything else that's important and relevant to your pull request, mention that information here. Please remove this section if it remains empty. --> ### ⚠ BREAKING <!-- If there's a breaking change, please shortly describe in which way users are affected and how they can mitigate it. If there are no breakings, please remove this section. --> ### Checklist <!-- [Place an '[X]' (no spaces) in all applicable fields. Please remove unrelated fields.] --> - [X] Parameters are documented in the `values.yaml` and added to the `README.md` using [readme-generator-for-helm](https://github.com/bitnami-labs/readme-generator-for-helm) - [X] Helm templating unittests are added (required when changing anything in `templates` folder) - [X] All added template resources MUST render a namespace in metadata Co-authored-by: Christopher Homberger <christopher.homberger@web.de> Reviewed-on: https://gitea.com/gitea/helm-actions/pulls/61 Reviewed-by: Ross Golder <rossigee@noreply.gitea.com> Reviewed-by: DaanSelen <daanselen@noreply.gitea.com> Reviewed-by: Markus Pesch <volker.raschek@noreply.gitea.com> Reviewed-by: ChristopherHX <christopherhx@noreply.gitea.com> Co-authored-by: Stephen Sullivan <sjsullivan7@gmail.com> Co-committed-by: Stephen Sullivan <sjsullivan7@gmail.com>
131 lines
4.0 KiB
Smarty
131 lines
4.0 KiB
Smarty
{{/* vim: set filetype=mustache: */}}
|
|
{{/*
|
|
Expand the name of the chart.
|
|
*/}}
|
|
|
|
{{- define "gitea.actions.name" -}}
|
|
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
|
|
{{- end -}}
|
|
|
|
{{/*
|
|
Create a default fully qualified app name.
|
|
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
|
|
If release name contains chart name it will be used as a full name.
|
|
*/}}
|
|
{{- define "gitea.actions.fullname" -}}
|
|
{{- if .Values.fullnameOverride -}}
|
|
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
|
|
{{- else -}}
|
|
{{- $name := default .Chart.Name .Values.nameOverride -}}
|
|
{{- if contains $name .Release.Name -}}
|
|
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
|
|
{{- else -}}
|
|
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
|
|
{{/*
|
|
Create a default worker name.
|
|
*/}}
|
|
{{- define "gitea.actions.workername" -}}
|
|
{{- printf "%s-%s" .global.Release.Name .worker | trunc 63 | trimSuffix "-" -}}
|
|
{{- end -}}
|
|
|
|
{{/*
|
|
Create chart name and version as used by the chart label.
|
|
*/}}
|
|
{{- define "gitea.actions.chart" -}}
|
|
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
|
|
{{- end -}}
|
|
|
|
{{/*
|
|
Storage Class
|
|
*/}}
|
|
{{- define "gitea.actions.persistence.storageClass" -}}
|
|
{{- $storageClass := default (tpl ( default "" .Values.global.storageClass) .) }}
|
|
{{- if $storageClass }}
|
|
storageClassName: {{ $storageClass | quote }}
|
|
{{- end }}
|
|
{{- end -}}
|
|
|
|
{{/*
|
|
Common labels
|
|
*/}}
|
|
{{- define "gitea.actions.labels" -}}
|
|
helm.sh/chart: {{ include "gitea.actions.chart" . }}
|
|
app: {{ include "gitea.actions.name" . }}
|
|
{{ include "gitea.actions.selectorLabels" . }}
|
|
app.kubernetes.io/version: {{ default .Chart.AppVersion | quote }}
|
|
version: {{ default .Chart.AppVersion | quote }}
|
|
app.kubernetes.io/managed-by: {{ .Release.Service }}
|
|
{{- end -}}
|
|
|
|
{{- define "gitea.actions.labels.actRunner" -}}
|
|
helm.sh/chart: {{ include "gitea.actions.chart" . }}
|
|
app: {{ include "gitea.actions.name" . }}-act-runner
|
|
{{ include "gitea.actions.selectorLabels.actRunner" . }}
|
|
app.kubernetes.io/version: {{ default .Chart.AppVersion | quote }}
|
|
version: {{ default .Chart.AppVersion | quote }}
|
|
app.kubernetes.io/managed-by: {{ .Release.Service }}
|
|
{{- end -}}
|
|
|
|
{{/*
|
|
Selector labels
|
|
*/}}
|
|
{{- define "gitea.actions.selectorLabels" -}}
|
|
app.kubernetes.io/name: {{ include "gitea.actions.name" . }}
|
|
app.kubernetes.io/instance: {{ .Release.Name }}
|
|
{{- end -}}
|
|
|
|
{{- define "gitea.actions.selectorLabels.actRunner" -}}
|
|
app.kubernetes.io/name: {{ include "gitea.actions.name" . }}-act-runner
|
|
app.kubernetes.io/instance: {{ .Release.Name }}
|
|
{{- end -}}
|
|
|
|
{{- define "gitea.actions.local_root_url" -}}
|
|
{{- .Values.giteaRootURL -}}
|
|
{{- end -}}
|
|
|
|
{{/*
|
|
Common create image implementation
|
|
*/}}
|
|
{{- define "gitea.actions.common.image" -}}
|
|
{{- $fullOverride := .image.fullOverride | default "" -}}
|
|
{{- $registry := .root.Values.global.imageRegistry | default .image.registry -}}
|
|
{{- $repository := .image.repository -}}
|
|
{{- $separator := ":" -}}
|
|
{{- $tag := .image.tag | default .root.Chart.AppVersion | toString -}}
|
|
{{- $digest := "" -}}
|
|
{{- if .image.digest }}
|
|
{{- $digest = (printf "@%s" (.image.digest | toString)) -}}
|
|
{{- end -}}
|
|
{{- if $fullOverride }}
|
|
{{- printf "%s" $fullOverride -}}
|
|
{{- else if $registry }}
|
|
{{- printf "%s/%s%s%s%s" $registry $repository $separator $tag $digest -}}
|
|
{{- else -}}
|
|
{{- printf "%s%s%s%s" $repository $separator $tag $digest -}}
|
|
{{- end -}}
|
|
{{- end -}}
|
|
|
|
{{/*
|
|
Create image for the Gitea Actions Act Runner
|
|
*/}}
|
|
{{- define "gitea.actions.actRunner.image" -}}
|
|
{{ include "gitea.actions.common.image" (dict "root" . "image" .Values.statefulset.actRunner) }}
|
|
{{- end -}}
|
|
|
|
{{/*
|
|
Create image for DinD
|
|
*/}}
|
|
{{- define "gitea.actions.dind.image" -}}
|
|
{{ include "gitea.actions.common.image" (dict "root" . "image" .Values.statefulset.dind) }}
|
|
{{- end -}}
|
|
|
|
{{/*
|
|
Create image for Init
|
|
*/}}
|
|
{{- define "gitea.actions.init.image" -}}
|
|
{{ include "gitea.actions.common.image" (dict "root" . "image" .Values.init.image) }}
|
|
{{- end -}} |