Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions lib/orchestrator_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def post(location, body)
req.body = body.to_json
res = https.request(req)

if res.code != "202"
unless Set.new(["202", "200"]).include? res.code
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using a one-time set here brings no actual benefit.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the other ruby way to do this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh for some reason I thought arrays responded to include based on their indexes

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

raise OrchestratorClient::ApiError.make_error_from_response(res)
end

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

def run_task(options)
job = OrchestratorClient::Job.new(self, options, :task)
if options[:plan_job] || options['plan_job']
type = :plan_task
else
type = :task
end
job = OrchestratorClient::Job.new(self, options, type)
job.start
job.wait
job.nodes['items']
Expand Down
23 changes: 19 additions & 4 deletions lib/orchestrator_client/command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,33 @@ def initialize(https)
@https = https
end

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

def deploy(options = {})
def plan_start(options = {})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When will plan_start/plan_finish be used? Or how are they exposed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

client.command.plan_start

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤷‍♂️

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bolt will call it directly in other words. The orchestrator transport is informed that a plan is running before the plan starts. It then calls start plan on the client before running any tasks. finish_task is called after the plan finishes and orchestrator calls finish_task on any clients that were used during the plan.

raise ArgumentError, 'Must pass options as a hash' unless options.is_a? Hash
@https.post("command/deploy", options)
@https.post("command/plan_start", options)
end

def plan_finish(options = {})
raise ArgumentError, 'Must pass options as a hash' unless options.is_a? Hash
@https.post("command/plan_finish", options)
end

def plan_task(options = {})
raise ArgumentError, 'Must pass options as a hash' unless options.is_a? Hash
@https.post("command/plan_task", options)
end

def stop(job_number)
data = {"job" => "#{job_number}"}
@https.post("command/stop",data)
end

def task(options = {})
raise ArgumentError, 'Must pass options as a hash' unless options.is_a? Hash
@https.post("command/task", options)
end
end
2 changes: 2 additions & 0 deletions lib/orchestrator_client/job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ def start
result = @client.command.deploy(options)
when :task
result = @client.command.task(options)
when :plan_task
result = @client.command.plan_task(options)
end

@job_name = result['job']['name']
Expand Down