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, #locate_config_value, #msg_pair, #validate!
Methods inherited from Chef::Knife
#create_create_def, #create_update_def
Instance Method Details
#create_validate_def ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/chef/knife/cfn_validate.rb', line 66 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
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/chef/knife/cfn_validate.rb', line 45 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 |