You've already forked helm-actions
							
							refactor: use gitea.actions for global defines (#10)
### Description of the change Just moves all defines under a new gitea.actions prefix. ### Additional information Reduce possibility to cause a name clash with the helm-gitea chart if both would be included in a single helm chart installation. Reviewed-on: https://gitea.com/gitea/helm-actions/pulls/10 Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: Christopher Homberger <christopher.homberger@web.de> Co-committed-by: Christopher Homberger <christopher.homberger@web.de>
This commit is contained in:
		
				
					committed by
					
						
						Lunny Xiao
					
				
			
			
				
	
			
			
			
						parent
						
							490e690e09
						
					
				
				
					commit
					41c4bf1bc7
				
			@@ -3,7 +3,7 @@
 | 
			
		||||
Expand the name of the chart.
 | 
			
		||||
*/}}
 | 
			
		||||
 | 
			
		||||
{{- define "gitea.name" -}}
 | 
			
		||||
{{- define "gitea.actions.name" -}}
 | 
			
		||||
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
 | 
			
		||||
{{- end -}}
 | 
			
		||||
 | 
			
		||||
@@ -12,7 +12,7 @@ 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.fullname" -}}
 | 
			
		||||
{{- define "gitea.actions.fullname" -}}
 | 
			
		||||
{{- if .Values.fullnameOverride -}}
 | 
			
		||||
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
 | 
			
		||||
{{- else -}}
 | 
			
		||||
