Skip to content
This repository was archived by the owner on Jan 13, 2026. It is now read-only.

Commit 7f2941e

Browse files
author
Rafa Castelblanque
committed
Added comments from PR
Signed-off-by: Rafa Castelblanque <rcastelblanq@vmware.com>
1 parent 5dbb130 commit 7f2941e

1 file changed

Lines changed: 27 additions & 20 deletions

File tree

script/chart-museum.sh

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,16 @@
33
# Copyright 2022 the Kubeapps contributors.
44
# SPDX-License-Identifier: Apache-2.0
55

6-
CM_PORT=${CM_PORT:-8090}
7-
CM_USER=${CM_USER:-"admin"}
8-
CM_PWD=${CM_PWD:-"password"}
9-
CHART_MUSEUM_NS=${CHART_MUSEUM_NS:-"chart-museum"}
10-
CM_VERSION=${CM_VERSION:-"3.9.0"}
6+
CHARTMUSEUM_PORT=${CHARTMUSEUM_PORT:-8090}
7+
CHARTMUSEUM_USER=${CHARTMUSEUM_USER:-"admin"}
8+
CHARTMUSEUM_PWD=${CHARTMUSEUM_PWD:-"password"}
9+
CHARTMUSEUM_NS=${CHARTMUSEUM_NS:-"chart-museum"}
10+
CHARTMUSEUM_VERSION=${CHARTMUSEUM_VERSION:-"3.9.0"}
1111

