Class: InstanceAgent::Plugins::CodeDeployPlugin::Installer
- Inherits:
-
Object
- Object
- InstanceAgent::Plugins::CodeDeployPlugin::Installer
- Defined in:
- lib/instance_agent/plugins/codedeploy/installer.rb
Overview
Manages install and cleanup files. Also generates and executes install instructions based on the files section of the application specification file.
Instance Attribute Summary collapse
-
#deployment_archive_dir ⇒ Object
readonly
Returns the value of attribute deployment_archive_dir.
-
#deployment_instructions_dir ⇒ Object
readonly
Returns the value of attribute deployment_instructions_dir.
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ Installer
constructor
A new instance of Installer.
- #install(deployment_group_id, application_specification) ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ Installer
Returns a new instance of Installer.
11 12 13 14 15 16 17 18 19 |
# File 'lib/instance_agent/plugins/codedeploy/installer.rb', line 11 def initialize(opts = {}) raise "the deployment_archive_dir option is required" if opts[:deployment_archive_dir].nil? raise "the deployment_instructions_dir option is required" if opts[:deployment_instructions_dir].nil? @deployment_archive_dir = opts[:deployment_archive_dir] @deployment_instructions_dir = opts[:deployment_instructions_dir] end |
Instance Attribute Details
#deployment_archive_dir ⇒ Object (readonly)
Returns the value of attribute deployment_archive_dir.
9 10 11 |
# File 'lib/instance_agent/plugins/codedeploy/installer.rb', line 9 def deployment_archive_dir @deployment_archive_dir end |
#deployment_instructions_dir ⇒ Object (readonly)
Returns the value of attribute deployment_instructions_dir.
10 11 12 |
# File 'lib/instance_agent/plugins/codedeploy/installer.rb', line 10 def deployment_instructions_dir @deployment_instructions_dir end |
Instance Method Details
#install(deployment_group_id, application_specification) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/instance_agent/plugins/codedeploy/installer.rb', line 21 def install(deployment_group_id, application_specification) cleanup_file = File.join(deployment_instructions_dir, "#{deployment_group_id}-cleanup") if File.exists?(cleanup_file) commands = InstallInstruction.parse_remove_commands(File.read(cleanup_file)) commands.each do |cmd| cmd.execute end commands.clear FileUtils.rm(cleanup_file) end instructions = generate_instructions(application_specification) install_file = File.join(deployment_instructions_dir, "#{deployment_group_id}-install.json") File.open(install_file, "w") do |f| f.write(instructions.to_json) end File.open(cleanup_file, "w") do |f| instructions.command_array.each do |cmd| cmd.execute(f) end end #Unlink references to the CommandBuilder instance that was yielded to the Proc object(code block) in generate_instructions() instructions.cleanup instructions = nil end |