mirror of
https://github.com/actions/actions-runner-controller.git
synced 2026-01-17 01:04:47 +08:00
slowly develop nicer helper functions
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
|
||||
{{- define "autoscaling-runner-set.name" -}}
|
||||
{{- $name := .Values.runnerScaleSetName | default .Release.Name | replace "_" "-" | trimSuffix "-" }}
|
||||
{{- if or (empty $name) (gt (len $name) 45) }}
|
||||
@@ -10,11 +11,59 @@
|
||||
{{- .Values.namespaceOverride | default .Release.Namespace -}}
|
||||
{{- end }}
|
||||
|
||||
|
||||
{{- define "githubsecret.name" -}}
|
||||
{{/*
|
||||
The name of the GitHub secret used for authentication.
|
||||
*/}}
|
||||
{{- define "github-secret.name" -}}
|
||||
{{- if not (empty .Values.auth.secretName) }}
|
||||
{{- quote .Values.auth.secretName }}
|
||||
{{- else }}
|
||||
{{- include "autoscaling-runner-set.name" . }}-github-secret
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Create the labels for the autoscaling runner set.
|
||||
*/}}
|
||||
{{- define "autoscaling-runner-set.labels" -}}
|
||||
{{- $resourceLabels := dict "app.kubernetes.io/component" "autoscaling-runner-set" -}}
|
||||
{{- $commonLabels := include "gha-common-labels" .Values | fromYaml -}}
|
||||
{{- $userLabels := include "gha-process-labels" .Values.resource.autoscalingRunnerSet.metadata.labels | fromYaml -}}
|
||||
{{- $global := include "gha-process-labels" .Values.resource.all.metadata.labels | fromYaml -}}
|
||||
{{- mergeOverwrite $global $userLabels $resourceLabels $commonLabels -}}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Create the common labels used across all resources.
|
||||
*/}}
|
||||
{{- define "gha-common-labels" -}}
|
||||
helm.sh/chart: {{ include "gha-runner-scale-set.chart" . }}
|
||||
app.kubernetes.io/name: {{ include "autoscaling-runner-set.name" . }}
|
||||
app.kubernetes.io/instance: {{ include "autoscaling-runner-set.name" . }}
|
||||
app.kubernetes.io/version: {{ .Chart.AppVersion }}
|
||||
app.kubernetes.io/managed-by: {{ .Release.Service }}
|
||||
app.kubernetes.io/part-of: "gha-rs"
|
||||
actions.github.com/scale-set-name: {{ include "autoscaling-runner-set.name" . }}
|
||||
actions.github.com/scale-set-namespace: {{ include "autoscaling-runner-set.namespace" . }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Takes a map of user labels and removes the ones with "actions.github.com/" prefix
|
||||
*/}}
|
||||
{{- define "gha-process-labels" -}}
|
||||
{{- $userLabels := . -}}
|
||||
{{- $processed := dict -}}
|
||||
{{- range $key, $value := $userLabels -}}
|
||||
{{- if not (hasPrefix $key "actions.github.com/") -}}
|
||||
{{- $_ := set $processed $key $value -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- $processed -}}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Create chart name and version as used by the chart label.
|
||||
*/}}
|
||||
{{- define "gha-runner-scale-set.chart" -}}
|
||||
{{- printf "%s-%s" (include "gha-base-name" .) .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
|
||||
{{- end }}
|
||||
|
||||
@@ -3,9 +3,11 @@ kind: AutoscalingRunnerSet
|
||||
metadata:
|
||||
name: {{ include "autoscaling-runner-set.name" . | quote }}
|
||||
namespace: {{ include "autoscaling-runner-set.namespace" . | quote }}
|
||||
labels: {{ include "autoscaling-runner-set.labels" . | nindent 4 }}
|
||||
|
||||
spec:
|
||||
githubConfigUrl: {{ required ".Values.auth.url is required" (trimSuffix "/" .Values.auth.url) | quote }}
|
||||
githubConfigSecret: {{ include "githubsecret.name" . | quote }}
|
||||
githubConfigSecret: {{ include "github-secret.name" . | quote }}
|
||||
runnerGroup: {{ .Values.scaleset.runnerGroup | quote }}
|
||||
|
||||
{{- if .Values.githubServerTLS }}
|
||||
@@ -18,21 +20,21 @@ spec:
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{- if and .Values.keyVault .Values.keyVault.type }}
|
||||
{{- if and .Values.secretResolution (ne .Values.secretResolution.type "kubernetes") }}
|
||||
vaultConfig:
|
||||
type: {{ .Values.keyVault.type }}
|
||||
{{- if .Values.keyVault.proxy }}
|
||||
proxy: {{- toYaml .Values.keyVault.proxy | nindent 6 }}
|
||||
type: {{ .Values.secretResolution.type }}
|
||||
{{- if .Values.secretResolution.proxy }}
|
||||
proxy: {{- toYaml .Values.secretResolution.proxy | nindent 6 }}
|
||||
{{- end }}
|
||||
{{- if eq .Values.keyVault.type "azure_key_vault" }}
|
||||
{{- if eq .Values.secretResolution.type "azureKeyVault" }}
|
||||
azureKeyVault:
|
||||
url: {{ .Values.keyVault.azureKeyVault.url }}
|
||||
tenantId: {{ .Values.keyVault.azureKeyVault.tenantId }}
|
||||
clientId: {{ .Values.keyVault.azureKeyVault.clientId }}
|
||||
certificatePath: {{ .Values.keyVault.azureKeyVault.certificatePath }}
|
||||
secretKey: {{ .Values.keyVault.azureKeyVault.secretKey }}
|
||||
url: {{ .Values.secretResolution.azureKeyVault.url }}
|
||||
tenantId: {{ .Values.secretResolution.azureKeyVault.tenantId }}
|
||||
clientId: {{ .Values.secretResolution.azureKeyVault.clientId }}
|
||||
certificatePath: {{ .Values.secretResolution.azureKeyVault.certificatePath }}
|
||||
secretKey: {{ .Values.secretResolution.azureKeyVault.secretKey }}
|
||||
{{- else }}
|
||||
{{- fail "Unsupported keyVault type: " .Values.keyVault.type }}
|
||||
{{- fail "Unsupported keyVault type: " .Values.secretResolution.type }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user