Skip to content

Commit

Permalink
Merge pull request #20 from opscode/ssd/cleanup-errors
Browse files Browse the repository at this point in the history
Sanity check arguments to provide better error messages.
  • Loading branch information
jkeiser committed Jun 25, 2014
2 parents abda5d3 + 5aed637 commit 6329f72
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions lib/chef/knife/job_start.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ class JobStart < Chef::Knife

def run
@node_names = []

job_name = @name_args[0]
if job_name.nil?
ui.error "No job specified."
show_usage
exit 1
end

if config[:search]
q = Chef::Search::Query.new
@escaped_query = URI.escape(config[:search],
Expand All @@ -61,10 +69,15 @@ def run
@node_names = name_args[1,name_args.length-1]
end

if @node_names.empty?
ui.error "No nodes to run job on. Specify nodes as arguments or use -s to specify a search query."
exit 1
end

rest = Chef::REST.new(Chef::Config[:chef_server_url])

job_json = {
'command' => name_args[0],
'command' => job_name,
'nodes' => @node_names,
'quorum' => get_quorum(config[:quorum], @node_names.length)
}
Expand Down Expand Up @@ -138,4 +151,3 @@ def status_code(job)
end
end
end

0 comments on commit 6329f72

Please sign in to comment.