Class: Chef::Knife::CfnOutputs
- Inherits:
-
CfnBase
- Object
- Chef::Knife
- CfnBase
- Chef::Knife::CfnOutputs
- Defined in:
- lib/chef/knife/cfn_outputs.rb
Instance Method Summary collapse
Methods inherited from CfnBase
#connection, included, #locate_config_value, #msg_pair, #validate!
Methods inherited from Chef::Knife
#create_create_def, #create_update_def
Instance Method Details
#run ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/chef/knife/cfn_outputs.rb', line 38 def run $stdout.sync = true validate! stack_name = @name_args[0] if stack_name.nil? show_usage ui.error("You must specify a stack name") exit 1 end events_list = [ ui.color("Stack", :bold), ui.color('Output Key', :bold), ui.color('Output Value', :bold), ui.color('Description', :bold) ] @name_args.each do |stack_name| = {} ["StackName"] = stack_name data = Array.new begin response = connection.describe_stacks() data = response.body["Stacks"] rescue Excon::Errors::BadRequest => e i= e.response.body.index("<Message>") j = e.response.body.index("</Message>") if !i.nil? and !j.nil? ui.error(e.response.body[i+9,j-i-9]) else print "\n#{e.response.body}" end exit 1 else parameter_output="" delim="" data.each do |stack| row1 = true parameter_output += delim delim="\n" parameter_output+=stack["StackName"] + ": " events_list << stack["StackName"] stack["Outputs"].each do |output| if !row1 events_list << "" parameter_output += ";" end events_list << output["OutputKey"] events_list << output["OutputValue"] events_list << output["Description"] parameter_output += output["OutputKey"] + "=" + output["OutputValue"] row1 = false end end if locate_config_value(:output_format) == "parameter" puts parameter_output else puts ui.list(events_list, :uneven_columns_across, 4) end end end end |