Skip to content

Commit ffbdd6c

Browse files
authored
Merge pull request #12 from adreyer/BOLT-372
(BOLT-372) Add plan commands
2 parents 56db15e + fbd047e commit ffbdd6c

File tree

3 files changed

+28
-6
lines changed

3 files changed

+28
-6
lines changed

lib/orchestrator_client.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def post(location, body)
5555
req.body = body.to_json
5656
res = https.request(req)
5757

58-
if res.code != "202"
58+
unless Set.new(["202", "200"]).include? res.code
5959
raise OrchestratorClient::ApiError.make_error_from_response(res)
6060
end
6161

@@ -75,7 +75,12 @@ def new_job(options, type = :deploy)
7575
end
7676

7777
def run_task(options)
78-
job = OrchestratorClient::Job.new(self, options, :task)
78+
if options[:plan_job] || options['plan_job']
79+
type = :plan_task
80+
else
81+
type = :task
82+
end
83+
job = OrchestratorClient::Job.new(self, options, type)
7984
job.start
8085
job.wait
8186
job.nodes['items']

lib/orchestrator_client/command.rb

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,33 @@ def initialize(https)
44
@https = https
55
end
66

7-
def task(options = {})
7+
def deploy(options = {})
88
raise ArgumentError, 'Must pass options as a hash' unless options.is_a? Hash
9-
@https.post("command/task", options)
9+
@https.post("command/deploy", options)
1010
end
1111

12-
def deploy(options = {})
12+
def plan_start(options = {})
1313
raise ArgumentError, 'Must pass options as a hash' unless options.is_a? Hash
14-
@https.post("command/deploy", options)
14+
@https.post("command/plan_start", options)
15+
end
16+
17+
def plan_finish(options = {})
18+
raise ArgumentError, 'Must pass options as a hash' unless options.is_a? Hash
19+
@https.post("command/plan_finish", options)
20+
end
21+
22+
def plan_task(options = {})
23+
raise ArgumentError, 'Must pass options as a hash' unless options.is_a? Hash
24+
@https.post("command/plan_task", options)
1525
end
1626

1727
def stop(job_number)
1828
data = {"job" => "#{job_number}"}
1929
@https.post("command/stop",data)
2030
end
31+
32+
def task(options = {})
33+
raise ArgumentError, 'Must pass options as a hash' unless options.is_a? Hash
34+
@https.post("command/task", options)
35+
end
2136
end

lib/orchestrator_client/job.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ def start
2626
result = @client.command.deploy(options)
2727
when :task
2828
result = @client.command.task(options)
29+
when :plan_task
30+
result = @client.command.plan_task(options)
2931
end
3032

3133
@job_name = result['job']['name']

0 commit comments

Comments
 (0)