elastic_beans 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 10462aa38d3834422bab9795d785bcc62918f1a9
4
- data.tar.gz: 976eab44cd9ef0562106c9438df39fb3936ffc28
3
+ metadata.gz: 07dcf92670f011c2715d0ffd754bc856803f1434
4
+ data.tar.gz: 8b483d5a53cb03898d44f8de16fcf4c5e180aa25
5
5
  SHA512:
6
- metadata.gz: 88a3f198fd40582742329016941ea9c672b45dc7e0ef548e9c5c2766c1bbf735ad4dbccb74cce15efd6eb338cfe9cc21cf56900eb38ff957fb9edd208a4bb89d
7
- data.tar.gz: ab100cd37d28544b0e1d1b853e3d0fca05ac922ac77fffe00d48ba831a98e5d06eb420bcd9bff914d251c8b744ee466fd50aee2fd43e1724a565cfdc7994ee0b
6
+ metadata.gz: c2758059cb4a7351e4c6ebb1492d5211c2098b351d4e7fbd584f96e0ce266d085bb4d7633cf4aa8a8f34695585adf4581b34150ab4350d3eef958927f9cb99c1
7
+ data.tar.gz: 2c2e12f9ee533a77d60b82b888b80bc708615ad12ae3f60b13c96b66b5ce89daecf5767c05770a65a9c3416a8e1b0b157a83cdc0f6487d77339653ec52d2035f
@@ -101,21 +101,6 @@ class ElasticBeans::CLI < Thor
101
101
  error(e)
102
102
  end
103
103
 
104
- desc ElasticBeans::Command::GetEnv::USAGE, ElasticBeans::Command::GetEnv::DESC
105
- long_desc ElasticBeans::Command::GetEnv::LONG_DESC
106
- option :application, aliases: %w(-a), required: true, desc: APPLICATION_DESC
107
- def getenv(*env_vars)
108
- @verbose = options[:verbose]
109
- ElasticBeans::Command::GetEnv.new(
110
- application: application(
111
- name: options[:application],
112
- ),
113
- ui: ui,
114
- ).run(*env_vars)
115
- rescue StandardError => e
116
- error(e)
117
- end
118
-
119
104
  desc ElasticBeans::Command::Scale::USAGE, ElasticBeans::Command::Scale::DESC
120
105
  long_desc ElasticBeans::Command::Scale::LONG_DESC
121
106
  option :application, aliases: %w(-a), required: true, desc: APPLICATION_DESC
@@ -138,6 +123,21 @@ class ElasticBeans::CLI < Thor
138
123
  error(e)
139
124
  end
140
125
 
126
+ desc ElasticBeans::Command::GetEnv::USAGE, ElasticBeans::Command::GetEnv::DESC
127
+ long_desc ElasticBeans::Command::GetEnv::LONG_DESC
128
+ option :application, aliases: %w(-a), required: true, desc: APPLICATION_DESC
129
+ def getenv(*env_vars)
130
+ @verbose = options[:verbose]
131
+ ElasticBeans::Command::GetEnv.new(
132
+ application: application(
133
+ name: options[:application],
134
+ ),
135
+ ui: ui,
136
+ ).run(*env_vars)
137
+ rescue StandardError => e
138
+ error(e)
139
+ end
140
+
141
141
  desc ElasticBeans::Command::SetEnv::USAGE, ElasticBeans::Command::SetEnv::DESC
142
142
  long_desc ElasticBeans::Command::SetEnv::LONG_DESC
143
143
  option :application, aliases: %w(-a), required: true, desc: APPLICATION_DESC
@@ -153,6 +153,23 @@ class ElasticBeans::CLI < Thor
153
153
  error(e)
154
154
  end
155
155
 
156
+ desc ElasticBeans::Command::UnsetEnv::USAGE, ElasticBeans::Command::UnsetEnv::DESC
157
+ long_desc ElasticBeans::Command::UnsetEnv::LONG_DESC
158
+ option :application, aliases: %w(-a), required: true, desc: APPLICATION_DESC
159
+ def unsetenv(*env_keys)
160
+ @verbose = options[:verbose]
161
+ ElasticBeans::Command::UnsetEnv.new(
162
+ application: application(
163
+ name: options[:application],
164
+ ),
165
+ ui: ui,
166
+ ).run(*env_keys)
167
+ rescue StandardError => e
168
+ error(e)
169
+ end
170
+
171
+ map ["delvar", "rmvar"] => "unsetenv"
172
+
156
173
  desc "talk", ""
157
174
  def talk
158
175
  ElasticBeans::Command::Talk.new(ui: ui).run
@@ -10,7 +10,7 @@ module ElasticBeans
10
10
  LONG_DESC = <<-LONG_DESC
11
11
  Update environment variables in the Elastic Beanstalk application.
12
12
  These are stored in S3 to avoid the 4096-byte limit on environment variables in Elastic Beanstalk.
13
- Restarts all running environments so they load the updated environment.
13
+ Restarts all running environments so they load the updated environment vars.
14
14
 
15
15
  Requires AWS credentials to be set in the environment, i.e. AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY.
16
16
  LONG_DESC
