|
| 1 | +{{/* |
| 2 | +Expand the name of the chart. |
| 3 | +*/}} |
| 4 | +{{- define "cocov-chart.name" -}} |
| 5 | +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} |
| 6 | +{{- end }} |
| 7 | + |
| 8 | +{{/* |
| 9 | +Create a default fully qualified app name. |
| 10 | +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). |
| 11 | +If release name contains chart name it will be used as a full name. |
| 12 | +*/}} |
| 13 | +{{- define "cocov-chart.fullname" -}} |
| 14 | +{{- if .Values.fullnameOverride }} |
| 15 | +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} |
| 16 | +{{- else }} |
| 17 | +{{- $name := default .Chart.Name .Values.nameOverride }} |
| 18 | +{{- if contains $name .Release.Name }} |
| 19 | +{{- .Release.Name | trunc 63 | trimSuffix "-" }} |
| 20 | +{{- else }} |
| 21 | +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} |
| 22 | +{{- end }} |
| 23 | +{{- end }} |
| 24 | +{{- end }} |
| 25 | + |
| 26 | +{{/* |
| 27 | +Create chart name and version as used by the chart label. |
| 28 | +*/}} |
| 29 | +{{- define "cocov-chart.chart" -}} |
| 30 | +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} |
| 31 | +{{- end }} |
| 32 | + |
| 33 | +{{- define "cocov-chart.appVersion" }} |
| 34 | +{{- printf "%s" .Chart.AppVersion }} |
| 35 | +{{- end }} |
| 36 | + |
| 37 | +{{/* |
| 38 | +Common labels |
| 39 | +*/}} |
| 40 | +{{- define "cocov-chart.labels" -}} |
| 41 | +helm.sh/chart: {{ include "cocov-chart.chart" . }} |
| 42 | +{{ include "cocov-chart.selectorLabels" . }} |
| 43 | +{{- if .Chart.AppVersion }} |
| 44 | +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} |
| 45 | +{{- end }} |
| 46 | +app.kubernetes.io/managed-by: {{ .Release.Service }} |
| 47 | +{{- end }} |
| 48 | + |
| 49 | +{{/* |
| 50 | +Selector labels |
| 51 | +*/}} |
| 52 | +{{- define "cocov-chart.selectorLabels" -}} |
| 53 | +app.kubernetes.io/name: {{ include "cocov-chart.name" . }} |
| 54 | +app.kubernetes.io/instance: {{ .Release.Name }} |
| 55 | +{{- end }} |
| 56 | + |
| 57 | +{{/* |
| 58 | +Create the name of the service account to use |
| 59 | +*/}} |
| 60 | +{{- define "cocov-chart.serviceAccountName" -}} |
| 61 | +{{- if .Values.serviceAccount.create }} |
| 62 | +{{- default (include "cocov-chart.fullname" .) .Values.serviceAccount.name }} |
| 63 | +{{- else }} |
| 64 | +{{- default "default" .Values.serviceAccount.name }} |
| 65 | +{{- end }} |
| 66 | +{{- end }} |
| 67 | + |
| 68 | +{{ define "sizeInBytes" -}} |
| 69 | +{{- if hasSuffix "Mi" . }} |
| 70 | + {{- mulf (float64 (trimSuffix "Mi" .)) 1024 1024 }} |
| 71 | +{{- else if hasSuffix "M" (.| quote) }} |
| 72 | + {{- mulf (float64 (trimSuffix "M" .)) 1000 1000 }} |
| 73 | +{{- else if hasSuffix "Gi" (.| quote) }} |
| 74 | + {{- mulf (float64 (trimSuffix "Gi" .)) 1024 1024 1024 }} |
| 75 | +{{- else if hasSuffix "G" (.| quote) }} |
| 76 | + {{- mulf (float64 (trimSuffix "G" .)) 1000 1000 1000 }} |
| 77 | +{{- else if hasSuffix "Ti" (.| quote) }} |
| 78 | + {{- mulf (float64 (trimSuffix "Ti" .)) 1024 1024 1024 1024 }} |
| 79 | +{{- else if hasSuffix "T" (.| quote) }} |
| 80 | + {{- mulf (float64 (trimSuffix "T" .)) 1000 1000 1000 1000 }} |
| 81 | +{{- else }} |
| 82 | + {{- fail "invalid size definition" -}} |
| 83 | +{{- end }} |
| 84 | +{{- end }} |
| 85 | + |
| 86 | +{{ define "dockerHubImage" -}} |
| 87 | +"registry-1.docker.io/cocov/{{ mustFirst .}}:{{ index . 1 }}" |
| 88 | +{{- end }} |
| 89 | + |
| 90 | +{{ define "clusterLocalHost" -}} |
| 91 | +{{ mustFirst . }}.{{ (index . 1).Release.Namespace }}.svc.cluster.local |
| 92 | +{{- end }} |
| 93 | + |
| 94 | +{{ define "apiEnvs" -}} |
| 95 | +- name: COCOV_GITHUB_ORG_NAME |
| 96 | + value: {{ .Values.api.github.orgName | quote }} |
| 97 | +- name: COCOV_GITHUB_APP_ID |
| 98 | + value: {{ .Values.api.github.app.id | quote }} |
| 99 | +- name: COCOV_GITHUB_APP_PRIVATE_KEY |
| 100 | + value: {{ .Values.api.github.app.privateKey | quote }} |
| 101 | +- name: COCOV_GITHUB_APP_INSTALLATION_ID |
| 102 | + value: {{ .Values.api.github.app.installationID | quote }} |
| 103 | +- name: COCOV_GITHUB_WEBHOOK_SECRET_KEY |
| 104 | + value: {{ .Values.api.github.app.webhookSecret | quote }} |
| 105 | +- name: COCOV_GITHUB_OAUTH_CLIENT_ID |
| 106 | + value: {{ .Values.api.github.app.clientID | quote }} |
| 107 | +- name: COCOV_GITHUB_OAUTH_CLIENT_SECRET |
| 108 | + value: {{ .Values.api.github.app.clientSecret | quote }} |
| 109 | +- name: COCOV_DATABASE_USERNAME |
| 110 | + value: {{ .Values.api.db.username | quote }} |
| 111 | +- name: COCOV_DATABASE_PASSWORD |
| 112 | + value: {{ .Values.api.db.password | quote }} |
| 113 | +- name: COCOV_DATABASE_NAME |
| 114 | + value: {{ .Values.api.db.name | quote }} |
| 115 | +- name: COCOV_DATABASE_HOST |
| 116 | + value: {{ .Values.api.db.host | quote }} |
| 117 | +- name: COCOV_DATABASE_PORT |
| 118 | + value: {{ .Values.api.db.port | quote }} |
| 119 | +- name: SECRET_KEY_BASE |
| 120 | + value: {{ .Values.api.secretKeyBase | quote }} |
| 121 | +- name: COCOV_CRYPTOGRAPHIC_KEY |
| 122 | + value: {{ .Values.api.cryptoKey | quote }} |
| 123 | +- name: COCOV_UI_BASE_URL |
| 124 | + value: {{ .Values.ui.externalURL | quote }} |
| 125 | +- name: COCOV_ALLOW_OUTSIDE_COLLABORATORS |
| 126 | + value: {{ .Values.api.github.allowOutsideCollaborators | quote}} |
| 127 | +- name: COCOV_REDIS_URL |
| 128 | + value: {{ .Values.redis.commonURL | quote }} |
| 129 | +- name: COCOV_REDIS_CACHE_URL |
| 130 | + value: {{ .Values.redis.cacheURL | quote }} |
| 131 | +- name: COCOV_SIDEKIQ_REDIS_URL |
| 132 | + value: {{ .Values.redis.sidekiqURL | quote }} |
| 133 | +{{ if and .Values.storage.local.enabled .Values.storage.s3.enabled -}} |
| 134 | +{{ fail "Only a single storage mode must be enabled at a single time. Review configuration for cocov.storage."}} |
| 135 | +{{- end -}} |
| 136 | +{{- if .Values.storage.s3.enabled -}} |
| 137 | +- name: COCOV_GIT_SERVICE_STORAGE_MODE |
| 138 | + value: "s3" |
| 139 | +- name: COCOV_GIT_SERVICE_S3_STORAGE_BUCKET_NAME |
| 140 | + value: {{ .Values.storage.s3.bucketName | quote }} |
| 141 | +{{- else if .Values.storage.local.enabled -}} |
| 142 | +- name: COCOV_GIT_SERVICE_STORAGE_MODE |
| 143 | + value: "local" |
| 144 | +- name: COCOV_GIT_SERVICE_LOCAL_STORAGE_PATH |
| 145 | + value: {{ .Values.storage.local.mountPath | quote }} |
| 146 | +{{- else -}} |
| 147 | + {{ fail "No storage mode is configured. Review configuration for cocov.storage"}} |
| 148 | +{{- end -}} |
| 149 | +{{- if .Values.cache.enabled }} |
| 150 | +- name: COCOV_REPOSITORY_CACHE_MAX_SIZE |
| 151 | + value: {{ (include "sizeInBytes" .Values.cache.repositoryMaxSize) | quote }} |
| 152 | +- name: COCOV_CACHE_SERVICE_URL |
| 153 | + value: {{ include "clusterLocalHost" (list "cocov-cache" .) }} |
| 154 | +{{- end }} |
| 155 | +{{- end }} |
0 commit comments