Skip to content

Commit 52c7ec8

Browse files
authored
Merge pull request #5 from alauda/fix/resoure-not-found
fix: when resource not found, skip error.
2 parents aa92835 + 242f919 commit 52c7ec8

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

setup.sh

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ SKIP_UPLOAD="false"
2727

2828
function detect() {
2929
local v
30-
REGISTRY=$(kubectl get productbases.product.alauda.io base -o jsonpath='{.spec.registry.address}' --ignore-not-found)
31-
v=$(kubectl get secrets -n cpaas-system registry-admin -o jsonpath='{.data.username}' --ignore-not-found)
30+
REGISTRY=$(kubectl get productbases.product.alauda.io base -o jsonpath='{.spec.registry.address}' --ignore-not-found || :)
31+
v=$(kubectl get secrets -n cpaas-system registry-admin -o jsonpath='{.data.username}' --ignore-not-found || :)
3232
if [ -n "${v}" ]; then
3333
USERNAME=$(echo "${v}" | base64 -d)
3434
fi
35-
v=$(kubectl get secrets -n cpaas-system registry-admin -o jsonpath='{.data.password}' --ignore-not-found)
35+
v=$(kubectl get secrets -n cpaas-system registry-admin -o jsonpath='{.data.password}' --ignore-not-found || :)
3636
if [ -n "${v}" ]; then
3737
PASSWORD=$(echo "${v}" | base64 -d)
3838
fi
@@ -70,12 +70,17 @@ function apply_resources() {
7070

7171
function apply_hooks() {
7272
local hooks
73-
hooks=$(ls "${HOOKS_DIR}/"*.sh)
73+
# When the hook script does not exist, ensure that it can run normally.
74+
hooks=$(ls "${HOOKS_DIR}/"*.sh || :)
7475
for it in ${hooks}; do
7576
bash "${it}"
7677
done
7778
}
7879

80+
function success() {
81+
echo "setup success"
82+
}
83+
7984
function parse_args() {
8085
if [ "$#" -eq "0" ]; then
8186
return
@@ -104,7 +109,8 @@ function parse_args() {
104109
shift
105110
;;
106111
--skip-upload)
107-
SKIP_UPLOAD="true"
112+
SKIP_UPLOAD="$2"
113+
shift
108114
;;
109115
*)
110116
if [ -n "$1" ]; then
@@ -124,3 +130,4 @@ parse_args "$@"
124130
upload_artifacts
125131
apply_resources
126132
apply_hooks
133+
success

0 commit comments

Comments
 (0)