Class: JackAndTheElasticBeanstalk::EB
- Inherits:
-
Object
- Object
- JackAndTheElasticBeanstalk::EB
- Defined in:
- lib/jack_and_the_elastic_beanstalk/eb.rb
Defined Under Namespace
Classes: Environment
Instance Attribute Summary collapse
-
#application_name ⇒ Object
readonly
Returns the value of attribute application_name.
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#keep_versions ⇒ Object
Returns the value of attribute keep_versions.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
Instance Method Summary collapse
- #application_versions ⇒ Object
- #cleanup_versions ⇒ Object
- #create_version(s3_bucket:, s3_key:, label:) ⇒ Object
- #environments ⇒ Object
-
#initialize(application_name:, logger:, client:) ⇒ EB
constructor
A new instance of EB.
- #refresh ⇒ Object
Constructor Details
#initialize(application_name:, logger:, client:) ⇒ EB
Returns a new instance of EB.
9 10 11 12 13 14 15 16 |
# File 'lib/jack_and_the_elastic_beanstalk/eb.rb', line 9 def initialize(application_name:, logger:, client:) @application_name = application_name @logger = logger @client = client @env_stack = [] @timeout = 600 @keep_versions = 100 end |
Instance Attribute Details
#application_name ⇒ Object (readonly)
Returns the value of attribute application_name.
3 4 5 |
# File 'lib/jack_and_the_elastic_beanstalk/eb.rb', line 3 def application_name @application_name end |
#client ⇒ Object (readonly)
Returns the value of attribute client.
5 6 7 |
# File 'lib/jack_and_the_elastic_beanstalk/eb.rb', line 5 def client @client end |
#keep_versions ⇒ Object
Returns the value of attribute keep_versions.
7 8 9 |
# File 'lib/jack_and_the_elastic_beanstalk/eb.rb', line 7 def keep_versions @keep_versions end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
4 5 6 |
# File 'lib/jack_and_the_elastic_beanstalk/eb.rb', line 4 def logger @logger end |
#timeout ⇒ Object
Returns the value of attribute timeout.
6 7 8 |
# File 'lib/jack_and_the_elastic_beanstalk/eb.rb', line 6 def timeout @timeout end |
Instance Method Details
#application_versions ⇒ Object
34 35 36 |
# File 'lib/jack_and_the_elastic_beanstalk/eb.rb', line 34 def application_versions @application_versions = client.describe_application_versions(application_name: application_name).application_versions.sort_by { |v| v.date_updated }.reverse end |
#cleanup_versions ⇒ Object
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/jack_and_the_elastic_beanstalk/eb.rb', line 49 def cleanup_versions old_application_versions = application_versions[keep_versions..-1] return 0 unless old_application_versions old_application_versions.each do |version| client.delete_application_version(application_name: application_name, version_label: version.version_label, delete_source_bundle: true) end old_application_versions.count end |
#create_version(s3_bucket:, s3_key:, label:) ⇒ Object
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/jack_and_the_elastic_beanstalk/eb.rb', line 38 def create_version(s3_bucket:, s3_key:, label:) client.create_application_version(application_name: application_name, description: label, version_label: label, source_bundle: { s3_bucket: s3_bucket, s3_key: s3_key, }, process: true) end |
#environments ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/jack_and_the_elastic_beanstalk/eb.rb', line 18 def environments @environments = client.describe_environments(application_name: application_name, include_deleted: false).environments.map {|env| Environment.new(application_name: application_name, environment_name: env.environment_name, logger: logger, client: client).tap do |e| e.timeout = timeout e.data = env end } end |
#refresh ⇒ Object
30 31 32 |
# File 'lib/jack_and_the_elastic_beanstalk/eb.rb', line 30 def refresh @environments = nil end |