Skip to content

Commit 1f33cac

Browse files
committed
feat: add DOCKERHUB_REPO configure when run _install.sh, add search test
1 parent 3b1a0a0 commit 1f33cac

File tree

6 files changed

+42
-13
lines changed

6 files changed

+42
-13
lines changed

.work/config/.env.amd64

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ CONTAINER_NAMESPACE=test
1717
# never set username and password, you must login manually in your local system firstly.
1818
DOCKERHUB_USERNAME=xxx
1919
DOCKERHUB_PASSWORD=xxx
20-
DOCKERHUB_DOMAIN=docker.io
20+
# DOCKERHUB_DOMAIN=docker.io # Deprecated, it will not be used
2121
DOCKERHUB_REPO=docker.io/lvsid # change to your own docker hub.
2222

2323
### Services ##############################################

.work/config/.env.arm64

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ CONTAINER_NAMESPACE=test
1717
# never set username and password, you must login manually in your local system firstly.
1818
DOCKERHUB_USERNAME=xxx
1919
DOCKERHUB_PASSWORD=xxx
20-
DOCKERHUB_DOMAIN=docker.io
20+
# DOCKERHUB_DOMAIN=docker.io # Deprecated, it will not be used
2121
DOCKERHUB_REPO=docker.io/lvsid # change to your own docker hub.
2222

2323
### Services ##############################################

.work/include/internal/constant.sh

+3
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,6 @@ CONST_BASE_CONFIG_ENV_ARM64_FILE=".work/config/.env.arm64"
2121
CONST_BASE_CONFIG_COMPOSE_FILE=".work/config/docker-compose.yml"
2222
CONST_SPARROW_CONFIG_ENV_FILE=".env"
2323
CONST_SPARROW_CONFIG_COMPOSE_FILE="docker-compose.yml"
24+
25+
# define some default values
26+
CONST_DEFAULT_DOCKERHUB_REPO="docker.io/lvsid"

.work/include/internal/dockerhub.sh

+12-8
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,26 @@ cd $SPARROW_BASE_PATH
77
# login of $DOCKERHUB_DOMAIN.
88
# to be safety, never allow login with account in the command, you must login manually in your local system firstly.
99
# docker login -u $DOCKERHUB_USERNAME -p $DOCKERHUB_PASSWORD $DOCKERHUB_DOMAIN
10-
login() {
11-
print_info "docker login {$DOCKERHUB_DOMAIN}..."
12-
# due to the reasons mentioned above, there is no need to do login explicitly here, as the session will be retained after manual login.
13-
# if ! docker login; then
14-
# print_error "docker login failed"
15-
# exit 1
16-
# fi
17-
}
10+
# @Deprecated: it is not available, and not being called
11+
# login() {
12+
# print_info "docker login {$DOCKERHUB_DOMAIN}..."
13+
# due to the reasons mentioned above, there is no need to do login explicitly here, as the session will be retained after manual login.
14+
# if ! docker login; then
15+
# print_error "docker login failed"
16+
# exit 1
17+
# fi
18+
# }
1819

1920
# search image
2021
search() {
2122
search_image=$1
2223
remove_prefix_search_image=$(echo "$search_image" | sed 's/^docker.io\///')
24+
echo "search search_image=${search_image}, remove_prefix_search_image=${remove_prefix_search_image}"
2325
if docker search "$search_image" | grep -q "^$remove_prefix_search_image"; then
26+
print_info "find it"
2427
return 0 # find
2528
else
29+
print_warn "not find it"
2630
return 1 # not find
2731
fi
2832
}

.work/test/run.sh

+11-3
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,19 @@ sleep_seconds 3
1616
testhttp() {
1717
if is_mac; then
1818
# open websites.
19-
open "http://127.0.0.1:${ETCDKEEPER_HOST_PORT}/etcdkeeper/" # etcdkeeper
20-
open "http://127.0.0.1:${KAFKAUI_HOST_PORT}/" # kafkaui
19+
open "http://127.0.0.1:${ETCDKEEPER_HOST_PORT}/etcdkeeper/" # etcdkeeper
20+
open "http://127.0.0.1:${KAFKAUI_HOST_PORT}/" # kafkaui
2121
fi
2222
}
23-
testhttp
23+
# testhttp
24+
25+
echo "test search"
26+
for service in "${ENABLE_SERVICE_LIST[@]}"; do
27+
image="sparrow-basic-${service}"
28+
search "$DOCKERHUB_REPO/$image"
29+
image="sparrow-app-${service}"
30+
search "$DOCKERHUB_REPO/$image"
31+
done
2432

2533
printf "UnitTest Success"
2634
exit 0

_install.sh

+14
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,20 @@ modify_files() {
6363
# this operation is fine because when the sdk.sh file is included at the beginning, the /env file is created.
6464
print_info "set GO_PATH: before($GO_PATH), after($local_go_path)"
6565
awk -F= '/^GO_PATH=/{OFS="="; $2="'${local_go_path}'"}1' "$CONST_SPARROW_CONFIG_ENV_FILE" > temp && mv temp "$CONST_SPARROW_CONFIG_ENV_FILE"
66+
67+
# modify DOCKERHUB_REPO in /env file
68+
if [ "$DOCKERHUB_REPO" == "$CONST_DEFAULT_DOCKERHUB_REPO" ]; then
69+
echo "set DOCKERHUB_REPO to configure your remote repository, press enter will use the default value (default=docker.io/lvsid)"
70+
printf "please input: "
71+
read dockerhub_repo
72+
if [ "$dockerhub_repo" == "" ]; then
73+
dockerhub_repo="$CONST_DEFAULT_DOCKERHUB_REPO"
74+
else
75+
awk -F= '/^DOCKERHUB_REPO=/{OFS="="; $2="'${dockerhub_repo}'"}1' "$CONST_SPARROW_CONFIG_ENV_FILE" > temp && mv temp "$CONST_SPARROW_CONFIG_ENV_FILE"
76+
fi
77+
print_info "your DOCKERHUB_REPO config is: ${dockerhub_repo}"
78+
print_warn "If you need to change the configuration in the future, you can update the DOCKERHUB_REPO variable in the /.env file."
79+
fi
6680
}
6781

6882
# before run install command.

0 commit comments

Comments
 (0)