Class: TerraformEnterprise::CommandLine::RunsCommand
- Defined in:
- lib/terraform_enterprise/command_line/commands/runs.rb
Constant Summary collapse
Constants included from TerraformEnterprise::CommandLine
Instance Method Summary collapse
- #apply(id) ⇒ Object
- #create ⇒ Object
- #discard(id) ⇒ Object
- #get(id) ⇒ Object
- #list ⇒ Object
- #logs(id) ⇒ Object
Methods included from Util::Tar
Instance Method Details
#apply(id) ⇒ Object
31 32 33 34 35 |
# File 'lib/terraform_enterprise/command_line/commands/runs.rb', line 31 def apply(id) params = { id: id, action: :apply } params[:comment] = [:comment] if [:comment] render client.runs.action(params) end |
#create ⇒ Object
20 21 22 |
# File 'lib/terraform_enterprise/command_line/commands/runs.rb', line 20 def create render client.runs.create(), except: [:permissions] end |
#discard(id) ⇒ Object
39 40 41 42 43 |
# File 'lib/terraform_enterprise/command_line/commands/runs.rb', line 39 def discard(id) params = { id: id, action: :discard } params[:comment] = [:comment] if [:comment] render client.runs.action(params) end |
#get(id) ⇒ Object
25 26 27 |
# File 'lib/terraform_enterprise/command_line/commands/runs.rb', line 25 def get(id) render client.runs.get(id: id), except: [:permissions] end |
#list ⇒ Object
12 13 14 |
# File 'lib/terraform_enterprise/command_line/commands/runs.rb', line 12 def list render client.runs.list(id: [:workspace_id]), except: [:permissions] end |
#logs(id) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/terraform_enterprise/command_line/commands/runs.rb', line 48 def logs(id) following = [:follow] finished = false exit_requested = false finished_states = %w[errored canceled finished] # Listens for "control-c" to exit Kernel.trap('INT') { exit_requested = true } loop do event = get_event_resource(id, [:event]) url = event.attributes['log-read-url'] finished = finished_states.include?(event.attributes['status'].to_s) logs = RestClient.get(url).body # errase screen and go to (0,0) print "\033[2J" if following print logs break if !following || exit_requested || finished sleep 2 end end |