Class: Automan::Beanstalk::Uploader
- Inherits:
-
Automan::Base
- Object
- Automan::Base
- Automan::Beanstalk::Uploader
- Defined in:
- lib/automan/beanstalk/uploader.rb
Constant Summary
Constants included from Mixins::AwsCaller
Instance Attribute Summary
Attributes inherited from Automan::Base
Attributes included from Mixins::AwsCaller
#as, #cfn, #eb, #ec, #ec2, #elb, #r53, #rds, #s3
Instance Method Summary collapse
- #config_templates ⇒ Object
- #config_templates_valid? ⇒ Boolean
- #read_config_template(file) ⇒ Object
- #upload_config_templates ⇒ Object
- #upload_file(file) ⇒ Object
Methods inherited from Automan::Base
add_option, #initialize, #log_options, #wait_until
Methods included from Mixins::AwsCaller
#account, #configure_aws, #looks_like_s3_path?, #parse_s3_path, #s3_object_exists?, #s3_read
Constructor Details
This class inherits a constructor from Automan::Base
Instance Method Details
#config_templates ⇒ Object
8 9 10 |
# File 'lib/automan/beanstalk/uploader.rb', line 8 def config_templates Dir.glob template_files end |
#config_templates_valid? ⇒ Boolean
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/automan/beanstalk/uploader.rb', line 16 def config_templates_valid? valid = true templates = config_templates if templates.empty? raise NoConfigurationTemplatesError, "No configuration template files found for #{template_files}" end templates.each do |template| raw = read_config_template template begin JSON.parse(raw) rescue Exception => e logger.warn "#{template} is invalid json: #{e.}" valid = false next end logger.debug "#{template} is valid json" end valid end |
#read_config_template(file) ⇒ Object
12 13 14 |
# File 'lib/automan/beanstalk/uploader.rb', line 12 def read_config_template(file) File.read file end |
#upload_config_templates ⇒ Object
48 49 50 51 52 53 54 55 56 |
# File 'lib/automan/beanstalk/uploader.rb', line 48 def upload_config_templates unless config_templates_valid? raise InvalidConfigurationTemplateError, "There are invalid configuration templates. Halting upload." end config_templates.each do |template| upload_file(template) end end |