Skip to content
This repository was archived by the owner on Nov 15, 2024. It is now read-only.

Commit 4513f6f

Browse files
committed
Modifying onprem_admin to work in nested sandbox env associated with codestream-server repo
1 parent fa0f8df commit 4513f6f

8 files changed

Lines changed: 94 additions & 0 deletions

File tree

onprem_admin/.eslintrc.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
module.exports = {
2+
parser: 'babel-eslint',
3+
env: {
4+
browser: true,
5+
commonjs: true,
6+
es6: true,
7+
node: true,
8+
jest: true
9+
},
10+
extends: ['eslint:recommended', 'plugin:react/recommended'],
11+
parserOptions: {
12+
ecmaFeatures: {
13+
jsx: true
14+
},
15+
sourceType: 'module'
16+
},
17+
plugins: ['react'],
18+
rules: {
19+
indent: ['error', "tab", { SwitchCase: 1 }],
20+
'linebreak-style': ['error', 'unix'],
21+
quotes: ['error', 'single'],
22+
semi: ['error', 'always'],
23+
'no-console': [
24+
'warn',
25+
{ allow: ['clear', 'info', 'error', 'dir', 'trace'] }
26+
]
27+
}
28+
};

onprem_admin/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
.DS_Store
3+
public/bundle.js

onprem_admin/.prettierrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"useTabs": true,
3+
"tabWidth": 4,
4+
"singleQuote": true,
5+
"printWidth": 160
6+
}

