3
3
# Colors definition
4
4
readonly RED=$( tput setaf 1)
5
5
readonly RESET=$( tput sgr0)
6
- readonly BLUE=$( tput setaf 2)
6
+ readonly GREEN=$( tput setaf 2)
7
+
8
+ # Check if Podman binary exists
9
+ verify_podman_binary () {
10
+ if hash podman 2> /dev/null; then
11
+ POD_MANAGER=" podman"
12
+ else
13
+ POD_MANAGER=" docker"
14
+ fi
15
+ }
7
16
8
17
# Add port as 9000:9000 as arg when the SO is MacOS or Win
9
18
add_host_port_arg (){
@@ -14,38 +23,49 @@ add_host_port_arg (){
14
23
}
15
24
16
25
pull_ocp_console_image (){
17
- docker pull quay.io/openshift/origin-console:latest
26
+ $POD_MANAGER pull quay.io/openshift/origin-console:latest
18
27
}
19
28
20
- run_docker_console (){
29
+ run_ocp_console_image (){
21
30
secretname=$( kubectl get serviceaccount default --namespace=kube-system -o jsonpath=' {.secrets[0].name}' )
22
31
endpoint=$( kubectl config view -o json | jq ' {myctx: .["current-context"], ctxs: .contexts[], clusters: .clusters[]}' | jq ' select(.myctx == .ctxs.name)' | jq ' select(.ctxs.context.cluster == .clusters.name)' | jq ' .clusters.cluster.server' -r)
23
32
24
33
echo -e " Using $endpoint "
25
- command -v docker run -it $args \
34
+ $POD_MANAGER run -dit $args \
26
35
-e BRIDGE_USER_AUTH=" disabled" \
27
36
-e BRIDGE_K8S_MODE=" off-cluster" \
28
37
-e BRIDGE_K8S_MODE_OFF_CLUSTER_ENDPOINT=$endpoint \
29
38
-e BRIDGE_K8S_MODE_OFF_CLUSTER_SKIP_VERIFY_TLS=true \
30
39
-e BRIDGE_K8S_AUTH=" bearer-token" \
31
40
-e BRIDGE_K8S_AUTH_BEARER_TOKEN=$( kubectl get secret " $secretname " --namespace=kube-system -o template --template=' {{.data.token}}' | base64 --decode) \
32
41
quay.io/openshift/origin-console:latest & > /dev/null
42
+ }
33
43
34
- docker_exists=${?} ; if [[ ${docker_exists} -ne 0 ]]; then
35
- echo -e " ${BLUE} The OLM is accessible via web console at:${RESET} "
36
- echo -e " ${BLUE} https://localhost:9000/${RESET} "
44
+ verify_ocp_console_image (){
45
+ while true ; do
46
+ if [ " $( $POD_MANAGER ps -q -f label=io.openshift.build.source-location=https://github.com/openshift/console) " ];
47
+ then
48
+ echo -e " ${GREEN} The OLM is accessible via web console at:${RESET} "
49
+ echo -e " ${GREEN} http://localhost:9000/${RESET} "
50
+ echo -e " ${GREEN} Press Ctrl-C to quit${RESET} " ; sleep 10;
37
51
else
38
- echo -e " ${RED} Unable to run the console locally. May this port is in usage already. ${RESET} "
39
- echo -e " ${RED} Check if the OLM is not accessible via web console at: https ://localhost:9000/. ${RESET} "
40
- exit 1
52
+ echo -e " ${RED} Unable to run the console locally. May this port is in usage already.${RESET} "
53
+ echo -e " ${RED} Check if the OLM is not accessible via web console at: http ://localhost:9000/${RESET} "
54
+ exit 1
41
55
fi
42
-
56
+ done
43
57
}
44
58
59
+ function ctrl_c() {
60
+ container_id=" $( $POD_MANAGER ps -q -f label=io.openshift.build.source-location=https://github.com/openshift/console) "
61
+ $POD_MANAGER rm -f $container_id
62
+ exit 130
63
+ }
45
64
46
65
# Calling the functions
66
+ verify_podman_binary
47
67
add_host_port_arg
48
68
pull_ocp_console_image
49
- run_docker_console
50
-
51
-
69
+ run_ocp_console_image
70
+ trap ctrl_c INT
71
+ verify_ocp_console_image
0 commit comments