Class: EPC::Command::AttachRuntimeCommand

Inherits:
BaseCommand show all
Defined in:
lib/epc/command/attach_runtime_command.rb

Constant Summary

Constants inherited from BaseCommand

BaseCommand::GIVEUP_TICKS, BaseCommand::SLEEP_TIME, BaseCommand::TICKER_TICKS

Instance Attribute Summary

Attributes inherited from BaseCommand

#client, #options

Instance Method Summary collapse

Methods inherited from BaseCommand

#go, inherited, #initialize, required_options

Methods included from PersistentAttributes

#auth_token, #caller_id, #target_url

Constructor Details

This class inherits a constructor from EPC::Command::BaseCommand

Instance Method Details

#execute(runtime = nil) ⇒ Object

Raises:



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/epc/command/attach_runtime_command.rb', line 5

def execute(runtime = nil)

  path = File.expand_path(".")

  solution_id, solution_name = infer_solution_context(@options[:solution_name], path) 
  project_id, project_name = infer_project_context(@options[:project_name], path, solution_id)

  raise InputError, "Project could not be inferred" if project_id.nil?

  status, response, headers = client.put(EPC::Config::PROJECTS_PATH + "/#{project_id}/set_runtime_env", {:runtime_env_id => runtime, :stage_name => @options[:stage]})

  if status.successful?
    say("Runtime attached")
  else
    say("Request failed: [#{response[:message]}]")
  end

  return status

end