Class: ElasticBeans::ApplicationVersion
- Inherits:
-
Object
- Object
- ElasticBeans::ApplicationVersion
- Defined in:
- lib/elastic_beans/application_version.rb
Instance Attribute Summary collapse
-
#application ⇒ Object
readonly
Returns the value of attribute application.
-
#version_description ⇒ Object
writeonly
Sets the attribute version_description.
-
#version_label ⇒ Object
readonly
Returns the value of attribute version_label.
Class Method Summary collapse
-
.create(working_directory:, application:, elastic_beanstalk:, s3:) ⇒ Object
Create a new Elastic Beanstalk application version from the HEAD git commit of the given
working_directory
. -
.new_from_existing(version_description, application:, elastic_beanstalk:) ⇒ Object
Create a representation of an existing application version in Elastic Beanstalk.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #date_updated ⇒ Object
- #delete ⇒ Object
-
#initialize(version_label, application:, elastic_beanstalk:) ⇒ ApplicationVersion
constructor
Create a representation of an existing application version in Elastic Beanstalk.
Constructor Details
#initialize(version_label, application:, elastic_beanstalk:) ⇒ ApplicationVersion
Create a representation of an existing application version in Elastic Beanstalk. Details will be fetched from the Elastic Beanstalk API.
15 16 17 18 19 |
# File 'lib/elastic_beans/application_version.rb', line 15 def initialize(version_label, application:, elastic_beanstalk:) @version_label = version_label @application = application @elastic_beanstalk = elastic_beanstalk end |
Instance Attribute Details
#application ⇒ Object (readonly)
Returns the value of attribute application.
10 11 12 |
# File 'lib/elastic_beans/application_version.rb', line 10 def application @application end |
#version_description=(value) ⇒ Object
Sets the attribute version_description
11 12 13 |
# File 'lib/elastic_beans/application_version.rb', line 11 def version_description=(value) @version_description = value end |
#version_label ⇒ Object (readonly)
Returns the value of attribute version_label.
10 11 12 |
# File 'lib/elastic_beans/application_version.rb', line 10 def version_label @version_label end |
Class Method Details
.create(working_directory:, application:, elastic_beanstalk:, s3:) ⇒ Object
Create a new Elastic Beanstalk application version from the HEAD git commit of the given working_directory
. Returns immediately if the application version already exists in Elastic Beanstalk.
Injects helper code from this library to enable the functionality described in the README.
Raises an error if the application version cannot be processed by Elastic Beanstalk.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/elastic_beans/application_version.rb', line 36 def create(working_directory:, application:, elastic_beanstalk:, s3:) version_label = fetch_version_label(working_directory) if application.versions.any? { |version| version.version_label == version_label } return new(version_label, application: application, elastic_beanstalk: elastic_beanstalk) end archive_path = File.join(working_directory, ".elasticbeanstalk", "#{version_label}.zip") create_archive(working_directory: working_directory, sha: version_label, path: archive_path) create_application_version( path: archive_path, version_label: version_label, application: application, elastic_beanstalk: elastic_beanstalk, s3: s3, ) new(version_label, application: application, elastic_beanstalk: elastic_beanstalk) end |
.new_from_existing(version_description, application:, elastic_beanstalk:) ⇒ Object
Create a representation of an existing application version in Elastic Beanstalk. version_description
should be the Aws::ElasticBeanstalk::Types::ApplicationVersionDescription
from the AWS API.
23 24 25 26 27 |
# File 'lib/elastic_beans/application_version.rb', line 23 def self.new_from_existing(version_description, application:, elastic_beanstalk:) version = new(version_description.version_label, application: application, elastic_beanstalk: elastic_beanstalk) version.version_description = version_description version end |
Instance Method Details
#==(other) ⇒ Object
194 195 196 197 |
# File 'lib/elastic_beans/application_version.rb', line 194 def ==(other) version_label == other.version_label && application.name == other.application.name end |
#date_updated ⇒ Object
190 191 192 |
# File 'lib/elastic_beans/application_version.rb', line 190 def date_updated version_description.date_updated end |
#delete ⇒ Object
179 180 181 182 183 184 185 186 187 188 |
# File 'lib/elastic_beans/application_version.rb', line 179 def delete elastic_beanstalk.delete_application_version( application_name: application.name, version_label: version_label, delete_source_bundle: true, ) rescue ::Aws::ElasticBeanstalk::Errors::Throttling sleep 5 retry end |