onprem_admin/bin/admin_server.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ ExpressServer.get('*', (req, res) => res.send(`bad url: ${req.url}`));
7676
// SHOULD BE READ-ONLY!!!!
7777
GlobalData.AdminConfig = AdminConfig;
7878
const Config = await AdminConfig.loadPreferredConfig();
79+
console.log(Config);
7980
GlobalData.Logger = new SimpleFileLogger(Config.adminServer.logger);
8081
if (Config.adminServer.adminServerDisabled) {
8182
GlobalData.Logger.error('The admin server is disabled in the config. Good bye.');

onprem_admin/sandbox/defaults.sh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export PATH=$OPADM_SANDBOX/node/bin:$OPADM_TOP/node_modules/.bin:$PATH
4343

4444
# Add $MY_SANDBOX/bin to the search path
4545
export PATH=$OPADM_TOP/bin:$PATH
46+
export NODE_PATH=$OPADM_TOP/node_modules:$NODE_PATH
4647

4748
# if you want to short circuit the sandbox hooks (see hooks/git_hooks.sh) either uncomment
4849
# this in defaults.sh or add 'OPADM_DISABLE_GIT_HOOKS=1' to OPADM_SANDBOX/sb.options
@@ -70,3 +71,46 @@ export OPADM_PIDS=$OPADM_SANDBOX/pid # pid files directory
7071
# https://github.com/TeamCodeStream/dev_tools/blob/master/README/README.deployments.md)
7172
[ -z "$OPADM_ENV" ] && export OPADM_ENV=local
7273
# [ -z "$OPADM_ENV" ] && export OPADM_ENV=`eval echo $(get-json-property -j $CSSVC_CFG_FILE -p apiServer.runTimeEnvironment)`
74+
75+
if [ -n "$CSSVC_CFG_URL" ]; then
76+
echo "looking for config from $CSSVC_CFG_URL"
77+
export CSSVC_ENV=`eval echo $(get-json-property --config-url $CSSVC_CFG_URL -p sharedGeneral.runTimeEnvironment)`
78+
# apiPort=`eval echo $(get-json-property --config-url $CSSVC_CFG_URL -p apiServer.port)`
79+
else
80+
[ -n "$OPADM_CFG_FILE" ] && configParm=$OPADM_CFG_FILE || configParm="$CSSVC_CONFIGURATION"
81+
[ -z "$CSSVC_CFG_FILE" ] && sandutil_get_codestream_cfg_file "$OPADM_SANDBOX" "$configParm" "$CSSVC_ENV"
82+
export CSSVC_ENV=`eval echo $(get-json-property -j $CSSVC_CFG_FILE -p sharedGeneral.runTimeEnvironment)`
83+
# apiPort=`eval echo $(get-json-property -j $CSSVC_CFG_FILE -p apiServer.port)`
84+
fi
85+
86+
# sanity check
87+
[ -n "$OPADM_CFG_FILE" -a \( "$CSSVC_CFG_FILE" != "$OPADM_CFG_FILE" \) ] && echo "**** WARNING: OPADM_CFG_FILE != CSSVC_CFG_FILE"
88+
89+
# needed for the build process
90+
export OPADM_ENV=$CSSVC_ENV
91+
92+
# local development sets the callback env so external requests can be routed
93+
# through the network proxy and back to your local VPN IP (codestream version of
94+
# https://ngrok.com)
95+
if [ "$CSSVC_ENV" = local -a -z "$OPADM_CALLBACK_ENV" ]; then
96+
TUNNEL_IP=$(sandutil_get_tunnel_ip fallbackLocalIp,useHyphens)
97+
[ -n "$TUNNEL_IP" ] && export OPADM_CALLBACK_ENV="local-$TUNNEL_IP" || echo "could not detect your vpn ip - callbacks won't work" >&2
98+
[ -n "$OPADM_CALLBACK_ENV" ] && echo "OPADM_CALLBACK_ENV = $OPADM_CALLBACK_ENV"
99+
elif [ -z "$OPADM_CALLBACK_ENV" ]; then
100+
export OPADM_CALLBACK_ENV=$CSSVC_ENV
101+
fi
102+
103+
104+
# local development on ec2 instances (remote hosts) should reference their
105+
# hostname and not 'localhost' when constructing URLs so we set
106+
if [ "$CSSVC_ENV" = "local" ]; then
107+
if [ $(sandutil_is_network_instance) -eq 1 ]; then
108+
export OPADM_PUBLIC_URL="https://`hostname`:$apiPort"
109+
echo "OPADM_PUBLIC_URL = $OPADM_PUBLIC_URL [this is a network development host]"
110+
fi
111+
fi
112+
113+
# Multiple installations possible ($REPO_ROOT/.git/)
114+
[ -n "$CSBE_TOP" ] && export OPADM_REPO_ROOT=$CSBE_TOP || { . $OPADM_SANDBOX/sb.info; export OPADM_REPO_ROOT=$OPADM_SANDBOX/$SB_REPO_ROOT; }
115+
[ -z "$CSSVC_BACKEND_ROOT" ] && export CSSVC_BACKEND_ROOT=$OPADM_REPO_ROOT
116+
return 0

sandbox/configure-sandbox

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ cd $CS_API_TOP && npm install --no-save
8282
cd $CS_BROADCASTER_TOP && npm install --no-save
8383
cd $CS_MAILIN_TOP && npm install --no-save
8484
cd $CS_OUTBOUND_EMAIL_TOP && npm install --no-save
85+
cd $OPADM_TOP && npm install --no-save
8586

8687
# You must exit with a status of '0' if the script was successful or '1' otherwise.
8788
exit 0

sandbox/defaults.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,9 @@ export CS_OUTBOUND_EMAIL_SANDBOX=$CSBE_SANDBOX
8989
export CS_OUTBOUND_EMAIL_TOP=$CSBE_TOP/outbound_email
9090
# CS_OUTBOUND_EMAIL_DEPS=....
9191
. $CS_OUTBOUND_EMAIL_TOP/sandbox/defaults.sh
92+
93+
export OPADM_NAME=$CSBE_NAME
94+
export OPADM_SANDBOX=$CSBE_SANDBOX
95+
export OPADM_TOP=$CSBE_TOP/onprem_admin
96+
# OPADM_DEPS=....
97+
. $OPADM_TOP/sandbox/defaults.sh

sandbox/sb.info.opadm

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
SB_TYPE=opadm
2+
SB_PREFIX=OPADM
3+
[email protected]:teamcodestream/codestream-server
4+
SB_REPO_ROOT=codestream-server
5+
SB_PROJECT_PATH=codestream-server/onprem_admin

0 commit comments

Comments
 (0)