Skip to content

Commit

Permalink
Customize failure messages
Browse files Browse the repository at this point in the history
  • Loading branch information
BanzaiMan committed May 22, 2018
1 parent ac77846 commit af50adb
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 13 deletions.
3 changes: 2 additions & 1 deletion lib/dpl/provider.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,10 @@ def self.context
end

def self.shell(command, options = {})
cmd_str = "#{command} " if options[:verbose]
system(command)
if !options[:assert] && !$?.success?
error "Command #{command} failed with status #{$?.exitstatus}"
error(options[:message] || "Command #{cmd_str}failed with status #{$?.exitstatus}")
end
end

Expand Down
5 changes: 2 additions & 3 deletions lib/dpl/provider/bluemix_cloud_foundry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,9 @@ def needs_key?
end

def push_app
error 'Failed to push app' unless context.shell("./cf push#{manifest}")

context.shell "./cf push#{manifest}", message: 'Failed to push app'
ensure
context.shell "./cf logout"
context.shell "./cf logout", assert: false
end

def cleanup
Expand Down
5 changes: 2 additions & 3 deletions lib/dpl/provider/cloud_foundry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@ def needs_key?
end

def push_app
error 'Failed to push app' unless context.shell("./cf push#{manifest}")

context.shell "./cf push#{manifest}", message: 'Failed to push app'
ensure
context.shell "./cf logout"
context.shell "./cf logout", assert: false
end

def cleanup
Expand Down
6 changes: 2 additions & 4 deletions lib/dpl/provider/deis.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module DPL
class Provider
class Deis < Provider

def install_deploy_dependencies
install_url = determine_install_url
context.shell "curl -sSL #{install_url} | bash -x -s #{option(:cli_version)}"
Expand Down Expand Up @@ -102,9 +102,7 @@ def controller_host
end

def push_app
unless context.shell "bash -c 'git push #{verbose_flag} #{repository_url} HEAD:refs/heads/master -f 2>&1 | tr -dc \"[:alnum:][:space:][:punct:]\" | sed -E \"s/remote: (\\[1G)+//\" | sed \"s/\\[K$//\"; exit ${PIPESTATUS[0]}'"
error 'Deploying application failed.'
end
context.shell "bash -c 'git push #{verbose_flag} #{repository_url} HEAD:refs/heads/master -f 2>&1 | tr -dc \"[:alnum:][:space:][:punct:]\" | sed -E \"s/remote: (\\[1G)+//\" | sed \"s/\\[K$//\"; exit ${PIPESTATUS[0]}'", message: 'Deploying application failed.'
end

def run(command)
Expand Down
3 changes: 1 addition & 2 deletions lib/dpl/provider/testfairy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,8 @@ def post url, params
puts res.body
resBody = JSON.parse(res.body)
if (resBody['status'] == 'fail')
raise Error, resBody['message']
error resBody['message']
end
return resBody
end

def get_printable_params params
Expand Down

0 comments on commit af50adb

Please sign in to comment.