volcano.sh/volcano@v1.9.0/hack/generate-charts.sh (about)

     1  #!/bin/bash
     2  
     3  #
     4  # Copyright 2023 The Volcano Authors.
     5  #
     6  # Licensed under the Apache License, Version 2.0 (the "License");
     7  # you may not use this file except in compliance with the License.
     8  # You may obtain a copy of the License at
     9  #
    10  #     http://www.apache.org/licenses/LICENSE-2.0
    11  #
    12  # Unless required by applicable law or agreed to in writing, software
    13  # distributed under the License is distributed on an "AS IS" BASIS,
    14  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    15  # See the License for the specific language governing permissions and
    16  # limitations under the License.
    17  #
    18  
    19  set -o errexit
    20  set -o nounset
    21  set -o pipefail
    22  
    23  VK_ROOT=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/..
    24  export HELM_BIN_DIR=${VK_ROOT}/${BIN_DIR}
    25  export RELEASE_FOLDER=${VK_ROOT}/${RELEASE_DIR}
    26  
    27  export HELM_VER=${HELM_VER:-v3.6.3}
    28  export VOLCANO_CHART_VERSION=${TAG:-"latest"}
    29  export VOLCANO_IMAGE_TAG=${VOLCANO_CHART_VERSION}
    30  
    31  LOCAL_OS=${OSTYPE}
    32  case $LOCAL_OS in
    33    "linux"*)
    34      LOCAL_OS='linux'
    35      alias sed_i='sed -i'
    36      ;;
    37    "darwin"*)
    38      LOCAL_OS='darwin'
    39      alias sed_i='sed -i ""'
    40      ;;
    41    *)
    42      echo "This system's OS ${LOCAL_OS} isn't recognized/supported"
    43      exit 1
    44      ;;
    45  esac
    46  
    47  # Enable the alias function in the Shell
    48  shopt -s  expand_aliases 
    49  ARCH=$(go env GOARCH)
    50  
    51  # Step1. install helm binary
    52  if [[ ! -f "${HELM_BIN_DIR}/version.helm.${HELM_VER}" ]] || [[ ! -f "${HELM_BIN_DIR}/helm" ]] ; then
    53      TD=$(mktemp -d)
    54      cd "${TD}" && \
    55          curl -Lo "${TD}/helm.tgz" "https://get.helm.sh/helm-${HELM_VER}-${LOCAL_OS}-${ARCH}.tar.gz" && \
    56          tar xfz helm.tgz && \
    57          mv ${LOCAL_OS}-${ARCH}/helm "${HELM_BIN_DIR}/helm-${HELM_VER}" && \
    58          cp "${HELM_BIN_DIR}/helm-${HELM_VER}" "${HELM_BIN_DIR}/helm" && \
    59          chmod +x ${HELM_BIN_DIR}/helm
    60          rm -rf "${TD}"
    61  
    62          if [[ ! -f "${HELM_BIN_DIR}/version.helm.${HELM_VER}" ]] ; then
    63            touch "${HELM_BIN_DIR}/version.helm.${HELM_VER}"
    64          fi
    65  fi
    66  
    67  echo "generate chart"
    68  CHART_ORIGIN_PATH=${VK_ROOT}/installer/helm/chart
    69  CHART_OUT_PATH=${RELEASE_FOLDER}/chart
    70  rm -rf ${RELEASE_FOLDER}/chart
    71  cp -r "${CHART_ORIGIN_PATH}" "${CHART_OUT_PATH}"
    72  sed_i "s|image_tag_version: \"latest\"|image_tag_version: \"${VOLCANO_IMAGE_TAG}\"|g" $(find ${CHART_OUT_PATH} -type f | grep values.yaml)
    73  sed_i "s|version: 1.5|version: ${VOLCANO_CHART_VERSION}|g" $(find ${CHART_OUT_PATH} -type f | grep Chart.yaml)
    74  sed_i "s|appVersion: 0.1|appVersion: ${VOLCANO_CHART_VERSION}|g" $(find ${CHART_OUT_PATH} -type f | grep Chart.yaml)
    75  helm package "${CHART_OUT_PATH}/volcano" -d "${CHART_OUT_PATH}"
    76  echo "helm package end, charts is in ${CHART_OUT_PATH}"