Skip to content

Commit

Permalink
fix(build): issues/16 separate out hosts update (#22)
Browse files Browse the repository at this point in the history
* minor tweak for first time users and host setup
  • Loading branch information
cdcabrera authored Jun 28, 2019
1 parent 50b0ca5 commit 8c2815a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"scripts": {
"api:dev": "mock -p 5000 -w ./src/services",
"api:docs": "node ./scripts/openapi.docs.js",
"api:proxy-hosts": "sh ./scripts/proxy.api.sh -s",
"api:proxy": "sh ./scripts/proxy.api.sh -d \"ci.foo.redhat.com\" -p 1337 -c \"$(pwd)/config/spandx.config.js\"",
"api:proxyClean": "sh ./scripts/proxy.api.sh -u",
"build": "run-s -l build:pre build:version build:js build:post test:integration",
Expand All @@ -63,7 +64,7 @@
"release": "standard-version",
"start": "sh ./scripts/dev.chrome.sh; run-p -l api:dev start:js",
"start:js": "react-scripts start",
"start:proxy": "sh -ac '. ./.env.proxy; open https://ci.foo.redhat.com:1337/; run-p -l start:js api:proxy api:dev'",
"start:proxy": "sh -ac '. ./.env.proxy; open https://ci.foo.redhat.com:1337/; run-s api:proxy-hosts; run-p -l start:js api:proxy api:dev'",
"start:standalone": "rm ./.env.development.local; run-p -l api:dev start:js",
"test": "run-s test:lint test:ci",
"test:ci": "export CI=true; react-scripts test --env=jsdom --roots=./src --coverage",
Expand Down
15 changes: 11 additions & 4 deletions scripts/proxy.api.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ gitRepo()
(cd $DIR && git clone --depth=1 $GITREPO temp > /dev/null 2>&1)

if [ $? -eq 0 ]; then
printf "\n${GREEN}Cloning ${GITREPO} ...${NOCOLOR}"
printf "\n${GREEN}Checking ${GITREPO} ...${NOCOLOR}"

rm -rf $DIR_REPO
cp -R $DIR/temp $DIR_REPO

rm -rf $DIR/temp
rm -rf $DIR_REPO/.git

printf "${GREEN}Clone SUCCESS${NOCOLOR}\n"
printf "${GREEN}SUCCESS${NOCOLOR}\n"

elif [ -d $DIR_REPO ]; then
printf "${YELLOW}Unable to connect, using cached ${GITREPO}...${NOCOLOR}\n"
Expand Down Expand Up @@ -134,6 +134,7 @@ runProxy()
PORT=1337
CONFIG=""
UPDATE=false
HOST_ONLY=false


REPO="https://github.com/RedHatInsights/insights-proxy.git"
Expand All @@ -142,13 +143,14 @@ runProxy()
CONTAINER="redhatinsights/insights-proxy"
CONTAINER_NAME="insightsproxy"

while getopts p:c:d:u option;
while getopts p:c:d:us option;
do
case $option in
p ) PORT="$OPTARG";;
c ) CONFIG="$OPTARG";;
d ) DOMAIN="$OPTARG";;
u ) UPDATE=true;;
s ) HOST=true;;
esac
done

Expand All @@ -163,6 +165,11 @@ runProxy()
printf "${YELLOW}The proxy environment requires being able to access secure resources at runtime.${NOCOLOR}\n"

gitRepo $REPO $DATADIR $DATADIR_REPO
updateHosts $DATADIR $DATADIR_REPO

if [ "$HOST" = true ]; then
updateHosts $DATADIR $DATADIR_REPO
exit 0
fi

runProxy $CONTAINER $CONTAINER_NAME $DOMAIN $PORT $CONFIG
}

0 comments on commit 8c2815a

Please sign in to comment.