Class: Chef::Knife::CfnValidate
- Inherits:
-
CfnBase
- Object
- Chef::Knife
- CfnBase
- Chef::Knife::CfnValidate
- Defined in:
- lib/chef/knife/cfn_validate.rb
Instance Method Summary collapse
Methods inherited from CfnBase
#connection, included, #is_image_windows?, #locate_config_value, #msg_pair, #validate!
Methods inherited from Chef::Knife
#create_create_def, #create_update_def, #iam_name_from_profile, #ini_parse
Instance Method Details
#create_validate_def ⇒ Object
105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/chef/knife/cfn_validate.rb', line 105 def create_validate_def validate_def = {} template_file = locate_config_value(:template_file) if template_file != nil and template_file != "" doc = File.open(template_file, 'rb') { |file| file.read } validate_def['TemplateBody'] = doc else validate_def['TemplateURL'] = locate_config_value(:template_url) end validate_def end |
#run ⇒ Object
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_validate.rb', line 84 def run $stdout.sync = true validate! begin response = connection.validate_template(create_validate_def) 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 print "\n#{ui.color("Template validated successfully", :green)}" end end |