Compare commits

..

No commits in common. "ff95becbbdd82320a9034a2e31901ddb6ae3008f" and "fe4dd320695c0bba7bd6965c9948d16409b118ec" have entirely different histories.

2 changed files with 28 additions and 95 deletions

3
.gitignore vendored
View File

@ -1,3 +0,0 @@
/node_modules
yarn.lock

View File

@ -3,7 +3,6 @@
set -eu set -eu
WORKDIR=/home/oscarzhou/source/github.com/portainer WORKDIR=/home/oscarzhou/source/github.com/portainer
GLOBAL_VOLUME=/home/oscarzhou/volumes
TRUE=0; TRUE=0;
FALSE=1; FALSE=1;
@ -14,24 +13,18 @@ ERROR_COLOR='\033[0;31m';
HIGHLIGHT_COLOR='\033[0;32m'; HIGHLIGHT_COLOR='\033[0;32m';
NO_COLOR='\033[0m'; NO_COLOR='\033[0m';
function choose_repo() { function is_ce_project() {
read -p "Choose the working project EE/(CE)/(k8s)/(agent):" REPO read -p "Choose the working project EE/(CE):" REPO
if [ -z "$REPO" ]; then if [ -z "$REPO" ]; then
REPO="EE"; REPO="EE";
fi fi
if [[ "${REPO}" == "ee" || "${REPO}" == "EE" ]]; then if [[ "${REPO}" == "ee" || "${REPO}" == "EE" ]]; then
cd ${WORKDIR}/portainer-ee return $FALSE;
elif [[ "${REPO}" == "ce" || "${REPO}" == "CE" ]]; then elif [[ "${REPO}" == "ce" || "${REPO}" == "CE" ]]; then
cd ${WORKDIR}/portainer return $TRUE;
elif [[ "${REPO}" == "k8s" || "${REPO}" == "ks" ]]; then
cd ${WORKDIR}/k8s
elif [[ "${REPO}" == "ag" || "${REPO}" == "agent" ]]; then
cd ${WORKDIR}/agent
fi fi
} }
@ -56,42 +49,20 @@ function check_branch() {
return $TRUE; return $TRUE;
} }
function choose_export_volume() { function export_volume() {
read -p "Choose the volume EE/CE/Temp-data(TD):" DEST local VOLUME=~/volumes/portainer-ee-data
if is_ce_project; then
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 VOLUME=~/volumes/portainer-ce-data
cd ${WORKDIR}/portainer
elif [[ "${DEST}" == "td" || "${DEST}" == "TD" ]]; then else
VOLUME=~/volumes/temp-data cd ${WORKDIR}/portainer-ee
fi fi
export PORTAINER_DATA=${VOLUME} export PORTAINER_DATA=${VOLUME}
printf "${HIGHLIGHT_COLOR}export PORTAINER_DATA=${PORTAINER_DATA}${NO_COLOR}\n" printf "${HIGHLIGHT_COLOR}export PORTAINER_DATA=${PORTAINER_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}/*
fi
else
mkdir ${VOLUME}
fi
}
function build_portainer_frontend_without_prompt() { function build_portainer_frontend_without_prompt() {
printf "${HIGHLIGHT_COLOR}Build Portainer Frontend${NO_COLOR}\n" printf "${HIGHLIGHT_COLOR}Build Portainer Frontend${NO_COLOR}\n"
@ -110,7 +81,7 @@ function build_portainer_backend_without_prompt() {
} }
function build_portainer_frontend() { function build_portainer_frontend() {
choose_repo export_volume
if ! check_branch; then if ! check_branch; then
exit; exit;
@ -121,9 +92,7 @@ function build_portainer_frontend() {
} }
function build_portainer_backend() { function build_portainer_backend() {
choose_repo export_volume
choose_export_volume
if ! check_branch; then if ! check_branch; then
exit; exit;
@ -132,36 +101,28 @@ function build_portainer_backend() {
build_portainer_backend_without_prompt build_portainer_backend_without_prompt
} }
function build_portainer_agent() {
choose_repo
if ! check_branch; then
exit;
fi
./dev.sh compile
}
function build_portainer_all() { function build_portainer_all() {
printf "${HIGHLIGHT_COLOR}Build Portainer all${NO_COLOR}\n" printf "${HIGHLIGHT_COLOR}Build Portainer all${NO_COLOR}\n"
choose_repo export_volume
choose_export_volume
if ! check_branch; then if ! check_branch; then
exit; exit;
fi fi
build_portainer_backend_without_prompt
build_portainer_frontend_without_prompt build_portainer_frontend_without_prompt
build_portainer_backend_without_prompt
} }
function run_before_commit() { function run_before_commit() {
printf "${HIGHLIGHT_COLOR}Run before commit${NO_COLOR}\n" printf "${HIGHLIGHT_COLOR}Run before commit${NO_COLOR}\n"
choose_repo if is_ce_project; then
cd ${WORKDIR}/portainer
else
cd ${WORKDIR}/portainer-ee
fi
if ! check_branch; then if ! check_branch; then
exit; exit;
@ -175,57 +136,32 @@ function run_before_commit() {
} }
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() { function menu() {
PS3='Please select the option: ' PS3='Please select the option: '
OPTIONS=( OPTIONS=(
'Build Portainer EE/CE All' 'Build Portainer All'
'Build Portainer EE/CE Frontend' 'Build Portainer Frontend'
'Build Portainer EE/CE Backend' 'Build Portainer Backend'
'Run Before Commit [Portainer EE/CE]' 'Run Before Commit'
'Run Before Commit [k8s]'
'Build Portainer Agent'
'Cleanup Temporary Volume'
'Quit' 'Quit'
) )
select opt in "${OPTIONS[@]}" select opt in "${OPTIONS[@]}"
do do
case $opt in case $opt in
'Build Portainer EE/CE All') 'Build Portainer All')
build_portainer_all build_portainer_all
;; ;;
'Build Portainer EE/CE Frontend') 'Build Portainer Frontend')
build_portainer_frontend build_portainer_frontend
;; ;;
'Build Portainer EE/CE Backend') 'Build Portainer Backend')
build_portainer_backend build_portainer_backend
;; ;;
'Run Before Commit [Portainer EE/CE]') 'Run Before Commit')
run_before_commit run_before_commit
;; ;;
'Run Before Commit [k8s]')
run_before_commit_k8s
;;
'Build Portainer Agent')
build_portainer_agent
;;
'Cleanup Temporary Volume')
cleanup_temporary_volume
;;
'Quit') 'Quit')
break break
;; ;;