From 7f21b00bf226d0f018c381df0a635276ec78122d Mon Sep 17 00:00:00 2001 From: oscar Date: Thu, 17 Mar 2022 08:59:53 +1300 Subject: [PATCH 1/5] adjust the function executing sequence --- build_manager.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build_manager.sh b/build_manager.sh index 2ea900d..5eeb376 100755 --- a/build_manager.sh +++ b/build_manager.sh @@ -110,9 +110,9 @@ function build_portainer_all() { exit; fi - build_portainer_frontend_without_prompt - build_portainer_backend_without_prompt + + build_portainer_frontend_without_prompt } function run_before_commit() { -- 2.40.1 From 1cbbebff40c5c2745420d884129409b5419b638b Mon Sep 17 00:00:00 2001 From: oscar Date: Thu, 17 Mar 2022 21:28:40 +1300 Subject: [PATCH 2/5] support to choose export volume --- build_manager.sh | 64 +++++++++++++++++++++++++++++++++--------------- 1 file changed, 44 insertions(+), 20 deletions(-) diff --git a/build_manager.sh b/build_manager.sh index 5eeb376..43284c2 100755 --- a/build_manager.sh +++ b/build_manager.sh @@ -3,6 +3,7 @@ set -eu WORKDIR=/home/oscarzhou/source/github.com/portainer +GLOBAL_VOLUME=/home/oscarzhou/volumes TRUE=0; FALSE=1; @@ -13,7 +14,7 @@ ERROR_COLOR='\033[0;31m'; HIGHLIGHT_COLOR='\033[0;32m'; NO_COLOR='\033[0m'; -function is_ce_project() { +function choose_repo() { read -p "Choose the working project EE/(CE):" REPO if [ -z "$REPO" ]; then @@ -21,10 +22,10 @@ function is_ce_project() { fi if [[ "${REPO}" == "ee" || "${REPO}" == "EE" ]]; then - return $FALSE; + cd ${WORKDIR}/portainer-ee elif [[ "${REPO}" == "ce" || "${REPO}" == "CE" ]]; then - return $TRUE; + cd ${WORKDIR}/portainer fi } @@ -49,20 +50,41 @@ function check_branch() { return $TRUE; } -function export_volume() { - local VOLUME=~/volumes/portainer-ee-data - if is_ce_project; then - VOLUME=~/volumes/portainer-ce-data - cd ${WORKDIR}/portainer +function choose_export_volume() { + read -p "Choose the volume EE/CE/Temp-data(TD):" DEST + + if [ -z "$DEST" ]; then + DEST="EE"; + fi + + if [[ "${DEST}" == "ee" || "${DEST}" == "EE" ]]; then + VOLUME=~/volumes/portainer-ee-data + + elif [[ "${DEST}" == "ce" || "${DEST}" == "CE" ]]; then + VOLUME=~/volumes/portainer-ce-data + + elif [[ "${DEST}" == "td" || "${DEST}" == "TD" ]]; then + VOLUME=~/volumes/temp-data - else - cd ${WORKDIR}/portainer-ee fi export PORTAINER_DATA=${VOLUME} printf "${HIGHLIGHT_COLOR}export PORTAINER_DATA=${PORTAINER_DATA}${NO_COLOR}\n" } +function prepare_temporary_volume() { + printf "${HIGHLIGHT_COLOR}Prepare temporary data${NO_COLOR}\n" + + local VOLUME=~/volumes/temp-data + if [ -d ${VOLUME} ]; then + read -p "Do you want to clean up the existing data N/(Y)?" CLEAN_DATA + if [[ "${CLEAN_DATA}" == "y" || "${CLEAN_DATA}" == "Y" ]]; then + rm -rvf ${VOLUME}/* + fi + else + mkdir ${VOLUME} + fi +} function build_portainer_frontend_without_prompt() { printf "${HIGHLIGHT_COLOR}Build Portainer Frontend${NO_COLOR}\n" @@ -81,7 +103,7 @@ function build_portainer_backend_without_prompt() { } function build_portainer_frontend() { - export_volume + choose_repo if ! check_branch; then exit; @@ -92,7 +114,9 @@ function build_portainer_frontend() { } function build_portainer_backend() { - export_volume + choose_repo + + choose_export_volume if ! check_branch; then exit; @@ -104,7 +128,9 @@ function build_portainer_backend() { function build_portainer_all() { printf "${HIGHLIGHT_COLOR}Build Portainer all${NO_COLOR}\n" - export_volume + choose_repo + + choose_export_volume if ! check_branch; then exit; @@ -118,11 +144,7 @@ function build_portainer_all() { function run_before_commit() { printf "${HIGHLIGHT_COLOR}Run before commit${NO_COLOR}\n" - if is_ce_project; then - cd ${WORKDIR}/portainer - else - cd ${WORKDIR}/portainer-ee - fi + choose_repo if ! check_branch; then exit; @@ -135,8 +157,6 @@ function run_before_commit() { yarn lint } - - function menu() { PS3='Please select the option: ' OPTIONS=( @@ -144,6 +164,7 @@ function menu() { 'Build Portainer Frontend' 'Build Portainer Backend' 'Run Before Commit' + 'Prepare Temporary Volume' 'Quit' ) @@ -162,6 +183,9 @@ function menu() { 'Run Before Commit') run_before_commit ;; + 'Prepare Temporary Volume') + prepare_temporary_volume + ;; 'Quit') break ;; -- 2.40.1 From 31283547003fa775be3e623db9bb55ad919eea1a Mon Sep 17 00:00:00 2001 From: oscar Date: Sat, 19 Mar 2022 16:51:57 +1300 Subject: [PATCH 3/5] add .gitignore --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..82a033c --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +/node_modules + +yarn.lock \ No newline at end of file -- 2.40.1 From 7793f7e5f99259f0ecd81c420ca1471c023a9ded Mon Sep 17 00:00:00 2001 From: oscar Date: Thu, 24 Mar 2022 08:42:49 +1300 Subject: [PATCH 4/5] add option for k8s helm chart lint check --- build_manager.sh | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/build_manager.sh b/build_manager.sh index 43284c2..1dc6e30 100755 --- a/build_manager.sh +++ b/build_manager.sh @@ -15,7 +15,7 @@ HIGHLIGHT_COLOR='\033[0;32m'; NO_COLOR='\033[0m'; function choose_repo() { - read -p "Choose the working project EE/(CE):" REPO + read -p "Choose the working project EE/(CE)/(k8s):" REPO if [ -z "$REPO" ]; then REPO="EE"; @@ -26,6 +26,9 @@ function choose_repo() { elif [[ "${REPO}" == "ce" || "${REPO}" == "CE" ]]; then cd ${WORKDIR}/portainer + + elif [[ "${REPO}" == "k8s" || "${REPO}" == "ks" ]]; then + cd ${WORKDIR}/k8s fi } @@ -72,11 +75,12 @@ function choose_export_volume() { printf "${HIGHLIGHT_COLOR}export PORTAINER_DATA=${PORTAINER_DATA}${NO_COLOR}\n" } -function prepare_temporary_volume() { - printf "${HIGHLIGHT_COLOR}Prepare temporary data${NO_COLOR}\n" +function cleanup_temporary_volume() { + printf "${HIGHLIGHT_COLOR}Clean temporary data${NO_COLOR}\n" local VOLUME=~/volumes/temp-data if [ -d ${VOLUME} ]; then + printf "The current volume is ${VOLUME}. " read -p "Do you want to clean up the existing data N/(Y)?" CLEAN_DATA if [[ "${CLEAN_DATA}" == "y" || "${CLEAN_DATA}" == "Y" ]]; then rm -rvf ${VOLUME}/* @@ -157,6 +161,21 @@ function run_before_commit() { yarn lint } + +function run_before_commit_k8s() { + printf "${HIGHLIGHT_COLOR}Run before commit${NO_COLOR}\n" + + choose_repo + + if ! check_branch; then + exit; + fi + + printf "${HIGHLIGHT_COLOR}chart-testing ct lint${NO_COLOR}\n" + + docker run --rm -it -w /repo -v `pwd`:/repo quay.io/helmpack/chart-testing ct lint --all --config=.ci/ct-config.yaml +} + function menu() { PS3='Please select the option: ' OPTIONS=( @@ -164,7 +183,8 @@ function menu() { 'Build Portainer Frontend' 'Build Portainer Backend' 'Run Before Commit' - 'Prepare Temporary Volume' + 'Cleanup Temporary Volume' + 'Run Before COmmit (k8s)' 'Quit' ) @@ -183,8 +203,11 @@ function menu() { 'Run Before Commit') run_before_commit ;; - 'Prepare Temporary Volume') - prepare_temporary_volume + 'Cleanup Temporary Volume') + cleanup_temporary_volume + ;; + 'Run Before COmmit (k8s)') + run_before_commit_k8s ;; 'Quit') break -- 2.40.1 From c039838a9e56e095bd161764038ac9b1523fdbf0 Mon Sep 17 00:00:00 2001 From: oscar Date: Thu, 19 May 2022 12:36:38 +1200 Subject: [PATCH 5/5] add option for agent build --- build_manager.sh | 43 ++++++++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/build_manager.sh b/build_manager.sh index 1dc6e30..851ef9d 100755 --- a/build_manager.sh +++ b/build_manager.sh @@ -15,7 +15,7 @@ HIGHLIGHT_COLOR='\033[0;32m'; NO_COLOR='\033[0m'; function choose_repo() { - read -p "Choose the working project EE/(CE)/(k8s):" REPO + read -p "Choose the working project EE/(CE)/(k8s)/(agent):" REPO if [ -z "$REPO" ]; then REPO="EE"; @@ -29,6 +29,9 @@ function choose_repo() { elif [[ "${REPO}" == "k8s" || "${REPO}" == "ks" ]]; then cd ${WORKDIR}/k8s + + elif [[ "${REPO}" == "ag" || "${REPO}" == "agent" ]]; then + cd ${WORKDIR}/agent fi } @@ -129,6 +132,16 @@ function build_portainer_backend() { build_portainer_backend_without_prompt } +function build_portainer_agent() { + choose_repo + + if ! check_branch; then + exit; + fi + + ./dev.sh compile +} + function build_portainer_all() { printf "${HIGHLIGHT_COLOR}Build Portainer all${NO_COLOR}\n" @@ -179,36 +192,40 @@ function run_before_commit_k8s() { function menu() { PS3='Please select the option: ' OPTIONS=( - 'Build Portainer All' - 'Build Portainer Frontend' - 'Build Portainer Backend' - 'Run Before Commit' + 'Build Portainer EE/CE All' + 'Build Portainer EE/CE Frontend' + 'Build Portainer EE/CE Backend' + 'Run Before Commit [Portainer EE/CE]' + 'Run Before Commit [k8s]' + 'Build Portainer Agent' 'Cleanup Temporary Volume' - 'Run Before COmmit (k8s)' 'Quit' ) select opt in "${OPTIONS[@]}" do case $opt in - 'Build Portainer All') + 'Build Portainer EE/CE All') build_portainer_all ;; - 'Build Portainer Frontend') + 'Build Portainer EE/CE Frontend') build_portainer_frontend ;; - 'Build Portainer Backend') + 'Build Portainer EE/CE Backend') build_portainer_backend ;; - 'Run Before Commit') + 'Run Before Commit [Portainer EE/CE]') run_before_commit ;; + 'Run Before Commit [k8s]') + run_before_commit_k8s + ;; + 'Build Portainer Agent') + build_portainer_agent + ;; 'Cleanup Temporary Volume') cleanup_temporary_volume ;; - 'Run Before COmmit (k8s)') - run_before_commit_k8s - ;; 'Quit') break ;; -- 2.40.1