mirror of
https://github.com/dokku/dokku.git
synced 2026-02-24 04:00:36 +01:00
fix: correct issue where removing by index failed due to incorrect input validation
Closes #6657
This commit is contained in:
@@ -44,7 +44,7 @@ func rewriteBuildpacksFile(sourceWorkDir string) error {
|
||||
|
||||
func validBuildpackURL(buildpack string) (string, error) {
|
||||
if buildpack == "" {
|
||||
return buildpack, errors.New("Must specify a buildpack to add")
|
||||
return buildpack, errors.New("Must specify a buildpack url or reference")
|
||||
}
|
||||
|
||||
reHerokuValue := regexp.MustCompile(`(?m)^([\w-]+\/[\w-]+)$`)
|
||||
|
||||
@@ -65,7 +65,7 @@ func CommandRemove(appName string, buildpack string, index int) (err error) {
|
||||
}
|
||||
|
||||
buildpack, err = validBuildpackURL(buildpack)
|
||||
if err != nil {
|
||||
if index == 0 && err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -205,7 +205,7 @@ teardown() {
|
||||
run /bin/bash -c "dokku --quiet buildpacks:list $TEST_APP | xargs"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_output_contains "https://github.com/heroku/heroku-buildpack-nodejs.git https://github.com/heroku/heroku-buildpack-ruby.git"
|
||||
assert_output "https://github.com/heroku/heroku-buildpack-nodejs.git https://github.com/heroku/heroku-buildpack-ruby.git"
|
||||
|
||||
run /bin/bash -c "dokku buildpacks:remove $TEST_APP heroku/nodejs"
|
||||
echo "output: $output"
|
||||
@@ -215,7 +215,7 @@ teardown() {
|
||||
run /bin/bash -c "dokku --quiet buildpacks:list $TEST_APP | xargs"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_output_contains "https://github.com/heroku/heroku-buildpack-ruby.git"
|
||||
assert_output "https://github.com/heroku/heroku-buildpack-ruby.git"
|
||||
|
||||
run /bin/bash -c "dokku buildpacks:remove $TEST_APP heroku/php"
|
||||
echo "output: $output"
|
||||
@@ -231,6 +231,36 @@ teardown() {
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_output_not_exists
|
||||
|
||||
run /bin/bash -c "dokku buildpacks:add $TEST_APP https://github.com/heroku/heroku-buildpack-nodejs.git"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run /bin/bash -c "dokku buildpacks:add $TEST_APP https://github.com/heroku/heroku-buildpack-ruby.git"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run /bin/bash -c "dokku buildpacks:add $TEST_APP https://github.com/yespark/heroku-imagemagick-buildpack"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run /bin/bash -c "dokku --quiet buildpacks:list $TEST_APP | xargs"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_output "https://github.com/heroku/heroku-buildpack-nodejs.git https://github.com/heroku/heroku-buildpack-ruby.git https://github.com/yespark/heroku-imagemagick-buildpack"
|
||||
|
||||
run /bin/bash -c "dokku buildpacks:remove $TEST_APP --index 1"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_success
|
||||
|
||||
run /bin/bash -c "dokku --quiet buildpacks:list $TEST_APP | xargs"
|
||||
echo "output: $output"
|
||||
echo "status: $status"
|
||||
assert_output "https://github.com/heroku/heroku-buildpack-ruby.git https://github.com/yespark/heroku-imagemagick-buildpack"
|
||||
}
|
||||
|
||||
@test "(buildpacks) buildpacks:clear" {
|
||||
|
||||
Reference in New Issue
Block a user