forked from alphagov/verify-stub-idp
-
Notifications
You must be signed in to change notification settings - Fork 1
/
login_to_paas.sh
executable file
·26 lines (21 loc) · 970 Bytes
/
login_to_paas.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
#!/usr/bin/env bash
set -e
ROOT_DIR="$1"
cfLogin() {
if [ -z "${CF_USER:-}" ]; then
echo "Using cached credentials in ${CF_HOME:-home directory}" >&2
else
CF_API="${CF_API:?CF_USER is set - CF_API environment variable also needs to be set}"
CF_ORG="${CF_ORG:?CF_USER is set - CF_ORG environment variable also needs to be set}"
CF_SPACE="${CF_SPACE:?CF_USER is set - CF_SPACE environment variable also needs to be set}"
CF_PASS="${CF_PASS:?CF_USER is set - CF_PASS environment variable also needs to be set}"
# CloudFoundry will cache credentials in ~/.cf/config.json by default.
# Create a dedicated work area to avoid contaminating the user's credential cache
export CF_HOME="$ROOT_DIR/work"
rm -rf "$CF_HOME"
mkdir -p "$CF_HOME"
echo "Authenticating to CloudFoundry at '$CF_API' ($CF_ORG/$CF_SPACE) as '$CF_USER'" >&2
cf login -a "$CF_API" -u "$CF_USER" -o "$CF_ORG" -s "$CF_SPACE" -p "$CF_PASS"
fi
}
cfLogin