jack_and_the_elastic_beanstalk 0.1.0.pre → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4578032c8d9235e27f4491ace04ec78f8929d63f
4
- data.tar.gz: '06419fd23e051d5205a536a1c2e6f076819b881c'
3
+ metadata.gz: 3a9b6fdfd1072695714769ae81f8c4b4f766cc7c
4
+ data.tar.gz: 6e708c0e1d0a1e6fa9b152397331fac469f1f6d4
5
5
  SHA512:
6
- metadata.gz: 9886c279514422cb879ca4c7c598cea9a868df7058efebebb9f775bdeb194993ff198bbc189f94345f025459a0ad9aa9ca9b89ff426b25e230f498d3d80f97f5
7
- data.tar.gz: 1096c0027dfc9b5e5da7539b9f543bccfca76a8630ad9cdb2caf2ea677af075bba3cb58a12a5f6b207d1d1cea81a69ac7ab4cf07434a2e8c8b14c3ffa0ca660a
6
+ metadata.gz: 332939a0c51ac97770674c689c73bbfd5df7cce4d7551017e64c7e4fd85432aefd70ccf118afffe93b649d70ea7c2f94bbee52a3e42bfd27ccc1994524d58804
7
+ data.tar.gz: 2acd0fba8246f497d5ea7ee796c4f05d1397320ebcef76b940df6f18adee7d2554d70497aa62d6a69af196ee4ad64bb038dee2bb83f0f27d5399706c16b6eb28
@@ -18,6 +18,7 @@ module JackAndTheElasticBeanstalk
18
18
  def eb
19
19
  @eb ||= JackAndTheElasticBeanstalk::EB.new(application_name: config.app_name, logger: logger, client: client).tap do |eb|
20
20
  eb.timeout = options[:timeout] * 60
21
+ eb.keep_versions = options[:keep_versions]
21
22
  end
22
23
  end
23
24
 
@@ -60,6 +61,7 @@ module JackAndTheElasticBeanstalk
60
61
  class_option :loglevel, type: :string, enum: ["info", "debug", "error"], default: "error", desc: "Loglevel"
61
62
  class_option :jack_dir, type: :string, default: (Pathname.pwd + "jack").to_s, desc: "Directory to app.yml"
62
63
  class_option :source_dir, type: :string, default: Pathname.pwd.to_s, desc: "Directory for source code"
64
+ class_option :keep_versions, type: :numeric, default: 100, desc: "Number of application versions to keep"
63
65
 
64
66
  desc "create CONFIGURATION GROUP ENV_VAR=VALUE...", "Create new group"
65
67
  def create(configuration, group, *env_var_args)
@@ -341,5 +343,16 @@ module JackAndTheElasticBeanstalk
341
343
  runner.stdout.puts JSON.pretty_generate(resources)
342
344
  end
343
345
  end
346
+
347
+ desc "cleanup", "Cleanup old application versions"
348
+ def cleanup
349
+ deleted_count = eb.cleanup_versions
350
+ runner.stdout.puts "Cleanup #{deleted_count} versions."
351
+ end
352
+
353
+ desc "version", "Print version"
354
+ def version
355
+ puts VERSION
356
+ end
344
357
  end
345
358
  end
@@ -4,6 +4,7 @@ module JackAndTheElasticBeanstalk
4
4
  attr_reader :logger
5
5
  attr_reader :client
6
6
  attr_accessor :timeout
7
+ attr_accessor :keep_versions
7
8
 
8
9
  def initialize(application_name:, logger:, client:)
9
10
  @application_name = application_name
@@ -11,6 +12,7 @@ module JackAndTheElasticBeanstalk
11
12
  @client = client
12
13
  @env_stack = []
13
14
  @timeout = 600
15
+ @keep_versions = 100
14
16
  end
15
17
 
16
18
  def environments
@@ -29,6 +31,10 @@ module JackAndTheElasticBeanstalk
29
31
  @environments = nil
30
32
  end
31
33
 
34
+ def application_versions
35
+ @application_versions = client.describe_application_versions(application_name: application_name).application_versions.sort_by { |v| v.date_updated }.reverse
36
+ end
37
+
32
38
  def create_version(s3_bucket:, s3_key:, label:)
33
39
  client.create_application_version(application_name: application_name,
34
40
  description: label,
@@ -40,6 +46,17 @@ module JackAndTheElasticBeanstalk
40
46
  process: true)
41
47
  end
42
48
 
49
+ def cleanup_versions
50
+ old_application_versions = application_versions[keep_versions..-1]
51
+ return 0 unless old_application_versions
52
+ old_application_versions.each do |version|
53
+ client.delete_application_version(application_name: application_name,
54
+ version_label: version.version_label,
55
+ delete_source_bundle: true)
56
+ end
57
+ old_application_versions.count
58
+ end
59
+
43
60
  class Environment
44
61
  attr_reader :application_name
45
62
  attr_reader :logger
@@ -148,6 +148,8 @@ module JackAndTheElasticBeanstalk
148
148
 
149
149
  env.ensure_version!(expected_label: label)
150
150
  end
151
+
152
+ eb.cleanup_versions
151
153
  end
152
154
 
153
155
  def destroy(group:)
@@ -1,3 +1,3 @@
1
1
  module JackAndTheElasticBeanstalk
2
- VERSION = "0.1.0.pre"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jack_and_the_elastic_beanstalk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.pre
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Soutaro Matsumoto
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-02-24 00:00:00.000000000 Z
11
+ date: 2017-03-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -189,9 +189,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
189
189
  version: '0'
190
190
  required_rubygems_version: !ruby/object:Gem::Requirement
191
191
  requirements:
192
- - - ">"
192
+ - - ">="
193
193
  - !ruby/object:Gem::Version
194
- version: 1.3.1
194
+ version: '0'
195
195
  requirements: []
196
196
  rubyforge_project:
197
197
  rubygems_version: 2.5.2