This repository has been archived by the owner on May 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 53
/
launcher-env-template.sh
executable file
·158 lines (130 loc) · 5.43 KB
/
launcher-env-template.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
#!/usr/bin/env bash
#################################################
# Here you can find basic setup for this script #
#################################################
if [ -z "$LAUTH" ]; then
# Default KeyCloak will be used if KEYCLOAK variable is not set before.
# Choose (uncomment) one of the 3 KeyCloak options below.
LAUTH=TOKEN
#LAUTH=KEYCLOAK
#LAUTH=OAUTH
fi
if [ -z "$ECHO_ENV" ]; then
# Display environment vars?
ECHO_ENV=YES
#ECHO_ENV=NO
fi
if [ -z "$UNSET_ENV" ]; then
# Unset environment vars?
UNSET_ENV=YES
#UNSET_ENV=NO
fi
#################################################
#################################################
echo ----- Environment is using $LAUTH authentication -----
SCRIPT_DIR=$(cd "$(dirname "$BASH_SOURCE")" ; pwd -P)
#### DO NOT CHANGE - Reset environment variables
case "$UNSET_ENV" in
"YES")
unset LAUNCHER_MISSIONCONTROL_OPENSHIFT_API_URL
unset LAUNCHER_MISSIONCONTROL_OPENSHIFT_CONSOLE_URL
unset LAUNCHER_MISSIONCONTROL_OPENSHIFT_USERNAME
unset LAUNCHER_MISSIONCONTROL_OPENSHIFT_PASSWORD
unset LAUNCHER_MISSIONCONTROL_OPENSHIFT_TOKEN
unset LAUNCHER_MISSIONCONTROL_OPENSHIFT_IMPERSONATE_USER
unset LAUNCHER_MISSIONCONTROL_OPENSHIFT_CLUSTERS_FILE
unset LAUNCHER_MISSIONCONTROL_GITHUB_USERNAME
unset LAUNCHER_MISSIONCONTROL_GITHUB_TOKEN
unset LAUNCHER_MISSIONCONTROL_GITLAB_PRIVATE_TOKEN
unset LAUNCHER_MISSIONCONTROL_GITLAB_USERNAME
unset LAUNCHER_MISSIONCONTROL_BITBUCKET_USERNAME
unset LAUNCHER_MISSIONCONTROL_BITBUCKET_APPLICATION_PASSWORD
unset LAUNCHER_MISSIONCONTROL_OPENSHIFT_CLUSTERS_SUBSCRIPTION_TOKEN
unset LAUNCHER_KEYCLOAK_URL
unset LAUNCHER_KEYCLOAK_REALM
unset LAUNCHER_KEYCLOAK_CLIENT_ID
unset LAUNCHER_OAUTH_OPENSHIFT_URL
unset LAUNCHER_GIT_PROVIDER
unset LAUNCHER_GIT_PROVIDERS_FILE
unset LAUNCHER_HOVERFLY_CAPTURE
;;
esac
####
case "$LAUTH" in
"TOKEN"|"OAUTH")
# No KeyCloak
OCAPI=$(oc whoami --show-server)
OCCONSOLE=$(oc whoami --show-console)
if [[ $OCAPI != "https://"* || $OCCONSOLE != "https://"* ]]; then
echo "WARNING: No active connection to OpenShift detected, these ENV vars must be set manually"
echo " LAUNCHER_MISSIONCONTROL_OPENSHIFT_API_URL"
echo " LAUNCHER_MISSIONCONTROL_OPENSHIFT_CONSOLE_URL"
return
else
export LAUNCHER_MISSIONCONTROL_OPENSHIFT_API_URL=$OCAPI
export LAUNCHER_MISSIONCONTROL_OPENSHIFT_CONSOLE_URL=$OCCONSOLE
fi
esac
case "$LAUTH" in
"TOKEN")
export LAUNCHER_MISSIONCONTROL_OPENSHIFT_USERNAME=developer
export LAUNCHER_MISSIONCONTROL_OPENSHIFT_PASSWORD=developer
# If set, will override username/password authentication scheme
#export LAUNCHER_MISSIONCONTROL_OPENSHIFT_TOKEN=<token here>
# Setup git providers default credentials (please look at README.md)
export LAUNCHER_MISSIONCONTROL_GITHUB_USERNAME=`git config github.user`
export LAUNCHER_MISSIONCONTROL_GITHUB_TOKEN=`git config github.token`
export LAUNCHER_MISSIONCONTROL_GITLAB_USERNAME=`git config gitlab.user`
export LAUNCHER_MISSIONCONTROL_GITLAB_PRIVATE_TOKEN=`git config gitlab.token`
export LAUNCHER_MISSIONCONTROL_BITBUCKET_USERNAME=`git config bitbucket.user`
export LAUNCHER_MISSIONCONTROL_BITBUCKET_APPLICATION_PASSWORD=`git config bitbucket.password`
;;
"KEYCLOAK")
# Official KeyCloak
export LAUNCHER_KEYCLOAK_URL=https://sso.openshift.io/auth
export LAUNCHER_KEYCLOAK_REALM=rh-developers-launch
#export LAUNCHER_KEYCLOAK_CLIENT_ID=???
export LAUNCHER_MISSIONCONTROL_OPENSHIFT_CLUSTERS_FILE=$SCRIPT_DIR/clusters.yaml
#export LAUNCHER_MISSIONCONTROL_OPENSHIFT_CLUSTERS_SUBSCRIPTION_TOKEN=???
;;
"OAUTH")
# Necessary for OpenShift v4+, comment it out for v3
# See https://docs.openshift.com/container-platform/4.1/authentication/configuring-internal-oauth.html#oauth-server-metadata_configuring-internal-oauth
export LAUNCHER_OAUTH_OPENSHIFT_URL=https://oauth-openshift.apps-crc.testing/oauth/authorize
export LAUNCHER_OAUTH_OPENSHIFT_CLIENT_ID=launcher
;;
*)
echo ERROR: Failed to setup environment. Please choose a LAUTH mode.
[ $PS1 ] && return || exit;
;;
esac
#export LAUNCHER_BACKEND_SENTRY_DSN=???
# This will prevent boosters being downloaded at startup making development faster (default = true)
export LAUNCHER_PREFETCH_BOOSTERS=false
# For launchpad-booster-catalog-service
#export LAUNCHER_BOOSTER_CATALOG_REPOSITORY=https://github.com/fabric8-launcher/launcher-booster-catalog.git
#export LAUNCHER_BOOSTER_CATALOG_REF=master
# This can be used to filter boosters depending on their properties
# Eg. `booster.mission.id == 'rest-http'`
#export LAUNCHER_BOOSTER_CATALOG_FILTER=
# The supported Git providers
#eport LAUNCHER_GIT_PROVIDER=GitHub
export LAUNCHER_GIT_PROVIDERS_FILE=$SCRIPT_DIR/git-providers.yaml
# For launchpad-frontend
#export LAUNCHER_MISSIONCONTROL_URL="ws://localhost:8080"
#export LAUNCHER_BACKEND_URL="http://localhost:8080/api"
#export LAUNCHER_LAUNCH_ENABLED=true
#export LAUNCHER_CREATOR_ENABLED=true
#export LAUNCHER_CREATOR_URL="http://localhost:8080/api/creator"
#export LAUNCHER_CREATOR_SENTRY_DSN=???
#export LAUNCHER_TARGETENVIRONMENT_SKIP=false
#export LAUNCHER_FRONTEND_SENTRY_DSN=???
# Testing tracker token
# It says Segment, but it's actually a Google Analytics token!
#export LAUNCHER_TRACKER_SEGMENT_TOKEN=<GA token here>
case "$ECHO_ENV" in
"YES")
# Display LAUNCHER environment
env | grep 'LAUNCHER_'
;;
esac