this repo has no description
1#!/usr/bin/env bash
2
3set -o errexit
4set -o nounset
5set -o pipefail
6shopt -s lastpipe
7
8check() {
9 command -v "${1}" >/dev/null 2>&1 || {
10 echo >&2 "ERROR: ${1} is not installed or not found in \$PATH" >&2
11 exit 1
12 }
13}
14
15chart_registry_url() {
16 local helm_release=
17 local chart_id=
18 helm_release="${1}"
19 chart_id=$(yq eval .spec.chart.spec.sourceRef.name "${helm_release}" 2>/dev/null)
20 # Discover all HelmRepository
21 find . -iname '*-charts.yaml' -type f -print0 | while IFS= read -r -d '' file; do
22 # Skip non HelmRepository
23 [[ $(yq eval .kind "${file}" 2>/dev/null) != "HelmRepository" ]] && continue
24 # Skip unrelated HelmRepository
25 [[ "${chart_id}" != $(yq eval .metadata.name "${file}" 2>/dev/null) ]] && continue
26 yq eval .spec.url "${file}"
27 break
28 done
29}
30
31chart_name() {
32 local helm_release=
33 helm_release="${1}"
34 yq eval .spec.chart.spec.chart "${helm_release}" 2>/dev/null
35}
36
37chart_version() {
38 local helm_release=
39 helm_release="${1}"
40 yq eval .spec.chart.spec.version "${helm_release}" 2>/dev/null
41}
42
43chart_values() {
44 local helm_release=
45 helm_release="${1}"
46 yq eval .spec.values "${helm_release}" 2>/dev/null
47}