-
Notifications
You must be signed in to change notification settings - Fork 0
/
tile-template.yml
242 lines (204 loc) · 7.78 KB
/
tile-template.yml
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
name: newrelic-pcf-nginx-buildpack
version: {{ version }}
metadata_version: 2.0
label: New Relic Nginx Buildpack for Tanzu
description: New Relic Nginx Integration Buildpack for VMware Tanzu
icon_file: resources/images/NR_logo.png
stemcell_criteria:
os: 'ubuntu-jammy'
version: '1.181'
forms:
- name: buildpack-selection-properties
label: New Relic Buildpack Selection
description: Select which buildpack extensions to install
properties:
# --------------------------------------------------------
# cflinuxfs4
- name: install_newrelic_nginx_buildpack_cflinuxfs4
type: boolean
label: Nginx Extension (cflinuxfs4)?
configurable: true
default: true
description: Install New Relic Nginx Extension Buildpack for cflinuxfs4 (y/n)
# cflinuxfs3
- name: install_newrelic_nginx_buildpack_cflinuxfs3
type: boolean
label: Nginx Extension (cflinuxfs3)?
configurable: true
default: true
description: Install New Relic Nginx Extension Buildpack for cflinuxfs3 (y/n)
packages:
# nginx extension - cflinuxfs4
- name: newrelic_nginx_buildpack_cflinuxfs4
buildpack_order: 32
type: buildpack
label: New Relic Nginx Extension Buildpack for cflinuxfs4
path: './build/newrelic_nginx_buildpack-{{ cached_suffix }}-cflinuxfs4-v{{ version }}.zip'
pre_deploy: |
function delete_nr_anystack_buildpacks() {
$CF buildpacks | egrep -w "^newrelic_nginx_buildpack(_cached)?" | awk '
NF == 5 { system("cf delete-buildpack -f " $1) }
'
}
function remove_buildpack() {
BP_NAME=${1}
export BP_STACK=${2}
echo "removing buildpack ${BP_NAME} stack ${BP_STACK} if it exists..."
$CF buildpacks | grep -w "^${BP_NAME}" | awk '
( NF == 6 && $6 == ENVIRON["BP_STACK"] ) {
system("cf delete-buildpack -f " $1 " -s " $6)
if (retval == 0) {
printf("bp %s - stack %s removed.\n", $1, $6)
}
}
'
}
function rename_anystack_buildpack() {
BP_NAME=${1}
# if buildpack without stack is found rename it
echo "searching for ${BP_NAME} for any-stack buildpacks and renaming them if any exists..."
$CF buildpacks | grep -w "^${BP_NAME}" | awk '
NF == 5 {
newBuildpackName = sprintf("%s_any_stack", $1)
system("cf rename-buildpack " $1 " " newBuildpackName)
}
'
}
function add_buildpack() {
BP_NAME=${1}
BP_FILE=${2}
BP_ORDER=${3}
BP_STACK=${4}
$CF buildpacks | grep -w "^${BP_NAME}" | grep -w " ${STACK}" >/dev/null
if [ "$?" -eq "0" ]; then
echo "updating buildpack ${BP_NAME} stack ${BP_STACK}..."
$CF update-buildpack ${BP_NAME} -p ${BP_FILE} -s ${STACK} --enable
else
echo "creating buildpack ${BP_NAME} stack ${BP_STACK}..."
$CF create-buildpack ${BP_NAME} ${BP_FILE} ${BP_ORDER} --enable
fi
}
### --------------------------------------------------
post_deploy: |
output=`$CF apps | tail -1`
if [ "$output" == "No apps found" ]; then
cf delete-space -f $CF_SPACE
fi
output=`$CF spaces | tail -1`
if [ "$output" == "No spaces found" ]; then
cf delete-org -f $CF_ORG
fi
### --------------------------------------------------
deploy: |
# clean up any NR buildpacks with no stacks
delete_nr_anystack_buildpacks
BUILDPACK_NAME="newrelic_nginx_buildpack"
STACK=cflinuxfs4
if [ ${INSTALL_NEWRELIC_NGINX_BUILDPACK_CFLINUXFS4} == true ]
then
BUILDPACK_ORDER=<%= Shellwords.escape properties.newrelic_nginx_buildpack_cflinuxfs4.buildpack_order %>
PKG_NAME=<%= Shellwords.escape properties.newrelic_nginx_buildpack_cflinuxfs4.name %>
BUILDPACK_FILE=${PACKAGE_PATH}/${PKG_NAME}/newrelic_nginx_buildpack-{{ cached_suffix }}-cflinuxfs4-v{{ version }}.zip
#----
echo "PKG_NAME: ${PKG_NAME}"
echo "BUILDPACK_NAME: ${BUILDPACK_NAME}"
echo "BUILDPACK_ORDER: ${BUILDPACK_ORDER}"
echo "BUILDPACK_FILE: ${BUILDPACK_FILE}"
echo "STACK: ${STACK}"
#--------
add_buildpack ${BUILDPACK_NAME} ${BUILDPACK_FILE} ${BUILDPACK_ORDER} ${STACK}
else
remove_buildpack ${BUILDPACK_NAME} ${STACK}
fi
### --------------------------------------------------
delete: |
### delete the buildpacks
cf delete-buildpack -f newrelic_nginx_buildpack -s cflinuxfs4
### --------------------------------------------------
# nginx extension - cflinuxfs3
- name: newrelic_nginx_buildpack_cflinuxfs3
buildpack_order: 31
type: buildpack
label: New Relic Nginx Extension Buildpack for cflinuxfs3
path: './build/newrelic_nginx_buildpack-{{ cached_suffix }}-cflinuxfs3-v{{ version }}.zip'
pre_deploy: |
function delete_nr_anystack_buildpacks() {
$CF buildpacks | egrep -w "^newrelic_nginx_buildpack(_cached)?" | awk '
NF == 5 { system("cf delete-buildpack -f " $1) }
'
}
function remove_buildpack() {
BP_NAME=${1}
export BP_STACK=${2}
echo "removing buildpack ${BP_NAME} stack ${BP_STACK} if it exists..."
$CF buildpacks | grep -w "^${BP_NAME}" | awk '
( NF == 6 && $6 == ENVIRON["BP_STACK"] ) {
system("cf delete-buildpack -f " $1 " -s " $6)
if (retval == 0) {
printf("bp %s - stack %s removed.\n", $1, $6)
}
}
'
}
function rename_anystack_buildpack() {
BP_NAME=${1}
# if buildpack without stack is found rename it
echo "searching for ${BP_NAME} for any-stack buildpacks and renaming them if any exists..."
$CF buildpacks | grep -w "^${BP_NAME}" | awk '
NF == 5 {
newBuildpackName = sprintf("%s_any_stack", $1)
system("cf rename-buildpack " $1 " " newBuildpackName)
}
'
}
function add_buildpack() {
BP_NAME=${1}
BP_FILE=${2}
BP_ORDER=${3}
BP_STACK=${4}
$CF buildpacks | grep -w "^${BP_NAME}" | grep -w " ${STACK}" >/dev/null
if [ "$?" -eq "0" ]; then
echo "updating buildpack ${BP_NAME} stack ${BP_STACK}..."
$CF update-buildpack ${BP_NAME} -p ${BP_FILE} -s ${STACK} --enable
else
echo "creating buildpack ${BP_NAME} stack ${BP_STACK}..."
$CF create-buildpack ${BP_NAME} ${BP_FILE} ${BP_ORDER} --enable
fi
}
### --------------------------------------------------
post_deploy: |
output=`$CF apps | tail -1`
if [ "$output" == "No apps found" ]; then
cf delete-space -f $CF_SPACE
fi
output=`$CF spaces | tail -1`
if [ "$output" == "No spaces found" ]; then
cf delete-org -f $CF_ORG
fi
### --------------------------------------------------
deploy: |
# clean up any NR buildpacks with no stacks
delete_nr_anystack_buildpacks
BUILDPACK_NAME="newrelic_nginx_buildpack"
STACK=cflinuxfs3
if [ ${INSTALL_NEWRELIC_NGINX_BUILDPACK_CFLINUXFS3} == true ]
then
BUILDPACK_ORDER=<%= Shellwords.escape properties.newrelic_nginx_buildpack_cflinuxfs3.buildpack_order %>
PKG_NAME=<%= Shellwords.escape properties.newrelic_nginx_buildpack_cflinuxfs3.name %>
BUILDPACK_FILE=${PACKAGE_PATH}/${PKG_NAME}/newrelic_nginx_buildpack-{{ cached_suffix }}-cflinuxfs3-v{{ version }}.zip
#----
echo "PKG_NAME: ${PKG_NAME}"
echo "BUILDPACK_NAME: ${BUILDPACK_NAME}"
echo "BUILDPACK_ORDER: ${BUILDPACK_ORDER}"
echo "BUILDPACK_FILE: ${BUILDPACK_FILE}"
echo "STACK: ${STACK}"
#--------
add_buildpack ${BUILDPACK_NAME} ${BUILDPACK_FILE} ${BUILDPACK_ORDER} ${STACK}
else
remove_buildpack ${BUILDPACK_NAME} ${STACK}
fi
### --------------------------------------------------
delete: |
### delete the buildpacks
cf delete-buildpack -f newrelic_nginx_buildpack -s cflinuxfs3
### --------------------------------------------------