From 59bbc8d87ff9407a0b271fac3e9750ce624c595d Mon Sep 17 00:00:00 2001 From: "sp.qiang.song" Date: Tue, 23 Jun 2026 17:50:00 +0800 Subject: [PATCH 01/15] add ci config --- .github/workflows/ci.yml | 81 +++++++++++++++++++++++++++++++ .pipeline/build.sh | 101 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 182 insertions(+) create mode 100644 .github/workflows/ci.yml create mode 100755 .pipeline/build.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..dbea813 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,81 @@ +name: CI Pipeline + +on: + pull_request: + branches: + - main + push: + branches: + - main + +env: + SA_IMAGE: registry-egc.enflame-tech.com/enflame/ci_sast:v1.0-os + CI_IMAGE: registry-egc.enflame-tech.com/artifacts/torch_gcu:v2.10.0-TR3.7.107-ubuntu2204 + SAST_REPO: EnflameTechnology/sast + SAST_BRANCH: main + +jobs: + all-ci-check: + runs-on: S60 + + steps: + - name: Setup SSH Agent + uses: webfactory/ssh-agent@v0.9.0 + with: + ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} + + - name: Checkout SAST tools + uses: actions/checkout@v4 + with: + repository: ${{env.SAST_REPO}} + ref: ${{env.SAST_BRANCH}} + path: ./sast + ssh-key: ${{ secrets.SSH_PUB_KEY }} + + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 # Required for full git history to compare changes + path: ./gcushare + ssh-key: ${{ secrets.SSH_PUB_KEY }} + + - name: Run static code analysis + run: | + sudo docker run --rm \ + -v "$(pwd)/gcushare:/app" \ + -v "$(pwd)/sast:/sast" \ + -u "$(id -u):$(id -g)" \ + -w /app \ + "${{ env.SA_IMAGE }}" \ + bash -c 'cd /app && python3 /sast/run.py --all_ci_check' + + - name: Install Driver + run: | + sudo ./gcushare/test/install_driver.sh + + - name: Run CI Build + run: | + sudo docker run --rm \ + -v "$(pwd):/app" \ + --volume=/log:/log \ + --volume=/root:/root \ + --volume=/lib/modules/:/lib/modules/ \ + --volume=/usr/src/:/usr/src/ \ + --volume=/dev:/dev \ + --privileged \ + -v /home/pypi_packages:/home/pypi_packages \ + -w /app \ + "${{ env.CI_IMAGE }}" \ + bash -c 'sudo git config --global --add safe.directory /app/gcushare;sudo ./gcushare/.pipeline/build.sh ci_build' + + - name: Upload wheel artifact + uses: actions/upload-artifact@v4 + with: + name: gcushare-wheel + path: ./gcushare/dist/*.whl + if-no-files-found: error + + - name: Clean up + if: always() + run: | + sudo rm -rf gcushare sast \ No newline at end of file diff --git a/.pipeline/build.sh b/.pipeline/build.sh new file mode 100755 index 0000000..d7b6557 --- /dev/null +++ b/.pipeline/build.sh @@ -0,0 +1,101 @@ +#!/bin/bash +# +# Copyright 2024 Enflame. All Rights Reserved. +# + +if [ -f "../../g_version.txt" ]; then + source ../../g_version.txt +fi +PKG_VER=${GCUSHARE_VERSION:-"0.0.0"} + +function usage() { + cat <&2; exit 1; } + + case $1 in + "clean") + clean_all;; + "all") + build_all;; + *) + usage + exit 1;; + esac +} + +main "$@" From 22d5dcbac0a5b340a44ffe73aeb4c3e7353068e9 Mon Sep 17 00:00:00 2001 From: "sp.qiang.song" Date: Tue, 23 Jun 2026 18:22:20 +0800 Subject: [PATCH 02/15] modify ci.yaml --- .github/workflows/ci.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dbea813..ee92b4e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -49,10 +49,6 @@ jobs: "${{ env.SA_IMAGE }}" \ bash -c 'cd /app && python3 /sast/run.py --all_ci_check' - - name: Install Driver - run: | - sudo ./gcushare/test/install_driver.sh - - name: Run CI Build run: | sudo docker run --rm \ From 2230277d446e12fdb9b7e2960b07170c040e967c Mon Sep 17 00:00:00 2001 From: "sp.qiang.song" Date: Tue, 23 Jun 2026 18:46:48 +0800 Subject: [PATCH 03/15] update build.sh --- .pipeline/build.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.pipeline/build.sh b/.pipeline/build.sh index d7b6557..8de3e47 100755 --- a/.pipeline/build.sh +++ b/.pipeline/build.sh @@ -92,6 +92,8 @@ function main() { clean_all;; "all") build_all;; + "ci_build") + ci_build;; *) usage exit 1;; From 904c7f1e9f22092c34b679b7975b55f80220b0c8 Mon Sep 17 00:00:00 2001 From: "sp.qiang.song" Date: Tue, 23 Jun 2026 19:06:12 +0800 Subject: [PATCH 04/15] update build.sh --- .github/workflows/ci.yml | 2 +- .pipeline/build.sh | 28 +--------------------------- 2 files changed, 2 insertions(+), 28 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ee92b4e..54066b2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -62,7 +62,7 @@ jobs: -v /home/pypi_packages:/home/pypi_packages \ -w /app \ "${{ env.CI_IMAGE }}" \ - bash -c 'sudo git config --global --add safe.directory /app/gcushare;sudo ./gcushare/.pipeline/build.sh ci_build' + bash -c 'sudo git config --global --add safe.directory /app/gcushare;sudo ./gcushare/.pipeline/build.sh build_all' - name: Upload wheel artifact uses: actions/upload-artifact@v4 diff --git a/.pipeline/build.sh b/.pipeline/build.sh index 8de3e47..8173b90 100755 --- a/.pipeline/build.sh +++ b/.pipeline/build.sh @@ -1,3 +1,4 @@ + #!/bin/bash # # Copyright 2024 Enflame. All Rights Reserved. @@ -20,31 +21,6 @@ Example: EOF } -function ci_build() { - # clean old dist if exist - if [ -d "./dist" ]; then - clean_all - fi - echo -e "\033[33mBuilding gcushare package start...\033[0m" - - PKG_DIR="dist/gcushare_$PKG_VER" - mkdir -p $PKG_DIR - - cd gcushare-device-plugin - ./build.sh all - cp -rf dist/* ../$PKG_DIR/ - rm -rf dist - cd - - - cd gcushare-scheduler-plugin - ./build.sh all - cp -rf dist/* ../$PKG_DIR/ - rm -rf dist - cd - - - echo -e "\033[33mBuilding gcushare package successfully!\033[0m" -} - function build_all() { # clean old dist if exist if [ -d "./dist" ]; then @@ -92,8 +68,6 @@ function main() { clean_all;; "all") build_all;; - "ci_build") - ci_build;; *) usage exit 1;; From eb93eb958b212da361aa2eea72e34395414830df Mon Sep 17 00:00:00 2001 From: "sp.qiang.song" Date: Tue, 23 Jun 2026 19:15:57 +0800 Subject: [PATCH 05/15] bash fix --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 54066b2..2d84276 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -62,7 +62,7 @@ jobs: -v /home/pypi_packages:/home/pypi_packages \ -w /app \ "${{ env.CI_IMAGE }}" \ - bash -c 'sudo git config --global --add safe.directory /app/gcushare;sudo ./gcushare/.pipeline/build.sh build_all' + bash -c 'sudo git config --global --add safe.directory /app/gcushare;sudo bash ./gcushare/.pipeline/build.sh build_all' - name: Upload wheel artifact uses: actions/upload-artifact@v4 From e6c65a0fa6f58053e76b7215ec4f4c3c5328df05 Mon Sep 17 00:00:00 2001 From: "sp.qiang.song" Date: Tue, 23 Jun 2026 19:17:46 +0800 Subject: [PATCH 06/15] fix build.sh all --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2d84276..60693de 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -62,7 +62,7 @@ jobs: -v /home/pypi_packages:/home/pypi_packages \ -w /app \ "${{ env.CI_IMAGE }}" \ - bash -c 'sudo git config --global --add safe.directory /app/gcushare;sudo bash ./gcushare/.pipeline/build.sh build_all' + bash -c 'sudo git config --global --add safe.directory /app/gcushare;sudo bash ./gcushare/.pipeline/build.sh all' - name: Upload wheel artifact uses: actions/upload-artifact@v4 From 8116a0e064549d7344ad0eae02faedd29a9c6048 Mon Sep 17 00:00:00 2001 From: "sp.qiang.song" Date: Tue, 23 Jun 2026 19:21:58 +0800 Subject: [PATCH 07/15] update ci.yml --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 60693de..e39c9e5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -62,7 +62,7 @@ jobs: -v /home/pypi_packages:/home/pypi_packages \ -w /app \ "${{ env.CI_IMAGE }}" \ - bash -c 'sudo git config --global --add safe.directory /app/gcushare;sudo bash ./gcushare/.pipeline/build.sh all' + bash -c 'sudo git config --global --add safe.directory /app/gcushare;cd /app && sudo bash ./gcushare/.pipeline/build.sh all' - name: Upload wheel artifact uses: actions/upload-artifact@v4 From 66c87b1ccbf75c9cd3fadf140f655a6e3b9feef6 Mon Sep 17 00:00:00 2001 From: "sp.qiang.song" Date: Tue, 23 Jun 2026 19:27:08 +0800 Subject: [PATCH 08/15] update ci.yml --- .github/workflows/ci.yml | 2 +- .pipeline/build.sh | 77 ---------------------------------------- 2 files changed, 1 insertion(+), 78 deletions(-) delete mode 100755 .pipeline/build.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e39c9e5..aa79c8e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -62,7 +62,7 @@ jobs: -v /home/pypi_packages:/home/pypi_packages \ -w /app \ "${{ env.CI_IMAGE }}" \ - bash -c 'sudo git config --global --add safe.directory /app/gcushare;cd /app && sudo bash ./gcushare/.pipeline/build.sh all' + bash -c 'sudo git config --global --add safe.directory /app/gcushare;cd /app/gcushare && sudo bash ./build.sh all' - name: Upload wheel artifact uses: actions/upload-artifact@v4 diff --git a/.pipeline/build.sh b/.pipeline/build.sh deleted file mode 100755 index 8173b90..0000000 --- a/.pipeline/build.sh +++ /dev/null @@ -1,77 +0,0 @@ - -#!/bin/bash -# -# Copyright 2024 Enflame. All Rights Reserved. -# - -if [ -f "../../g_version.txt" ]; then - source ../../g_version.txt -fi -PKG_VER=${GCUSHARE_VERSION:-"0.0.0"} - -function usage() { - cat <&2; exit 1; } - - case $1 in - "clean") - clean_all;; - "all") - build_all;; - *) - usage - exit 1;; - esac -} - -main "$@" From ab70f10341d4f704f92fc790a774a605d3af47e2 Mon Sep 17 00:00:00 2001 From: "sp.qiang.song" Date: Tue, 23 Jun 2026 19:30:38 +0800 Subject: [PATCH 09/15] update ci.yml --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index aa79c8e..e8c6640 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -68,10 +68,10 @@ jobs: uses: actions/upload-artifact@v4 with: name: gcushare-wheel - path: ./gcushare/dist/*.whl + path: /app/gcushare/dist/*.whl if-no-files-found: error - name: Clean up if: always() run: | - sudo rm -rf gcushare sast \ No newline at end of file + sudo rm -rf /app/gcushare /app/sast \ No newline at end of file From c99772a6913d55024c9d06abb64f573c02f3a4e1 Mon Sep 17 00:00:00 2001 From: "sp.qiang.song" Date: Wed, 24 Jun 2026 09:57:00 +0800 Subject: [PATCH 10/15] update ci build image --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e8c6640..9a69b59 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,7 +10,7 @@ on: env: SA_IMAGE: registry-egc.enflame-tech.com/enflame/ci_sast:v1.0-os - CI_IMAGE: registry-egc.enflame-tech.com/artifacts/torch_gcu:v2.10.0-TR3.7.107-ubuntu2204 + CI_IMAGE: registry-egc.enflame-tech.com/artifacts/qic_ubuntu_1804_gcc7:1.8.2 SAST_REPO: EnflameTechnology/sast SAST_BRANCH: main From dbbb4445c038f2eb6a58e3cb10c9c9ec1b7addfc Mon Sep 17 00:00:00 2001 From: "sp.qiang.song" Date: Wed, 24 Jun 2026 10:08:52 +0800 Subject: [PATCH 11/15] =?UTF-8?q?fix=20clean=20up=20=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci.yml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9a69b59..f0044d8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -68,10 +68,20 @@ jobs: uses: actions/upload-artifact@v4 with: name: gcushare-wheel - path: /app/gcushare/dist/*.whl + path: ${{ github.workspace }}/gcushare/dist/**/*.whl if-no-files-found: error - name: Clean up if: always() run: | - sudo rm -rf /app/gcushare /app/sast \ No newline at end of file + set -euo pipefail + WORKSPACE="${{ github.workspace }}" + for repo in gcushare sast; do + TARGET_PATH="${WORKSPACE}/${repo}" + if [ -d "${TARGET_PATH}" ]; then + sudo rm -rf "${TARGET_PATH}" + echo "Removed ${TARGET_PATH}" + else + echo "Skip ${TARGET_PATH}, directory not found" + fi + done \ No newline at end of file From 98b54ee71b5e39472d34d9e56052ec541a01d959 Mon Sep 17 00:00:00 2001 From: "sp.qiang.song" Date: Wed, 24 Jun 2026 10:22:08 +0800 Subject: [PATCH 12/15] fix sudo --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f0044d8..a066993 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -62,7 +62,7 @@ jobs: -v /home/pypi_packages:/home/pypi_packages \ -w /app \ "${{ env.CI_IMAGE }}" \ - bash -c 'sudo git config --global --add safe.directory /app/gcushare;cd /app/gcushare && sudo bash ./build.sh all' + bash -c 'sudo git config --global --add safe.directory /app/gcushare;cd /app/gcushare && bash ./build.sh all' - name: Upload wheel artifact uses: actions/upload-artifact@v4 From ce6a5ca24a9ec345d143add9e936accf55007b08 Mon Sep 17 00:00:00 2001 From: "sp.qiang.song" Date: Wed, 24 Jun 2026 10:26:45 +0800 Subject: [PATCH 13/15] debug --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a066993..d03d581 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -62,7 +62,7 @@ jobs: -v /home/pypi_packages:/home/pypi_packages \ -w /app \ "${{ env.CI_IMAGE }}" \ - bash -c 'sudo git config --global --add safe.directory /app/gcushare;cd /app/gcushare && bash ./build.sh all' + bash -c 'sudo git config --global --add safe.directory /app/gcushare;cd /app/gcushare && bash ./build.sh all && sleep 300' - name: Upload wheel artifact uses: actions/upload-artifact@v4 From 83d48bebfa29b74590966f80df7ffc5a96666bd3 Mon Sep 17 00:00:00 2001 From: "sp.qiang.song" Date: Wed, 24 Jun 2026 10:38:20 +0800 Subject: [PATCH 14/15] fix upload file/dir --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d03d581..5041a2d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -62,13 +62,13 @@ jobs: -v /home/pypi_packages:/home/pypi_packages \ -w /app \ "${{ env.CI_IMAGE }}" \ - bash -c 'sudo git config --global --add safe.directory /app/gcushare;cd /app/gcushare && bash ./build.sh all && sleep 300' + bash -c 'sudo git config --global --add safe.directory /app/gcushare;cd /app/gcushare && bash ./build.sh all' - name: Upload wheel artifact uses: actions/upload-artifact@v4 with: name: gcushare-wheel - path: ${{ github.workspace }}/gcushare/dist/**/*.whl + path: ${{ github.workspace }}/gcushare/dist/** if-no-files-found: error - name: Clean up From 95a17dbcaf2d7da6c2181c9a8c3f00873834755b Mon Sep 17 00:00:00 2001 From: "sp.qiang.song" Date: Mon, 29 Jun 2026 14:31:59 +0800 Subject: [PATCH 15/15] update build-image.sh --- .../deployments/build-image.sh | 185 +++++++++++++++++- 1 file changed, 184 insertions(+), 1 deletion(-) mode change 120000 => 100755 gcushare-device-plugin/deployments/build-image.sh diff --git a/gcushare-device-plugin/deployments/build-image.sh b/gcushare-device-plugin/deployments/build-image.sh deleted file mode 120000 index 0ac13b6..0000000 --- a/gcushare-device-plugin/deployments/build-image.sh +++ /dev/null @@ -1 +0,0 @@ -../../../common/build-image.sh \ No newline at end of file diff --git a/gcushare-device-plugin/deployments/build-image.sh b/gcushare-device-plugin/deployments/build-image.sh new file mode 100755 index 0000000..845b302 --- /dev/null +++ b/gcushare-device-plugin/deployments/build-image.sh @@ -0,0 +1,184 @@ +#!/bin/bash +# +# Copyright (c) 2024 Enflame. All Rights Reserved. +# + +if [ -f "./build-image.conf" ]; then + source ./build-image.conf +else + echo "build-image.conf is not found, exit."; exit 0 +fi + +VERSION="v1" +SET_VERSION=false + +function usage() { + cat < /dev/null 2>&1; then + echo "docker is not found, exit."; exit 1 + fi + elif [ "$CLI_NAME" == "podman" ]; then + if ! command -v podman > /dev/null 2>&1; then + echo "podman is not found, exit."; exit 1 + fi + elif [ "$CLI_NAME" == "nerdctl" ]; then + if ! command -v nerdctl > /dev/null 2>&1; then + echo "nerdctl is not found, exit."; exit 1 + fi + elif [ "$CLI_NAME" == "ctr" ]; then + if ! command -v ctr > /dev/null 2>&1; then + echo "ctr is not found, exit."; exit 1 + fi + if ! command -v docker > /dev/null 2>&1; then + echo "docker is not found, exit."; exit 1 + fi + else + echo "Invalid cli provided: $CLI_NAME"; exit 1 + fi + + case "$VERSION" in + "v1" | "v1beta1") + echo -e "\033[33mBuild gcushare device plugin version: '$VERSION'\033[0m" + ;; + *) + echo -e "\033[31mError: Invalid version '$VERSION'. Supported versions: v1, v1beta1\033[0m" + usage + exit 1 + ;; + esac +} + +function clearImage() { + echo -e "\033[33mClear old image if exist.\033[0m" + if [ "$CLI_NAME" == "nerdctl" ]; then + $CLI_NAME --namespace $NAMESPACE rmi -f $REPO_FULL_NAME > /dev/null 2>&1 || true + elif [ "$CLI_NAME" == "ctr" ]; then + $CLI_NAME --namespace $NAMESPACE images rm $REPO_FULL_NAME > /dev/null 2>&1 || true + else + $CLI_NAME rmi -f $REPO_FULL_NAME > /dev/null 2>&1 || true + fi +} + +function buildImage() { + echo -e "\033[33mBuilding image: $REPO_FULL_NAME start...\033[0m" + if [ "$CLI_NAME" == "nerdctl" ]; then + $CLI_NAME --namespace $NAMESPACE build --build-arg VERSION=$VERSION -t $REPO_FULL_NAME --file dockerfiles/Dockerfile.$OS . + elif [ "$CLI_NAME" == "ctr" ]; then + docker build --build-arg VERSION=$VERSION -t $REPO_FULL_NAME --file dockerfiles/Dockerfile.$OS . + else + $CLI_NAME build --build-arg VERSION=$VERSION -t $REPO_FULL_NAME --file dockerfiles/Dockerfile.$OS . + fi + echo "The image built successfully." +} + +function saveImage() { + echo -e "\033[33mSave image package to ./images\033[0m" + if [ -d "./images" ]; then + rm -rf ./images + fi + mkdir -p ./images + + IMAGE_SAVED_NAME="${IMAGE_NAME}.tar" + if [ "$CLI_NAME" == "nerdctl" ]; then + $CLI_NAME --namespace $NAMESPACE save -o ./images/$IMAGE_SAVED_NAME $REPO_FULL_NAME + elif [ "$CLI_NAME" == "ctr" ]; then + docker save -o ./images/$IMAGE_SAVED_NAME $REPO_FULL_NAME + $CLI_NAME --namespace $NAMESPACE image import ./images/$IMAGE_SAVED_NAME + else + $CLI_NAME save -o ./images/$IMAGE_SAVED_NAME $REPO_FULL_NAME + fi +} + +function listImage() { + echo -e "\033[33mList images...\033[0m" + if [ "$CLI_NAME" == "nerdctl" ]; then + $CLI_NAME --namespace $NAMESPACE images | grep $IMAGE_NAME + elif [ "$CLI_NAME" == "ctr" ]; then + $CLI_NAME --namespace $NAMESPACE images list | grep $IMAGE_NAME + else + $CLI_NAME images | grep $IMAGE_NAME + fi +} + +while true : + do + [[ "$#" -lt 1 ]] && { break;} + case $1 in + "") + break;; + --os) + OS=$2 + shift;; + --cli) + CLI_NAME=$2 + shift;; + --repo) + REPO_NAME=$2 + shift;; + --name) + IMAGE_NAME=$2 + shift;; + --tag) + TAG=$2 + shift;; + --namespace) + NAMESPACE=$2 + shift;; + --version) + VERSION=$2 + SET_VERSION=true + shift;; + --help | -h) + usage + exit 0;; + *) + echo -e "\033[31mError! Unknown parameter: $1. Please enter the specified parameters according to the usage\033[0m" + usage + exit 1;; + esac + shift +done + +if [ "$SET_VERSION" == "false" ]; then + echo -e "\033[32mWarning: The parameter: '--version' default '$VERSION' only apply to k8s1.24+,"\ + "set to v1beta1 for lower k8s versions\033[0m" +fi + +REPO_FULL_NAME="${REPO_NAME}/${IMAGE_NAME}:${TAG}" + +printEnv +checkCommand + +clearImage +buildImage +saveImage +listImage