Skip to content

Commit 3d82ddd

Browse files
deprecate buildpack in favor of buildpacks on push command
1 parent 911fa50 commit 3d82ddd

5 files changed

Lines changed: 67 additions & 17 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
66
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
77

8-
## 2.XX.X - Unreleased
8+
## 2.22.0 - Unreleased
99

1010
### Added
1111

12-
- Introduced new tests (see `spec` folder) using the [shellspec](https://shellspec.info/) BDD testing framework. The existing home-grown test framework in the `itest` folder has served this project well, but it's time to move
13-
- `push` command now supports to specify multiple `buildpacks`
12+
- Introduced new tests (see `spec` folder) using the [shellspec](https://shellspec.info/) BDD testing framework. The existing home-grown test framework in the `itest` folder has served this project well, but it's time to move on to something better. Over the upcoming releases, we'll slowly start converting more of the `itest` tests to the newer `spec` tests.
13+
- `push` command now supports specifying multiple `buildpacks`, thanks to a PR by [tenjaa](https://github.com/tenjaa). The original `buildpack` option is now deprecated and superceded by `buildpacks`.
1414

1515
### Changed
1616

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -794,8 +794,8 @@ _NOTE_: A manifest can be used to specify values for required parameters. Any pa
794794
- `org`: _Optional._ The organization to target (required if not set in the source config)
795795
- `space`: _Optional._ The space to target (required if not set in the source config)
796796
- `app_name`: _Required._ The name of the application (_Optional_ if using a `manifest` that specifies the application name)
797-
- `buildpack`: _Optional._ Custom buildpack by name (e.g. my-buildpack) or Git URL (e.g. 'https://github.com/cloudfoundry/java-buildpack.git') or Git URL with a branch or tag (e.g. 'https://github.com/cloudfoundry/java-buildpack.git#v3.3.0' for 'v3.3.0' tag). To use built-in buildpacks only, specify 'default' or 'null'
798-
- `buildpacks`: _Optional._ Multiple buildpacks as an array
797+
- `buildpack`: _Optional._ _Deprecated_, please use `buildpacks` instead.
798+
- `buildpacks`: _Optional._ List of custom buildpacks by name (e.g. my-buildpack) or Git URL (e.g. 'https://github.com/cloudfoundry/java-buildpack.git') or Git URL with a branch or tag (e.g. 'https://github.com/cloudfoundry/java-buildpack.git#v3.3.0' for 'v3.3.0' tag). To use built-in buildpacks only, specify 'default' or 'null'
799799
- `disk_quota`: _Optional._ Disk limit (e.g. 256M, 1024M, 1G)
800800
- `docker_image`: _Optional._ Docker-image to be used (e.g. user/docker-image-name)
801801
- `docker_username`: _Optional._ This is used as the username to authenticate against a protected docker registry
@@ -833,7 +833,8 @@ _NOTE_: Enable these by specifying `cf_cli_version: 7` in the resource `source`
833833
app_name: myapp-ui
834834
memory: 1G
835835
path: path/to/myapp-*.jar
836-
buildpack: java_buildpack
836+
buildpacks:
837+
- java_buildpack
837838
manifest: path/to/manifest.yml
838839
vars:
839840
instances: 3

itest/run-app-push-tests

Lines changed: 47 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,6 @@ it_can_push_an_app_with_multiple_buildpacks() {
315315
--arg org "$org" \
316316
--arg space "$space" \
317317
--arg app_name "$app_name" \
318-
--arg stack "$stack" \
319318
--arg path "$project/content" \
320319
--arg manifest "$project/manifest.yml" \
321320
'{
@@ -325,9 +324,10 @@ it_can_push_an_app_with_multiple_buildpacks() {
325324
app_name: $app_name,
326325
path: $path,
327326
manifest: $manifest,
328-
buildpacks:
329-
- binary_buildpack
330-
- staticfile_buildpack
327+
buildpacks: [
328+
"binary_buildpack",
329+
"staticfile_buildpack"
330+
]
331331
}')
332332

333333
put_with_params "$CCR_SOURCE" "$params" | jq -e '.version | keys == ["timestamp"]'
@@ -336,6 +336,40 @@ it_can_push_an_app_with_multiple_buildpacks() {
336336
assert::equals "binary_buildpack,staticfile_buildpack" "$(cf::get_app_buildpacks "$app_name")"
337337
}
338338

339+
it_can_push_an_app_with_deprecated_buildpack_param() {
340+
local org=${1:?org null or not set}
341+
local space=${2:?space null or not set}
342+
local app_name=${3:?app_name null or not set}
343+
344+
local project=$(create_static_app "$app_name", "---
345+
applications:
346+
- name: $app_name
347+
memory: 64M
348+
disk_quota: 64M
349+
path: content")
350+
351+
local params=$(jq -n \
352+
--arg org "$org" \
353+
--arg space "$space" \
354+
--arg app_name "$app_name" \
355+
--arg path "$project/content" \
356+
--arg manifest "$project/manifest.yml" \
357+
'{
358+
command: "push",
359+
org: $org,
360+
space: $space,
361+
app_name: $app_name,
362+
path: $path,
363+
manifest: $manifest,
364+
buildpack: "staticfile_buildpack"
365+
}')
366+
367+
put_with_params "$CCR_SOURCE" "$params" | jq -e '.version | keys == ["timestamp"]'
368+
369+
assert::success cf::is_app_started "$app_name"
370+
assert::equals "staticfile_buildpack" "$(cf::get_app_buildpacks "$app_name")"
371+
}
372+
339373
org=$(generate_test_name_with_spaces "Org")
340374
space=$(generate_test_name_with_spaces "Space")
341375

@@ -418,9 +452,16 @@ describe "push an app with stack"
418452
describe "push an app with multiple buildpacks"
419453
{
420454
app_name=$(generate_test_name_with_spaces "App")
421-
stack=cflinuxfs3
422455

423-
run it_can_push_an_app_with_stack \"$org\" \"$space\" \"$app_name\"
456+
run it_can_push_an_app_with_multiple_buildpacks \"$org\" \"$space\" \"$app_name\"
457+
run it_can_delete_an_app \"$org\" \"$space\" \"$app_name\"
458+
}
459+
460+
describe "push an app with deprecated buildpack param"
461+
{
462+
app_name=$(generate_test_name_with_spaces "App")
463+
464+
run it_can_push_an_app_with_deprecated_buildpack_param \"$org\" \"$space\" \"$app_name\"
424465
run it_can_delete_an_app \"$org\" \"$space\" \"$app_name\"
425466
}
426467

resource/commands/push.sh

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
1+
json_array_push() {
2+
local array=${1:?array null or not set}
3+
local value=${2:-}
4+
if [ -n "$value" ]; then
5+
echo "$array" | jq --arg value "$value" '. + [ $value ]'
6+
else
7+
echo "$array"
8+
fi
9+
}
110

211
app_name=$(get_option '.app_name')
3-
buildpack=$(get_option '.buildpack')
4-
buildpacks=$(get_option '.buildpacks')
12+
# backwards compatibility for deprecated 'buildpack' param (https://github.com/nulldriver/cf-cli-resource/issues/87)
13+
buildpacks=$(get_option '.buildpacks' "$(json_array_push '[]' "$(get_option '.buildpack')")")
514
startup_command=$(get_option '.startup_command')
615
docker_image=$(get_option '.docker_image')
716
docker_username=$(get_option '.docker_username')
@@ -36,7 +45,6 @@ fi
3645

3746
args=()
3847
[ -n "$app_name" ] && args+=("$app_name")
39-
[ -n "$buildpack" ] && args+=(-b "$buildpack")
4048
[ -n "$startup_command" ] && args+=(-c "$startup_command")
4149
[ -n "$docker_image" ] && args+=(--docker-image "$docker_image")
4250
[ -n "$docker_username" ] && args+=(--docker-username "$docker_username")

resource/lib/cf-functions.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -828,12 +828,12 @@ function cf::get_app_buildpacks() {
828828
local app_name=${1:?app_name null or not set}
829829

830830
local output
831-
if ! output=$(cf::curl "/v2/apps/$(cf::get_app_guid "$app_name")/droplets/current"); then
831+
if ! output=$(cf::curl "/v3/apps/$(cf::get_app_guid "$app_name")"); then
832832
logger::error "$output"
833833
exit 1
834834
fi
835835

836-
echo $output | jq -r '.buildpacks | map(.name) | join(",")'
836+
echo $output | jq -r '.lifecycle | select(.type == "buildpack") | .data.buildpacks | join(",")'
837837
}
838838

839839
function cf::scale() {

0 commit comments

Comments
 (0)