Skip to content

Commit 911fa50

Browse files
Merge pull request #88 from tenjaa/master
Add multiple buildpacks to push command
2 parents 67dce6a + 69f8dc9 commit 911fa50

5 files changed

Lines changed: 60 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1010
### Added
1111

1212
- 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`
1314

1415
### Changed
1516

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -795,6 +795,7 @@ _NOTE_: A manifest can be used to specify values for required parameters. Any pa
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)
797797
- `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
798799
- `disk_quota`: _Optional._ Disk limit (e.g. 256M, 1024M, 1G)
799800
- `docker_image`: _Optional._ Docker-image to be used (e.g. user/docker-image-name)
800801
- `docker_username`: _Optional._ This is used as the username to authenticate against a protected docker registry

itest/run-app-push-tests

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,38 @@ it_can_push_an_app_with_stack() {
304304
assert::equals "$stack" "$(cf::get_app_stack "$app_name")"
305305
}
306306

307+
it_can_push_an_app_with_multiple_buildpacks() {
308+
local org=${1:?org null or not set}
309+
local space=${2:?space null or not set}
310+
local app_name=${3:?app_name null or not set}
311+
312+
local project=$(create_static_app "$app_name")
313+
314+
local params=$(jq -n \
315+
--arg org "$org" \
316+
--arg space "$space" \
317+
--arg app_name "$app_name" \
318+
--arg stack "$stack" \
319+
--arg path "$project/content" \
320+
--arg manifest "$project/manifest.yml" \
321+
'{
322+
command: "push",
323+
org: $org,
324+
space: $space,
325+
app_name: $app_name,
326+
path: $path,
327+
manifest: $manifest,
328+
buildpacks:
329+
- binary_buildpack
330+
- staticfile_buildpack
331+
}')
332+
333+
put_with_params "$CCR_SOURCE" "$params" | jq -e '.version | keys == ["timestamp"]'
334+
335+
assert::success cf::is_app_started "$app_name"
336+
assert::equals "binary_buildpack,staticfile_buildpack" "$(cf::get_app_buildpacks "$app_name")"
337+
}
338+
307339
org=$(generate_test_name_with_spaces "Org")
308340
space=$(generate_test_name_with_spaces "Space")
309341

@@ -383,4 +415,13 @@ describe "push an app with stack"
383415
run it_can_delete_an_app \"$org\" \"$space\" \"$app_name\"
384416
}
385417

418+
describe "push an app with multiple buildpacks"
419+
{
420+
app_name=$(generate_test_name_with_spaces "App")
421+
stack=cflinuxfs3
422+
423+
run it_can_push_an_app_with_stack \"$org\" \"$space\" \"$app_name\"
424+
run it_can_delete_an_app \"$org\" \"$space\" \"$app_name\"
425+
}
426+
386427
teardown_integration_tests "$org" "$space"

resource/commands/push.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11

22
app_name=$(get_option '.app_name')
33
buildpack=$(get_option '.buildpack')
4+
buildpacks=$(get_option '.buildpacks')
45
startup_command=$(get_option '.startup_command')
56
docker_image=$(get_option '.docker_image')
67
docker_username=$(get_option '.docker_username')
@@ -56,6 +57,10 @@ for key in $(echo $vars | jq -r 'keys[]'); do
5657
args+=(--var "$key=$value")
5758
done
5859

60+
for buildpack in $(echo $buildpacks | jq -r '.[]'); do
61+
args+=(-b "$buildpack")
62+
done
63+
5964
for vars_file in $(echo $vars_files | jq -r '.[]'); do
6065
args+=(--vars-file "$vars_file")
6166
done

resource/lib/cf-functions.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -824,6 +824,18 @@ function cf::get_app_stack() {
824824
echo $output | jq -r '.entity.name'
825825
}
826826

827+
function cf::get_app_buildpacks() {
828+
local app_name=${1:?app_name null or not set}
829+
830+
local output
831+
if ! output=$(cf::curl "/v2/apps/$(cf::get_app_guid "$app_name")/droplets/current"); then
832+
logger::error "$output"
833+
exit 1
834+
fi
835+
836+
echo $output | jq -r '.buildpacks | map(.name) | join(",")'
837+
}
838+
827839
function cf::scale() {
828840
local app_name=${1:?app_name null or not set}
829841
local instances=${2:-}

0 commit comments

Comments
 (0)