@@ -28,21 +28,21 @@ If release name contains chart name it will be used as a full name.
 | 
			
		||||
{{/*
 | 
			
		||||
Create a default worker name.
 | 
			
		||||
*/}}
 | 
			
		||||
{{- define "gitea.workername" -}}
 | 
			
		||||
{{- 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.chart" -}}
 | 
			
		||||
{{- define "gitea.actions.chart" -}}
 | 
			
		||||
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
 | 
			
		||||
{{- end -}}
 | 
			
		||||
 | 
			
		||||
{{/*
 | 
			
		||||
Create image name and tag used by the deployment.
 | 
			
		||||
*/}}
 | 
			
		||||
{{- define "gitea.image" -}}
 | 
			
		||||
{{- define "gitea.actions.image" -}}
 | 
			
		||||
{{- $fullOverride := .Values.image.fullOverride | default "" -}}
 | 
			
		||||
{{- $registry := .Values.global.imageRegistry | default .Values.image.registry -}}
 | 
			
		||||
{{- $repository := .Values.image.repository -}}
 | 
			
		||||
@@ -65,7 +65,7 @@ Create image name and tag used by the deployment.
 | 
			
		||||
{{/*
 | 
			
		||||
Storage Class
 | 
			
		||||
*/}}
 | 
			
		||||
{{- define "gitea.persistence.storageClass" -}}
 | 
			
		||||
{{- define "gitea.actions.persistence.storageClass" -}}
 | 
			
		||||
{{- $storageClass :=  (tpl ( default "" .Values.persistence.storageClass) .) | default (tpl ( default "" .Values.global.storageClass) .) }}
 | 
			
		||||
{{- if $storageClass }}
 | 
			
		||||
storageClassName: {{ $storageClass | quote }}
 | 
			
		||||
@@ -75,19 +75,19 @@ storageClassName: {{ $storageClass | quote }}
 | 
			
		||||
{{/*
 | 
			
		||||
Common labels
 | 
			
		||||
*/}}
 | 
			
		||||
{{- define "gitea.labels" -}}
 | 
			
		||||
helm.sh/chart: {{ include "gitea.chart" . }}
 | 
			
		||||
app: {{ include "gitea.name" . }}
 | 
			
		||||
{{ include "gitea.selectorLabels" . }}
 | 
			
		||||
{{- define "gitea.actions.labels" -}}
 | 
			
		||||
helm.sh/chart: {{ include "gitea.actions.chart" . }}
 | 
			
		||||
app: {{ include "gitea.actions.name" . }}
 | 
			
		||||
{{ include "gitea.actions.selectorLabels" . }}
 | 
			
		||||
app.kubernetes.io/version: {{ .Values.image.tag | default .Chart.AppVersion | quote }}
 | 
			
		||||
version: {{ .Values.image.tag | default .Chart.AppVersion | quote }}
 | 
			
		||||
app.kubernetes.io/managed-by: {{ .Release.Service }}
 | 
			
		||||
{{- end -}}
 | 
			
		||||
 | 
			
		||||
{{- define "gitea.labels.actRunner" -}}
 | 
			
		||||
helm.sh/chart: {{ include "gitea.chart" . }}
 | 
			
		||||
app: {{ include "gitea.name" . }}-act-runner
 | 
			
		||||
{{ include "gitea.selectorLabels.actRunner" . }}
 | 
			
		||||
{{- 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: {{ .Values.image.tag | default .Chart.AppVersion | quote }}
 | 
			
		||||
version: {{ .Values.image.tag | default .Chart.AppVersion | quote }}
 | 
			
		||||
app.kubernetes.io/managed-by: {{ .Release.Service }}
 | 
			
		||||
@@ -96,25 +96,25 @@ app.kubernetes.io/managed-by: {{ .Release.Service }}
 | 
			
		||||
{{/*
 | 
			
		||||
Selector labels
 | 
			
		||||
*/}}
 | 
			
		||||
{{- define "gitea.selectorLabels" -}}
 | 
			
		||||
app.kubernetes.io/name: {{ include "gitea.name" . }}
 | 
			
		||||
{{- define "gitea.actions.selectorLabels" -}}
 | 
			
		||||
app.kubernetes.io/name: {{ include "gitea.actions.name" . }}
 | 
			
		||||
app.kubernetes.io/instance: {{ .Release.Name }}
 | 
			
		||||
{{- end -}}
 | 
			
		||||
 | 
			
		||||
{{- define "gitea.selectorLabels.actRunner" -}}
 | 
			
		||||
app.kubernetes.io/name: {{ include "gitea.name" . }}-act-runner
 | 
			
		||||
{{- define "gitea.actions.selectorLabels.actRunner" -}}
 | 
			
		||||
app.kubernetes.io/name: {{ include "gitea.actions.name" . }}-act-runner
 | 
			
		||||
app.kubernetes.io/instance: {{ .Release.Name }}
 | 
			
		||||
{{- end -}}
 | 
			
		||||
 | 
			
		||||
{{- define "gitea.act_runner.local_root_url" -}}
 | 
			
		||||
{{- define "gitea.actions.local_root_url" -}}
 | 
			
		||||
  {{- .Values.giteaRootURL -}}
 | 
			
		||||
{{- end -}}
 | 
			
		||||
 | 
			
		||||
{{/*
 | 
			
		||||
Parse the http url to hostname + port separated by space for the nc command
 | 
			
		||||
*/}}
 | 
			
		||||
{{- define "gitea.act_runner.nc" -}}
 | 
			
		||||
{{- $url := include "gitea.act_runner.local_root_url" . | urlParse -}}
 | 
			
		||||
{{- define "gitea.actions.nc" -}}
 | 
			
		||||
{{- $url := include "gitea.actions.local_root_url" . | urlParse -}}
 | 
			
		||||
{{- $host := get $url "host" -}}
 | 
			
		||||
{{- $scheme := get $url "scheme" -}}
 | 
			
		||||
{{- $port := "80" -}}
 | 
			
		||||
 
 | 
			
		||||
@@ -3,10 +3,10 @@
 | 
			
		||||
apiVersion: v1
 | 
			
		||||
kind: ConfigMap
 | 
			
		||||
metadata:
 | 
			
		||||
  name: {{ include "gitea.fullname" . }}-act-runner-config
 | 
			
		||||
  name: {{ include "gitea.actions.fullname" . }}-act-runner-config
 | 
			
		||||
  namespace: {{ .Values.namespace | default .Release.Namespace }}
 | 
			
		||||
  labels:
 | 
			
		||||
    {{- include "gitea.labels" . | nindent 4 }}
 | 
			
		||||
    {{- include "gitea.actions.labels" . | nindent 4 }}
 | 
			
		||||
data:
 | 
			
		||||
  config.yaml: |
 | 
			
		||||
    {{- with .Values.statefulset.actRunner.config -}}
 | 
			
		||||
 
 | 
			
		||||
@@ -4,10 +4,10 @@
 | 
			
		||||
apiVersion: v1
 | 
			
		||||
kind: ConfigMap
 | 
			
		||||
metadata:
 | 
			
		||||
  name: {{ include "gitea.fullname" . }}-scripts
 | 
			
		||||
  name: {{ include "gitea.actions.fullname" . }}-scripts
 | 
			
		||||
  namespace: {{ .Values.namespace | default .Release.Namespace }}
 | 
			
		||||
  labels:
 | 
			
		||||
    {{- include "gitea.labels" . | nindent 4 }}
 | 
			
		||||
    {{- include "gitea.actions.labels" . | nindent 4 }}
 | 
			
		||||
data:
 | 
			
		||||
{{ (.Files.Glob "scripts/*.sh").AsConfig | indent 2 }}
 | 
			
		||||
{{- end }}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
{{- if .Values.enabled }}
 | 
			
		||||
{{- if and (and .Values.provisioning.enabled .Values.persistence.enabled) .Values.persistence.mount }}
 | 
			
		||||
{{- $name := include "gitea.workername" (dict "global" . "worker" "actions-token-job") }}
 | 
			
		||||
{{- $secretName := include "gitea.workername" (dict "global" . "worker" "actions-token") }}
 | 
			
		||||
{{- $name := include "gitea.actions.workername" (dict "global" . "worker" "actions-token-job") }}
 | 
			
		||||
{{- $secretName := include "gitea.actions.workername" (dict "global" . "worker" "actions-token") }}
 | 
			
		||||
---
 | 
			
		||||
apiVersion: batch/v1
 | 
			
		||||
kind: Job
 | 
			
		||||
@@ -9,7 +9,7 @@ metadata:
 | 
			
		||||
  name: {{ $name }}
 | 
			
		||||
  namespace: {{ .Values.namespace | default .Release.Namespace }}
 | 
			
		||||
  labels:
 | 
			
		||||
    {{- include "gitea.labels" . | nindent 4 }}
 | 
			
		||||
    {{- include "gitea.actions.labels" . | nindent 4 }}
 | 
			
		||||
    {{- with .Values.provisioning.labels }}
 | 
			
		||||
    {{- toYaml . | nindent 4 }}
 | 
			
		||||
    {{- end }}
 | 
			
		||||
@@ -23,7 +23,7 @@ spec:
 | 
			
		||||
  template:
 | 
			
		||||
    metadata:
 | 
			
		||||
      labels:
 | 
			
		||||
        {{- include "gitea.labels" . | nindent 8 }}
 | 
			
		||||
        {{- include "gitea.actions.labels" . | nindent 8 }}
 | 
			
		||||
        {{- with .Values.provisioning.labels }}
 | 
			
		||||
        {{- toYaml . | nindent 8 }}
 | 
			
		||||
        {{- end }}
 | 
			
		||||
@@ -36,12 +36,12 @@ spec:
 | 
			
		||||
            - sh
 | 
			
		||||
            - -c
 | 
			
		||||
            - |
 | 
			
		||||
              while ! nc -z {{ include "gitea.act_runner.nc" . }}; do
 | 
			
		||||
              while ! nc -z {{ include "gitea.actions.nc" . }}; do
 | 
			
		||||
                sleep 5
 | 
			
		||||
              done
 | 
			
		||||
      containers:
 | 
			
		||||
        - name: actions-token-create
 | 
			
		||||
          image: "{{ include "gitea.image" . }}"
 | 
			
		||||
          image: "{{ include "gitea.actions.image" . }}"
 | 
			
		||||
          imagePullPolicy: {{ .Values.image.pullPolicy }}
 | 
			
		||||
          env:
 | 
			
		||||
            - name: GITEA_APP_INI
 | 
			
		||||
@@ -103,7 +103,7 @@ spec:
 | 
			
		||||
      volumes:
 | 
			
		||||
        - name: scripts
 | 
			
		||||
          configMap:
 | 
			
		||||
            name: {{ include "gitea.fullname" . }}-scripts
 | 
			
		||||
            name: {{ include "gitea.actions.fullname" . }}-scripts
 | 
			
		||||
            defaultMode: 0755
 | 
			
		||||
        - name: data
 | 
			
		||||
          persistentVolumeClaim:
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
{{- if .Values.enabled }}
 | 
			
		||||
{{- if and (and .Values.provisioning.enabled .Values.persistence.enabled) .Values.persistence.mount }}
 | 
			
		||||
{{- $name := include "gitea.workername" (dict "global" . "worker" "actions-token-job") }}
 | 
			
		||||
{{- $secretName := include "gitea.workername" (dict "global" . "worker" "actions-token") }}
 | 
			
		||||
{{- $name := include "gitea.actions.workername" (dict "global" . "worker" "actions-token-job") }}
 | 
			
		||||
{{- $secretName := include "gitea.actions.workername" (dict "global" . "worker" "actions-token") }}
 | 
			
		||||
---
 | 
			
		||||
apiVersion: rbac.authorization.k8s.io/v1
 | 
			
		||||
kind: Role
 | 
			
		||||
@@ -9,7 +9,7 @@ metadata:
 | 
			
		||||
  name: {{ $name }}
 | 
			
		||||
  namespace: {{ .Values.namespace | default .Release.Namespace }}
 | 
			
		||||
  labels:
 | 
			
		||||
    {{- include "gitea.labels" . | nindent 4 }}
 | 
			
		||||
    {{- include "gitea.actions.labels" . | nindent 4 }}
 | 
			
		||||
    app.kubernetes.io/component: token-job
 | 
			
		||||
rules:
 | 
			
		||||
  - apiGroups:
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
{{- if .Values.enabled }}
 | 
			
		||||
{{- if and (and .Values.provisioning.enabled .Values.persistence.enabled) .Values.persistence.mount }}
 | 
			
		||||
{{- $name := include "gitea.workername" (dict "global" . "worker" "actions-token-job") }}
 | 
			
		||||
{{- $name := include "gitea.actions.workername" (dict "global" . "worker" "actions-token-job") }}
 | 
			
		||||
---
 | 
			
		||||
apiVersion: rbac.authorization.k8s.io/v1
 | 
			
		||||
kind: RoleBinding
 | 
			
		||||
@@ -8,7 +8,7 @@ metadata:
 | 
			
		||||
  name: {{ $name }}
 | 
			
		||||
  namespace: {{ .Values.namespace | default .Release.Namespace }}
 | 
			
		||||
  labels:
 | 
			
		||||
    {{- include "gitea.labels" . | nindent 4 }}
 | 
			
		||||
    {{- include "gitea.actions.labels" . | nindent 4 }}
 | 
			
		||||
    app.kubernetes.io/component: token-job
 | 
			
		||||
roleRef:
 | 
			
		||||
  apiGroup: rbac.authorization.k8s.io
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
{{- if .Values.enabled }}
 | 
			
		||||
{{- if and (and .Values.provisioning.enabled .Values.persistence.enabled) .Values.persistence.mount }}
 | 
			
		||||
{{- $name := include "gitea.workername" (dict "global" . "worker" "actions-token-job") }}
 | 
			
		||||
{{- $secretName := include "gitea.workername" (dict "global" . "worker" "actions-token") }}
 | 
			
		||||
{{- $name := include "gitea.actions.workername" (dict "global" . "worker" "actions-token-job") }}
 | 
			
		||||
{{- $secretName := include "gitea.actions.workername" (dict "global" . "worker" "actions-token") }}
 | 
			
		||||
---
 | 
			
		||||
apiVersion: v1
 | 
			
		||||
kind: Secret
 | 
			
		||||
@@ -9,7 +9,7 @@ metadata:
 | 
			
		||||
  name: {{ $secretName }}
 | 
			
		||||
  namespace: {{ .Values.namespace | default .Release.Namespace }}
 | 
			
		||||
  labels:
 | 
			
		||||
    {{- include "gitea.labels" . | nindent 4 }}
 | 
			
		||||
    {{- include "gitea.actions.labels" . | nindent 4 }}
 | 
			
		||||
    app.kubernetes.io/component: token-job
 | 
			
		||||
{{ $secret := (lookup "v1" "Secret" .Release.Namespace $secretName) -}}
 | 
			
		||||
{{ if $secret -}}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
{{- if .Values.enabled }}
 | 
			
		||||
{{- if and (and .Values.provisioning.enabled .Values.persistence.enabled) .Values.persistence.mount }}
 | 
			
		||||
{{- $name := include "gitea.workername" (dict "global" . "worker" "actions-token-job") }}
 | 
			
		||||
{{- $name := include "gitea.actions.workername" (dict "global" . "worker" "actions-token-job") }}
 | 
			
		||||
---
 | 
			
		||||
apiVersion: v1
 | 
			
		||||
kind: ServiceAccount
 | 
			
		||||
@@ -8,7 +8,7 @@ metadata:
 | 
			
		||||
  name: {{ $name }}
 | 
			
		||||
  namespace: {{ .Values.namespace | default .Release.Namespace }}
 | 
			
		||||
  labels:
 | 
			
		||||
    {{- include "gitea.labels" . | nindent 4 }}
 | 
			
		||||
    {{- include "gitea.actions.labels" . | nindent 4 }}
 | 
			
		||||
    app.kubernetes.io/component: token-job
 | 
			
		||||
{{- end }}
 | 
			
		||||
{{- end }}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,11 +1,11 @@
 | 
			
		||||
{{- if .Values.enabled }}
 | 
			
		||||
{{- $secretName := include "gitea.workername" (dict "global" . "worker" "actions-token") }}
 | 
			
		||||
{{- $secretName := include "gitea.actions.workername" (dict "global" . "worker" "actions-token") }}
 | 
			
		||||
---
 | 
			
		||||
apiVersion: apps/v1
 | 
			
		||||
kind: StatefulSet
 | 
			
		||||
metadata:
 | 
			
		||||
  labels:
 | 
			
		||||
    {{- include "gitea.labels.actRunner" . | nindent 4 }}
 | 
			
		||||
    {{- include "gitea.actions.labels.actRunner" . | nindent 4 }}
 | 
			
		||||
    {{- with .Values.statefulset.labels }}
 | 
			
		||||
    {{- toYaml . | nindent 4 }}
 | 
			
		||||
    {{- end }}
 | 
			
		||||
@@ -13,18 +13,18 @@ metadata:
 | 
			
		||||
    {{- with .Values.statefulset.annotations }}
 | 
			
		||||
    {{- toYaml . | nindent 4 }}
 | 
			
		||||
    {{- end }}
 | 
			
		||||
  name: {{ include "gitea.fullname" . }}-act-runner
 | 
			
		||||
  name: {{ include "gitea.actions.fullname" . }}-act-runner
 | 
			
		||||
  namespace: {{ .Values.namespace | default .Release.Namespace }}
 | 
			
		||||
spec:
 | 
			
		||||
  selector:
 | 
			
		||||
    matchLabels:
 | 
			
		||||
      {{- include "gitea.selectorLabels.actRunner" . | nindent 6 }}
 | 
			
		||||
      {{- include "gitea.actions.selectorLabels.actRunner" . | nindent 6 }}
 | 
			
		||||
  template:
 | 
			
		||||
    metadata:
 | 
			
		||||
      annotations:
 | 
			
		||||
        checksum/config: {{ include (print $.Template.BasePath "/config-act-runner.yaml") . | sha256sum }}
 | 
			
		||||
      labels:
 | 
			
		||||
        {{- include "gitea.labels.actRunner" . | nindent 8 }}
 | 
			
		||||
        {{- include "gitea.actions.labels.actRunner" . | nindent 8 }}
 | 
			
		||||
        {{- with .Values.statefulset.labels }}
 | 
			
		||||
        {{- toYaml . | nindent 8 }}
 | 
			
		||||
        {{- end }}
 | 
			
		||||
@@ -36,7 +36,7 @@ spec:
 | 
			
		||||
            - sh
 | 
			
		||||
            - -c
 | 
			
		||||
            - |
 | 
			
		||||
              while ! nc -z {{ include "gitea.act_runner.nc" . }}; do
 | 
			
		||||
              while ! nc -z {{ include "gitea.actions.nc" . }}; do
 | 
			
		||||
                sleep 5
 | 
			
		||||
              done
 | 
			
		||||
      containers:
 | 
			
		||||
@@ -57,7 +57,7 @@ spec:
 | 
			
		||||
                  name: "{{ .Values.existingSecret | default $secretName }}"
 | 
			
		||||
                  key: "{{ .Values.existingSecretKey | default "token" }}"
 | 
			
		||||
            - name: GITEA_INSTANCE_URL
 | 
			
		||||
              value: {{ include "gitea.act_runner.local_root_url" . }}
 | 
			
		||||
              value: {{ include "gitea.actions.local_root_url" . }}
 | 
			
		||||
            - name: CONFIG_FILE
 | 
			
		||||
              value: /actrunner/config.yaml
 | 
			
		||||
          resources:
 | 
			
		||||
@@ -111,7 +111,7 @@ spec:
 | 
			
		||||
      volumes:
 | 
			
		||||
        - name: act-runner-config
 | 
			
		||||
          configMap:
 | 
			
		||||
            name: {{ include "gitea.fullname" . }}-act-runner-config
 | 
			
		||||
            name: {{ include "gitea.actions.fullname" . }}-act-runner-config
 | 
			
		||||
        - name: docker-certs
 | 
			
		||||
          emptyDir: {}
 | 
			
		||||
        {{- with .Values.statefulset.extraVolumes }}
 | 
			
		||||
@@ -122,7 +122,7 @@ spec:
 | 
			
		||||
        name: data-act-runner
 | 
			
		||||
      spec:
 | 
			
		||||
        accessModes: [ "ReadWriteOnce" ]
 | 
			
		||||
        {{- include "gitea.persistence.storageClass" . | nindent 8 }}
 | 
			
		||||
        {{- include "gitea.actions.persistence.storageClass" . | nindent 8 }}
 | 
			
		||||
        resources:
 | 
			
		||||
          requests:
 | 
			
		||||
            storage: {{ .Values.statefulset.persistence.size }}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user