#!/bin/bash
FUYAO_REPO="https://helm.openfuyao.cn/_core"
FUYAO_ADDON_REPO="https://helm.openfuyao.cn"
OPENFUYAO_CHART_VERSION="0.0.0-latest"
OPENFUYAO_ADDON_CHART_VERSION="0.0.0-latest"
LOCAL_HARBOR_CHART_VERSION="1.11.4"
OAUTH_WEBHOOK_CHART_VERSION="$OPENFUYAO_CHART_VERSION"
OAUTH_SERVER_CHART_VERSION="$OPENFUYAO_CHART_VERSION"
CONSOLE_WEBSITE_CHART_VERSION="$OPENFUYAO_CHART_VERSION"
MONITORING_SERVICE_CHART_VERSION="$OPENFUYAO_CHART_VERSION"
CONSOLE_SERVICE_CHART_VERSION="$OPENFUYAO_CHART_VERSION"
MARKETPLACE_SERVICE_CHART_VERSION="$OPENFUYAO_CHART_VERSION"
APPLICATION_MANAGEMENT_SERVICE_CHART_VERSION="$OPENFUYAO_CHART_VERSION"
PLUGIN_MANAGEMENT_SERVICE_CHART_VERSION="$OPENFUYAO_CHART_VERSION"
USER_MANAGEMENT_OPERATOR_CHART_VERSION="$OPENFUYAO_CHART_VERSION"
LOCAL_HARBOR_CHART_VERSION="$LOCAL_HARBOR_CHART_VERSION"
WEB_TERMINAL_SERVICE_CHART_VERSION="$OPENFUYAO_CHART_VERSION"
INSTALLER_SERVICE_CHART_VERSION="$OPENFUYAO_CHART_VERSION"
INSTALLER_WEBSITE_CHART_VERSION="$OPENFUYAO_CHART_VERSION"
VOLCANO_CONFIG_SERVICE_CHART_VERSION="$OPENFUYAO_ADDON_CHART_VERSION"
RAY_PACKAGE_CHART_VERSION="$OPENFUYAO_ADDON_CHART_VERSION"
COLOCATION_PACKAGE_CHART_VERSION="$OPENFUYAO_ADDON_CHART_VERSION"
NPU_OPERATOR_CHART_VERSION="$OPENFUYAO_ADDON_CHART_VERSION"
LOGGING_PACKAGE_CHART_VERSION="$OPENFUYAO_ADDON_CHART_VERSION"
MULTI_CLUSTER_SERVICE_CHART_VERSION="$OPENFUYAO_ADDON_CHART_VERSION"
MONITORING_DASHBOARD_CHART_VERSION="$OPENFUYAO_ADDON_CHART_VERSION"
OAUTH_WEBHOOK_CHART_NAME="oauth-webhook"
OAUTH_SERVER_CHART_NAME="oauth-server"
CONSOLE_WEBSITE_CHART_NAME="console-website"
MONITORING_SERVICE_CHART_NAME="monitoring-service"
CONSOLE_SERVICE_CHART_NAME="console-service"
MARKETPLACE_SERVICE_CHART_NAME="marketplace-service"
APPLICATION_MANAGEMENT_SERVICE_CHART_NAME="application-management-service"
PLUGIN_MANAGEMENT_SERVICE_CHART_NAME="plugin-management-service"
USER_MANAGEMENT_OPERATOR_CHART_NAME="user-management-operator"
HARBOR_CHART_NAME="harbor"
WEB_TERMINAL_SERVICE_CHART_NAME="web-terminal-service"
INSTALLER_SERVICE_CHART_NAME="installer-service"
INSTALLER_WEBSITE_CHART_NAME="installer-website"
VOLCANO_CONFIG_SERVICE_CHART_NAME="volcano-config-service"
RAY_PACKAGE_CHART_NAME="ray-package"
COLOCATION_PACKAGE_CHART_NAME="colocation-package"
NPU_OPERATOR_CHART_NAME="npu-operator"
LOGGING_PACKAGE_CHART_NAME="logging-package"
MULTI_CLUSTER_SERVICE_CHART_NAME="multi-cluster-service"
MONITORING_DASHBOARD_CHART_NAME="monitoring-dashboard"
declare -A chart_map
chart_map["${OAUTH_WEBHOOK_CHART_NAME}"]="${OAUTH_WEBHOOK_CHART_VERSION}"
chart_map["${OAUTH_SERVER_CHART_NAME}"]="${OAUTH_SERVER_CHART_VERSION}"
chart_map["${HARBOR_CHART_NAME}"]="${LOCAL_HARBOR_CHART_VERSION}"
chart_map["${CONSOLE_WEBSITE_CHART_NAME}"]="${CONSOLE_WEBSITE_CHART_VERSION}"
chart_map["${MONITORING_SERVICE_CHART_NAME}"]="${MONITORING_SERVICE_CHART_VERSION}"
chart_map["${CONSOLE_SERVICE_CHART_NAME}"]="${CONSOLE_SERVICE_CHART_VERSION}"
chart_map["${MARKETPLACE_SERVICE_CHART_NAME}"]="${MARKETPLACE_SERVICE_CHART_VERSION}"
chart_map["${APPLICATION_MANAGEMENT_SERVICE_CHART_NAME}"]="${APPLICATION_MANAGEMENT_SERVICE_CHART_VERSION}"
chart_map["${PLUGIN_MANAGEMENT_SERVICE_CHART_NAME}"]="${PLUGIN_MANAGEMENT_SERVICE_CHART_VERSION}"
chart_map["${USER_MANAGEMENT_OPERATOR_CHART_NAME}"]="${USER_MANAGEMENT_OPERATOR_CHART_VERSION}"
chart_map["${WEB_TERMINAL_SERVICE_CHART_NAME}"]="${WEB_TERMINAL_SERVICE_CHART_VERSION}"
chart_map["${INSTALLER_SERVICE_CHART_NAME}"]="${INSTALLER_SERVICE_CHART_VERSION}"
chart_map["${INSTALLER_WEBSITE_CHART_NAME}"]="${INSTALLER_WEBSITE_CHART_VERSION}"
declare -A addon_chart_map
addon_chart_map["${VOLCANO_CONFIG_SERVICE_CHART_NAME}"]="${VOLCANO_CONFIG_SERVICE_CHART_VERSION}"
addon_chart_map["${RAY_PACKAGE_CHART_NAME}"]="${RAY_PACKAGE_CHART_VERSION}"
addon_chart_map["${COLOCATION_PACKAGE_CHART_NAME}"]="${COLOCATION_PACKAGE_CHART_VERSION}"
addon_chart_map["${NPU_OPERATOR_CHART_NAME}"]="${NPU_OPERATOR_CHART_VERSION}"
addon_chart_map["${LOGGING_PACKAGE_CHART_NAME}"]="${LOGGING_PACKAGE_CHART_VERSION}"
addon_chart_map["${MULTI_CLUSTER_SERVICE_CHART_NAME}"]="${MULTI_CLUSTER_SERVICE_CHART_VERSION}"
addon_chart_map["${MONITORING_DASHBOARD_CHART_NAME}"]="${MONITORING_DASHBOARD_CHART_VERSION}"
for chart_name in "${!chart_map[@]}"; do
echo "Start downloading chart ${chart_name}:${chart_map[$chart_name]}"
attempts=0
while [ $attempts -lt 3 ]; do
helm fetch ${chart_name} --repo ${FUYAO_REPO} --version "${chart_map[$chart_name]}"
if [ $? -eq 0 ]; then
break
else
((attempts++))
sleep 2
fi
done
if [ $attempts -eq 3 ]; then
echo "Failed to download $chart_name after 3 attempts."
exit 1
fi
chart_file="${chart_name}-${chart_map[$chart_name]}.tgz"
if [ -f "$chart_file" ]; then
echo "Chart $chart_file saved to $chart_file successfully."
else
echo "Failed to save chart $chart_file to $chart_file."
exit 1
fi
done
for chart_name in "${!addon_chart_map[@]}"; do
echo "Start downloading chart ${chart_name}:${addon_chart_map[$chart_name]}"
attempts=0
while [ $attempts -lt 3 ]; do
helm fetch ${chart_name} --repo ${FUYAO_ADDON_REPO} --version "${addon_chart_map[$chart_name]}"
if [ $? -eq 0 ]; then
break
else
((attempts++))
sleep 2
fi
done
if [ $attempts -eq 3 ]; then
echo "Failed to download $addon_chart_name after 3 attempts."
exit 1
fi
chart_file="${chart_name}-${addon_chart_map[$chart_name]}.tgz"
if [ -f "${chart_file}" ]; then
temp_dir=$(mktemp -d)
echo "temp ${temp_dir}"
tar -xzf "${chart_file}" -C "${temp_dir}" || {
rm -rf "${temp_dir}"
exit 1
}
rm -f "${chart_file}"
find "${temp_dir}" -iname "values.yaml" | xargs sed -i 's/cr.openfuyao.cn\/openfuyao/deploy.bocloud.k8s:40443\/kubernetes/g'
find "${temp_dir}" -iname "values.yaml" | xargs sed -i 's/cr.openfuyao.cn\/docker.io/deploy.bocloud.k8s:40443\/kubernetes/g'
pkg="${temp_dir}"/"${chart_name}"
helm package "${pkg}"
rm -rf ${temp_dir}
echo "Chart $chart_file saved to $chart_file successfully."
else
echo "Failed to save chart $chart_file to $chart_file."
exit 1
fi
done