-
Notifications
You must be signed in to change notification settings - Fork 4
/
bake
executable file
·128 lines (108 loc) · 3.55 KB
/
bake
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
#!/usr/bin/env bash
set -eu
cwd="$(cd "$(dirname "${0}")" && pwd)"
VERSION="1.0.0"
STEMCELL_VERSION="170.16"
WORKSPACE="${WORKSPACE:-"$HOME/workspace"}"
RELEASES_DIR="$cwd/releases"
SKIP_RELEASES_BUILDING=true
ODB_DIR="$WORKSPACE/on-demand-service-broker-release"
BUILD_RELEASES_FROM_SOURCE=true
usage() {
cat <<EndOfUsage
Usage: $0 [flags]
Flags:
--tile-version, -v Desired tile version. Ex: 1.0.0
--stemcell-version, -s Target stemcell version. Ex: 3415.12
--releases-directory, -r Optional. Path to a directory containing the necessary releases
--odb-release-dir,-d Optional. Path to the ODB release directory. Defaults to "$ODB_DIR"
--help, -f Show help
EndOfUsage
exit 0
}
parse_opts() {
for arg in "$@"; do
shift
case "$arg" in
"--tile-version") set -- "$@" "-v" ;;
"--stemcell-version") set -- "$@" "-s" ;;
"--releases-directory") set -- "$@" "-r" ;;
"--odb-release-dir") set -- "$@" "-d" ;;
"--help") set -- "$@" "-h" ;;
*) set -- "$@" "$arg"
esac
done
OPTIND=1
while getopts "v:r:s:d:h" opt; do
case $opt in
v) VERSION="$OPTARG" ;;
r) RELEASES_DIR="$OPTARG"; BUILD_RELEASES_FROM_SOURCE=false ;;
s) STEMCELL_VERSION="$OPTARG" ;;
d) ODB_DIR="$OPTARG" ;;
h) usage ;;
*) exit 1 ;;
esac
done
shift $(( OPTIND - 1 ))
}
create_releases() {
rm -f releases/*
echo "Creating ODB release"
bosh create-release \
--name on-demand-service-broker \
--force \
--tarball "$cwd/releases/on-demand-service-broker.tgz" \
--dir="$ODB_DIR"
echo "Creating Kafka service adapter release"
bosh create-release \
--name kafka-example-service-adapter \
--force \
--tarball "$cwd/releases/kafka-example-service-adapter.tgz" \
--dir="$ODB_DIR/examples/kafka-example-service-adapter-release"
echo "Creating Kafka service release"
bosh create-release \
--name kafka-example-service \
--force \
--tarball "$cwd/releases/kafka-example-service.tgz" \
--dir="$ODB_DIR/examples/kafka-example-service-release"
echo "Downloading Consul"
curl -L -s "https://bosh.io/d/github.com/cloudfoundry-incubator/consul-release?v=192"\
-o "$cwd/releases/consul.tgz"
echo "Downlading BPM"
curl -L -s "https://github.com/cloudfoundry/bpm-release/releases/download/v1.1.0/bpm-release-1.1.0.tgz" \
-o "$cwd/releases/bpm.tgz"
}
download_stemcell() {
echo "Downloading stemcell version $STEMCELL_VERSION"
rm -f "$cwd/stemcells/stemcell/tgz"
curl -L -s "https://s3.amazonaws.com/bosh-gce-light-stemcells/light-bosh-stemcell-$STEMCELL_VERSION-google-kvm-ubuntu-xenial-go_agent.tgz" \
-o "$cwd/stemcells/stemcell.tgz"
}
main() {
parse_opts "$@"
if ! type kiln >/dev/null 2>/dev/null; then
go get github.com/pivotal-cf/kiln
fi
if [[ ! -d "$ODB_DIR" ]]; then
echo "Cannot find on-demand-service-broker-release in $WORKSPACE"
exit 1
fi
download_stemcell
if $BUILD_RELEASES_FROM_SOURCE; then
create_releases
fi
kiln bake \
--version "$VERSION" \
--metadata "$cwd/base.yml" \
--releases-directory "$RELEASES_DIR" \
--stemcell-tarball "$cwd/stemcells/stemcell.tgz" \
--properties-directory "$cwd/properties" \
--migrations-directory "$cwd/migrations" \
--forms-directory "$cwd/forms" \
--instance-groups-directory "$cwd/instance-groups" \
--jobs-directory "$cwd/jobs" \
--icon "$cwd/icon.png" \
--variables-file "$cwd/variables.yml" \
--output-file "$cwd/example-kafka-odb-tile-$VERSION.pivotal"
}
main "$@"