-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathentrypoint.sh
More file actions
executable file
·68 lines (57 loc) · 1.32 KB
/
entrypoint.sh
File metadata and controls
executable file
·68 lines (57 loc) · 1.32 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/bash
set -e
if [ -n "$PROJECT_PATH" ]; then
cd "$PROJECT_PATH"
fi
CLEANUP_TOKEN=""
SCRIPT_ARGS=("$@")
cleanup() {
if [ -n "$CLEANUP_TOKEN" ]; then
(node /kit/token/src/cleanup.ts "${SCRIPT_ARGS[@]}") || true
fi
}
trap cleanup EXIT
# Function like `juno functions build` are local only
requires_no_auth() {
local args="$1"
case "$args" in
"functions build"* | "fn build"* | \
"functions eject"* | "fn eject"* | \
"functions init"* | "fn init"* | \
"emulator start"* | "emulator stop"* | "emulator wait"* | \
"version"*)
return 0
;;
*)
return 1
;;
esac
}
# Some functions require Admin privileges which cannot be granted with the OIDC flow.
requires_token_only() {
local args="$1"
case "$args" in
"start"* | "stop"* | "status"* | "upgrade"*)
return 0
;;
*)
return 1
;;
esac
}
if requires_no_auth "$*"; then
: # No auth needed
elif requires_token_only "$*"; then
if [ -z "$JUNO_TOKEN" ]; then
echo "This command requires a JUNO_TOKEN. OIDC authentication is not supported for administrative commands."
exit 1
fi
else
if [ -z "$JUNO_TOKEN" ]; then
JUNO_TOKEN=$(node /kit/token/src/authenticate.ts "$@")
echo "::add-mask::$JUNO_TOKEN"
export JUNO_TOKEN
CLEANUP_TOKEN="true"
fi
fi
juno "$@" --headless