Class: TerraformEnterprise::CommandLine::Commands::RunsCommand
- Inherits:
-
TerraformEnterprise::CommandLine::Command
- Object
- Thor
- TerraformEnterprise::CommandLine::Command
- TerraformEnterprise::CommandLine::Commands::RunsCommand
- Defined in:
- lib/terraform_enterprise/command_line/commands/runs.rb
Constant Summary collapse
- ATTR_STR =
STRINGS[:runs][:attributes]
- CMD_STR =
STRINGS[:runs][:commands]
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
32 33 34 35 36 |
# File 'lib/terraform_enterprise/command_line/commands/runs.rb', line 32 def apply(id) params = { id: id, action: :apply } params[:comment] = [:comment] if [:comment] render client.runs.action(params) end |
#create ⇒ Object
21 22 23 |
# File 'lib/terraform_enterprise/command_line/commands/runs.rb', line 21 def create render client.runs.create(), except: [:permissions] end |
#discard(id) ⇒ Object
40 41 42 43 44 |
# File 'lib/terraform_enterprise/command_line/commands/runs.rb', line 40 def discard(id) params = { id: id, action: :discard } params[:comment] = [:comment] if [:comment] render client.runs.action(params) end |
#get(id) ⇒ Object
26 27 28 |
# File 'lib/terraform_enterprise/command_line/commands/runs.rb', line 26 def get(id) render client.runs.get(id: id), except: [:permissions] end |
#list ⇒ Object
13 14 15 |
# File 'lib/terraform_enterprise/command_line/commands/runs.rb', line 13 def list render client.runs.list(id: [:workspace_id]), except: [:permissions] end |
#logs(id) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/terraform_enterprise/command_line/commands/runs.rb', line 49 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 |