@@ -33,7 +33,7 @@ Requires AWS credentials to be set in the environment, i.e. AWS_ACCESS_KEY_ID an
33
33
  progressbar = ProgressBar.create(title: "Updating", total: nil, output: ui.stdout)
34
34
 
35
35
  progressbar.log("Updating configuration in #{application.name}...")
36
- application.env_vars.update(env_vars)
36
+ application.env_vars.upsert(env_vars)
37
37
  progressbar.increment
38
38
 
39
39
  threads += environments.map { |environment|
@@ -0,0 +1,65 @@
1
+ require "ruby-progressbar"
2
+ require "elastic_beans/error/environments_not_ready"
3
+
4
+ module ElasticBeans
5
+ module Command
6
+ # :nodoc: all
7
+ class UnsetEnv
8
+ USAGE = "unsetenv KEY [KEY]... | delvar | rmvar"
9
+ DESC = "Delete environment variables in the Elastic Beanstalk application"
10
+ LONG_DESC = <<-LONG_DESC
11
+ Delete environment variables in the Elastic Beanstalk application.
12
+ These are stored in S3 to avoid the 4096-byte limit on environment variables in Elastic Beanstalk.
13
+ Restarts all running environments so they load the updated environment vars.
14
+
15
+ Requires AWS credentials to be set in the environment, i.e. AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY.
16
+ LONG_DESC
17
+
18
+ def initialize(application:, ui:)
19
+ @application = application
20
+ @ui = ui
21
+ end
22
+
23
+ def run(*env_keys)
24
+ environments = application.environments
25
+ unready_environments = environments.select { |environment| environment.status != "Ready" }
26
+ if unready_environments.any?
27
+ raise EnvironmentsNotReady.new(environments: unready_environments)
28
+ end
29
+
30
+ threads = []
31
+
32
+ progressbar = ProgressBar.create(title: "Updating", total: nil, output: ui.stdout)
33
+
34
+ progressbar.log("Updating configuration in #{application.name}...")
35
+ application.env_vars.del(env_keys)
36
+ progressbar.increment
37
+
38
+ threads += environments.map { |environment|
39
+ progressbar.log("Deleting env vars from `#{environment.name}'...")
40
+ thread = Thread.new do
41
+ environment.restart
42
+ end
43
+ progressbar.increment
44
+ thread
45
+ }
46
+
47
+ loop do
48
+ sleep 0.5
49
+ progressbar.increment
50
+ if threads.none?(&:alive?)
51
+ progressbar.total = progressbar.progress
52
+ break
53
+ end
54
+ end
55
+
56
+ threads.each(&:join)
57
+ end
58
+
59
+ private
60
+
61
+ attr_reader :application, :ui
62
+
63
+ end
64
+ end
65
+ end
@@ -2,9 +2,10 @@ require "elastic_beans/command/configure"
2
2
  require "elastic_beans/command/create"
3
3
  require "elastic_beans/command/deploy"
4
4
  require "elastic_beans/command/exec"
5
- require "elastic_beans/command/get_env"
6
5
  require "elastic_beans/command/scale"
6
+ require "elastic_beans/command/get_env"
7
7
  require "elastic_beans/command/set_env"
8
+ require "elastic_beans/command/unset_env"
8
9
  require "elastic_beans/command/talk"
9
10
  require "elastic_beans/command/version"
10
11
 
@@ -28,11 +28,22 @@ module ElasticBeans
28
28
  end
29
29
 
30
30
  # Updates the environment variables stored in S3 by merging it with the given +env_hash+.
31
- def update(env_hash)
31
+ def upsert(env_hash)
32
32
  body = env_script(to_h.merge(env_hash))
33
33
  s3.put_object(bucket: application.bucket_name, key: s3_key, body: body)
34
34
  end
35
35
 
36
+ # Deletes the specified +env_keys+ environment variables stored in S3.
37
+ def del(env_keys)
38
+ json_hash = to_h
39
+ env_keys.each { |key|
40
+ json_hash.delete(key)
41
+ }
42
+
43
+ body = env_script(json_hash)
44
+ s3.put_object(bucket: application.bucket_name, key: s3_key, body: body)
45
+ end
46
+
36
47
  private
37
48
 
38
49
  attr_reader :application, :s3
@@ -1,3 +1,3 @@
1
1
  module ElasticBeans
2
- VERSION = "0.6.0"
2
+ VERSION = "0.7.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elastic_beans
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Stegman
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-01-18 00:00:00.000000000 Z
11
+ date: 2017-01-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk
@@ -171,6 +171,7 @@ files:
171
171
  - lib/elastic_beans/command/scale.rb
172
172
  - lib/elastic_beans/command/set_env.rb
173
173
  - lib/elastic_beans/command/talk.rb
174
+ - lib/elastic_beans/command/unset_env.rb
174
175
  - lib/elastic_beans/command/version.rb
175
176
  - lib/elastic_beans/configuration_template.rb
176
177
  - lib/elastic_beans/configuration_template/base.rb
@@ -217,7 +218,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
217
218
  version: '0'
218
219
  requirements: []
219
220
  rubyforge_project:
220
- rubygems_version: 2.5.2
221
+ rubygems_version: 2.5.1
221
222
  signing_key:
222
223
  specification_version: 4
223
224
  summary: Elastic Beanstalk environment orchestration for a Rails app