Skip to content

Commit

Permalink
feat(common/helm): add support for git helmRepositories
Browse files Browse the repository at this point in the history
  • Loading branch information
cwrau committed May 13, 2024
1 parent 8501fd4 commit 9b734e4
Showing 1 changed file with 24 additions and 10 deletions.
34 changes: 24 additions & 10 deletions charts/common/templates/_helm.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,29 @@ Returns a HelmRelease.spec.chart.spec for a given chart in a given repository.
*/}}
{{- define "common.helm.chartSpec" -}}
{{- $_ := set . "Release" .context.Release -}}
{{- dict
"chart" .chart
"version" (include "common.helm.chartVersion" (dict "repo" .repo "chart" .chart "context" .context))
"sourceRef" (dict
"kind" "HelmRepository"
"name" (eq .prependReleaseName true | ternary (printf "%s-%s" .Release.Name .repo) .repo)
"namespace" .Release.Namespace
)
| toYaml
-}}
{{- $_ = set . "Values" .context.Values -}}
{{- $spec := dict -}}
{{- if eq (dig .repo "type" "helm" .Values.global.helmRepositories) "helm" -}}
{{- $spec = merge (dict
"chart" .chart
"sourceRef" (dict
"kind" "HelmRepository"
"name" (eq .prependReleaseName true | ternary (printf "%s-%s" .Release.Name .repo) .repo)
"namespace" .Release.Namespace)
"version" (include "common.helm.chartVersion" (dict "repo" .repo "chart" .chart "context" .context))
) $spec
-}}
{{- else -}}
{{- $spec = merge (dict
"chart" (dig .repo "charts" .chart "path" (printf "charts/%s" .chart) .Values.global.helmRepositories)
"sourceRef" (dict
"kind" "GitRepository"
"name" (eq .prependReleaseName true | ternary (printf "%s-%s-%s" .Release.Name .repo .chart) (printf "%s-%s" .repo .chart))
"namespace" .Release.Namespace)
"reconcileStrategy" (.reconcileStrategy | default "Revision")
) $spec
-}}
{{- end -}}
{{- $spec | toYaml -}}
{{- end -}}

0 comments on commit 9b734e4

Please sign in to comment.