1212
# Pull a Bitnami chart to a local TGZ file
13+
# Arguments:
14+
# $1: Chart name
15+
# $2: Chart version
1316
pullBitnamiChart() {
1417
if [ -z "$1" ]; then
1518
echo "No Bitnami chart name supplied"
@@ -32,6 +35,10 @@ pullBitnamiChart() {
3235
}
3336

3437
# Push a local chart to ChartsMuseum
38+
# Arguments:
39+
# $1: Chart name
40+
# $2: Chart version
41+
# $3: Chart file
3542
pushChartToChartMuseum() {
3643
if [ -z "$1" ]; then
3744
echo "No chart name supplied"
@@ -52,45 +59,45 @@ pushChartToChartMuseum() {
5259

5360
echo "Pushing chart ${CHART_NAME} v${CHART_VERSION} to chart museum"
5461

55-
local CM_POD_NAME=$(kubectl get pods --namespace ${CHART_MUSEUM_NS} -l "app.kubernetes.io/name=chartmuseum" -o jsonpath="{.items[0].metadata.name}")
56-
/bin/sh -c "kubectl port-forward $CM_POD_NAME ${CM_PORT}:8080 --namespace ${CHART_MUSEUM_NS} &"
62+
local CHARTMUSEUM_POD_NAME=$(kubectl get pods --namespace ${CHARTMUSEUM_NS} -l "app.kubernetes.io/name=chartmuseum" -o jsonpath="{.items[0].metadata.name}")
63+
/bin/sh -c "kubectl port-forward $CHARTMUSEUM_POD_NAME ${CHARTMUSEUM_PORT}:8080 --namespace ${CHARTMUSEUM_NS} &"
5764
sleep 2
5865

59-
CHART_EXISTS=$(curl -u "${CM_USER}:${CM_PWD}" -X GET http://localhost:${CM_PORT}/api/charts/${CHART_NAME}/${CHART_VERSION} | jq -r 'any([ .error] ; . > 0)')
66+
CHART_EXISTS=$(curl -u "${CHARTMUSEUM_USER}:${CHARTMUSEUM_PWD}" -X GET http://localhost:${CHARTMUSEUM_PORT}/api/charts/${CHART_NAME}/${CHART_VERSION} | jq -r 'any([ .error] ; . > 0)')
6067
if [ "$CHART_EXISTS" == "true" ]; then
6168
echo ">> CHART EXISTS: deleting"
62-
curl -u "${CM_USER}:${CM_PWD}" -X DELETE http://localhost:${CM_PORT}/api/charts/${CHART_NAME}/${CHART_VERSION}
69+
curl -u "${CHARTMUSEUM_USER}:${CHARTMUSEUM_PWD}" -X DELETE http://localhost:${CHARTMUSEUM_PORT}/api/charts/${CHART_NAME}/${CHART_VERSION}
6370
fi
6471

6572
echo ">> Uploading chart from file ${CHART_FILE}"
66-
curl -u "${CM_USER}:${CM_PWD}" --data-binary "@${CHART_FILE}" http://localhost:${CM_PORT}/api/charts
73+
curl -u "${CHARTMUSEUM_USER}:${CHARTMUSEUM_PWD}" --data-binary "@${CHART_FILE}" http://localhost:${CHARTMUSEUM_PORT}/api/charts
6774

6875
# End port forward
69-
pkill -f "kubectl port-forward $CM_POD_NAME ${CM_PORT}:8080 --namespace ${CHART_MUSEUM_NS}"
76+
pkill -f "kubectl port-forward $CHARTMUSEUM_POD_NAME ${CHARTMUSEUM_PORT}:8080 --namespace ${CHARTMUSEUM_NS}"
7077

7178
rm ${CHART_FILE}
7279
}
7380

7481
# Install ChartsMuseum
7582
installChartMuseum() {
76-
echo "Installing ChartMuseum ${CM_VERSION}..."
77-
helm install chartmuseum --namespace ${CHART_MUSEUM_NS} --create-namespace "https://github.com/chartmuseum/charts/releases/download/chartmuseum-${CM_VERSION}/chartmuseum-${CM_VERSION}.tgz" \
83+
echo "Installing ChartMuseum ${CHARTMUSEUM_VERSION}..."
84+
helm install chartmuseum --namespace ${CHARTMUSEUM_NS} --create-namespace "https://github.com/chartmuseum/charts/releases/download/chartmuseum-${CHARTMUSEUM_VERSION}/chartmuseum-${CHARTMUSEUM_VERSION}.tgz" \
7885
--set env.open.DISABLE_API=false \
7986
--set persistence.enabled=true \
80-
--set env.secret.BASIC_AUTH_USER=$CM_USER \
81-
--set env.secret.BASIC_AUTH_PASS=$CM_PWD
82-
kubectl rollout status -w deployment/chartmuseum --namespace=${CHART_MUSEUM_NS}
87+
--set env.secret.BASIC_AUTH_USER=$CHARTMUSEUM_USER \
88+
--set env.secret.BASIC_AUTH_PASS=$CHARTMUSEUM_PWD
89+
kubectl rollout status -w deployment/chartmuseum --namespace=${CHARTMUSEUM_NS}
8390

84-
echo "Chart museum v${CM_VERSION} installed in namespace ${CHART_MUSEUM_NS}"
85-
echo "Credentials: ${CM_USER} / ${CM_PWD}"
91+
echo "Chart museum v${CHARTMUSEUM_VERSION} installed in namespace ${CHARTMUSEUM_NS}"
92+
echo "Credentials: ${CHARTMUSEUM_USER} / ${CHARTMUSEUM_PWD}"
8693
echo "Cluster internal URL: "
87-
echo " http://chartmuseum.${CHART_MUSEUM_NS}.svc.cluster.local:8080/"
94+
echo " http://chartmuseum.${CHARTMUSEUM_NS}.svc.cluster.local:8080/"
8895
}
8996

9097
# Uninstall ChartsMuseum
9198
uninstallChartMuseum() {
9299
echo "Uninstalling ChartMuseum..."
93-
helm uninstall chartmuseum --namespace ${CHART_MUSEUM_NS}
100+
helm uninstall chartmuseum --namespace ${CHARTMUSEUM_NS}
94101
}
95102

96103
case $1 in

0 commit comments

Comments
 (0)