|
| 1 | +#!/bin/bash |
1 | 2 | # install a helm chart with the correct global.clusterRouterBase |
2 | 3 |
|
3 | 4 | # default namespace if none set |
4 | 5 | namespace="rhdh-helm" |
5 | | -chartrepo=0 # by default don't create a new chart repo unless the version chart version includes "CI" suffix |
6 | | -github=0 # by default don't use the Github repo unless the chart doesn't exist in the OCI registry |
| 6 | +# chartrepo=0 # by default don't create a new chart repo unless the version chart version includes "CI" suffix |
7 | 7 |
|
8 | 8 | usage () |
9 | 9 | { |
10 | 10 | echo "Usage: $0 CHART_VERSION [-n namespace] |
11 | 11 |
|
12 | 12 | Examples: |
13 | | - $0 1.1.1 |
| 13 | + $0 1.5.1 |
14 | 14 | $0 1.7-20-CI -n rhdh-ci |
15 | 15 |
|
16 | 16 | Options: |
17 | 17 | -n, --namespace Project or namespace into which to install specified chart; default: $namespace |
18 | 18 | --github-repo If set will use the deprecated github repository to install the helm chart instead of the OCI registry. |
19 | | - --chartrepo If set, a Helm Chart Repo will be applied to the cluster, based on the chart version. |
20 | | - If CHART_VERSION ends in CI and --github-repo is set, this is done by default. |
21 | 19 | --router If set, the cluster router base is manually set. |
22 | 20 | Required for non-admin users |
23 | 21 | Redundant for admin users |
24 | 22 | " |
25 | | - exit |
| 23 | + # --chartrepo If set, a Helm Chart Repo will be applied to the cluster, based on the chart version. |
| 24 | + # If CHART_VERSION ends in CI, this is done by default. |
26 | 25 | } |
27 | 26 |
|
28 | | -if [[ $# -lt 1 ]]; then usage; fi |
| 27 | +if [[ $# -lt 1 ]]; then usage; exit 0; fi |
29 | 28 |
|
30 | 29 | while [[ "$#" -gt 0 ]]; do |
31 | 30 | case $1 in |
32 | | - '--chartrepo') chartrepo=1;; |
| 31 | + # '--chartrepo') chartrepo=1;; |
33 | 32 | '-n'|'--namespace') namespace="$2"; shift 1;; |
34 | | - '-h') usage;; |
35 | | - '--github-repo') github=1;; |
| 33 | + '-h') usage; exit 0;; |
36 | 34 | '--router') CLUSTER_ROUTER_BASE="$2"; shift 1;; |
37 | 35 | *) CV="$1";; |
38 | 36 | esac |
39 | 37 | shift 1 |
40 | 38 | done |
41 | 39 |
|
42 | | -if [[ ! "$CV" ]]; then usage; fi |
| 40 | +if [[ ! "$CV" ]]; then usage; exit 1; fi |
43 | 41 |
|
44 | 42 | CHART_URL="oci://quay.io/rhdh/chart" |
45 | 43 |
|
46 | | -if ! helm show chart $CHART_URL --version "$CV" &> /dev/null; then github=1; fi |
47 | | -if [[ $github -eq 1 ]]; then |
48 | | - # If a Github CI chart, create a chart repo |
49 | | - if [[ "$CV" == *"-CI" ]]; then chartrepo=1; fi |
50 | | - CHART_URL="https://github.com/rhdh-bot/openshift-helm-charts/raw/redhat-developer-hub-${CV}/charts/redhat/redhat/redhat-developer-hub/${CV}/redhat-developer-hub-${CV}.tgz" |
51 | | -fi |
| 44 | +if ! helm show chart $CHART_URL --version "$CV" &> /dev/null; then |
| 45 | + echo "Error: could not load chart $CV from $CHART_URL !" |
| 46 | + echo |
| 47 | + usage |
| 48 | + exit 1 |
| 49 | + fi |
52 | 50 |
|
53 | 51 | echo "Using ${CHART_URL} to install Helm chart" |
54 | 52 |
|
55 | 53 | # choose namespace for the install (or create if non-existant) |
56 | 54 | oc new-project "$namespace" || oc project "$namespace" |
57 | 55 |
|
58 | | -if [[ $chartrepo -eq 1 ]]; then |
59 | | - oc apply -f https://github.com/rhdh-bot/openshift-helm-charts/raw/redhat-developer-hub-"${CV}"/installation/rhdh-next-ci-repo.yaml |
60 | | -fi |
| 56 | +# TODO: RHIDP-6668 generate rhdh-next-ci-repo.yaml while installing so we don't have to publish a new file every time |
| 57 | +# TODO: RHIDP-6668 publish an index.yaml with every tarball pushed to quay.io/rhdh/chart; save them in rhdh-chart repo (one per CI versioned branch) |
| 58 | +# if [[ "$CV" == *"-CI" ]] || [[ $chartrepo -eq 1 ]]; then |
| 59 | +# see samples at |
| 60 | +# https://github.com/rhdh-bot/openshift-helm-charts/blob/rhdh-1-rhel-9/installation/index.yaml#L19 |
| 61 | +# https://github.com/rhdh-bot/openshift-helm-charts/blob/rhdh-1-rhel-9/installation/index.yaml#L49-L50 |
| 62 | +# https://github.com/rhdh-bot/openshift-helm-charts/blob/rhdh-1-rhel-9/installation/rhdh-next-ci-repo.yaml#L8 |
| 63 | +# oc apply -f https://github.com/redhat-developer/rhdh-chart/raw/redhat-developer-hub-"${CV}"/installation/rhdh-next-ci-repo.yaml |
| 64 | +# fi |
61 | 65 |
|
62 | 66 | # 1. install (or upgrade) |
63 | 67 | helm upgrade redhat-developer-hub -i "${CHART_URL}" --version "$CV" |
|
0 commit comments