-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.sh
executable file
·47 lines (41 loc) · 1.27 KB
/
main.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/sh
echo "Registering a console link"
# input validation
if [ -z "${APP_MENU_IMAGE_URL}" ]; then
echo "Please provide APP_MENU_IMAGE_URL as an environment variable"
exit
fi
if [ -z "${APP_MENU_SECTION}" ]; then
echo "Please provide APP_MENU_SECTION as an environment variable"
exit
fi
if [ -z "${ROUTE_NAME}" ]; then
echo "Please provide ROUTE_NAME as the an environment variable"
exit
fi
if [ -z "${ROUTE_NAMESPACE}" ]; then
echo "Please provide ROUTE_NAMESPACE as an environment variable"
exit
fi
if [ -z "${CONSOLE_LINK_TEXT}" ]; then
echo "Please provide CONSOLE_LINK_TEXT as an environment variable"
exit
fi
if [ -z "${APP_NAME}" ]; then
echo "Please provide APP_NAME as an environment variable"
exit
fi
CONSOLE_LINK_URL="https://$(oc get route $ROUTE_NAME -o=jsonpath='{.spec.host}' -n $ROUTE_NAMESPACE)"
RESULT=$?
if [ $RESULT -eq 0 ]; then
cat console-link.yaml | \
sed "s@#APP_MENU_IMAGE_URL@${APP_MENU_IMAGE_URL}@g" | \
sed "s@#APP_MENU_SECTION@${APP_MENU_SECTION}@g"| \
sed "s@#CONSOLE_LINK_URL@${CONSOLE_LINK_URL}@g"| \
sed "s@#CONSOLE_LINK_TEXT@${CONSOLE_LINK_TEXT}@g"| \
sed "s@#APP_NAME@${APP_NAME}@g"| \
oc apply -f -
else
echo "Route $ROUTE_NAME in $ROUTE_NAMESPACE not exist"
exit 1
fi