Skip to content

Commit cf891fb

Browse files
committed
Handle colon-delimited environmentpath in config_version.sh
1 parent 458877f commit cf891fb

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

Diff for: scripts/config_version.sh

+16-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
11
#!/bin/sh
22

3+
ENVIRONMENTPATH=$1
4+
# $ENVIRONMENTPATH may contain multiple colon-delimited locations.
5+
# We need to pick the first one that contains $ENVIRONMENT.
6+
IFS=":"
7+
for CANDIDATEPATH in ${ENVIRONMENTPATH}; do
8+
if [ -d "${CANDIDATEPATH}/${2}" ]; then
9+
ENVIRONMENTPATH=$CANDIDATEPATH
10+
break
11+
fi
12+
done
13+
314
# Usage
4-
if [ $# -ne 2 -o ! -d "$1" -o ! -d "$1/$2" ]; then
15+
if [ $# -ne 2 -o ! -d "${ENVIRONMENTPATH}" -o ! -d "${ENVIRONMENTPATH}/$2" ]; then
516
echo "usage: $0 <environmentpath> <environment>" >&2
617
exit 1
718
fi
@@ -14,19 +25,19 @@ ruby() {
1425
}
1526

1627
# Determine how best to calculate a config_version
17-
if [ -e $1/$2/.r10k-deploy.json ]; then
28+
if [ -e ${ENVIRONMENTPATH}/$2/.r10k-deploy.json ]; then
1829
# The environment was deployed using r10k. We will calculate the config
1930
# version using the r10k data.
20-
ruby $1/$2/scripts/config_version-r10k.rb $1 $2
31+
ruby ${ENVIRONMENTPATH}/$2/scripts/config_version-r10k.rb $1 $2
2132

2233
elif [ -e /opt/puppetlabs/server/pe_version ]; then
2334
# This is a Puppet Enterprise system and we can rely on the rugged ruby gem
2435
# being available.
25-
ruby $1/$2/scripts/config_version-rugged.rb $1 $2
36+
ruby ${ENVIRONMENTPATH}/$2/scripts/config_version-rugged.rb $1 $2
2637

2738
elif type git >/dev/null; then
2839
# The git command is available.
29-
git --git-dir $1/$2/.git rev-parse HEAD
40+
git --git-dir ${ENVIRONMENTPATH}/$2/.git rev-parse HEAD
3041

3142
else
3243
# Nothing else available; just use the date.

0 commit comments

Comments
 (0)