biosphere 0.2.12 → 0.2.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/biosphere +51 -3
- data/lib/biosphere/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1502995009f69c7c5443594f62ffd8a13737a470
|
4
|
+
data.tar.gz: f2f605a347d1535e1ac33414abf27abeb6b25073
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 56e6151183ca3d81ab3fb2b70478f289dc4c0a8664212bbcd55c4b6ecd183a430855c97cd46a89a2d2746d34f1d567e693d4775f13f429da76f6a40a075a24e1
|
7
|
+
data.tar.gz: 34ae7d91b1b20c289f4633bd68c53752120501083e4eecac1c5df66d786be06a525c063868c1ca0548c90d71f0353b37727045b8e9b1523bea9d854aff1397a2
|
data/bin/biosphere
CHANGED
@@ -9,6 +9,26 @@ require 'colorize'
|
|
9
9
|
require 'biosphere/s3.rb'
|
10
10
|
require 'pty'
|
11
11
|
|
12
|
+
|
13
|
+
# Asks a question
|
14
|
+
# Choises is an array of valid answers, such as ['y', 'n']
|
15
|
+
# If optional force is set to true then the first choise option is returned.
|
16
|
+
def ask_question(question, choices, force: false, color: :yellow)
|
17
|
+
answer = ""
|
18
|
+
if force
|
19
|
+
puts question + " Forcing since --force is set"
|
20
|
+
return choices.first
|
21
|
+
end
|
22
|
+
|
23
|
+
while answer.empty? || !choices.include?(answer.downcase)
|
24
|
+
puts (question + " [" + choices.join('/') + "]").colorize(color)
|
25
|
+
answer = STDIN.gets.chomp
|
26
|
+
end
|
27
|
+
|
28
|
+
return answer
|
29
|
+
end
|
30
|
+
|
31
|
+
|
12
32
|
class BiosphereOpts
|
13
33
|
|
14
34
|
def self.parse(args)
|
@@ -139,6 +159,19 @@ if options.src
|
|
139
159
|
state.load()
|
140
160
|
end
|
141
161
|
|
162
|
+
destroyed_deployments = state.node[:deployments].keys - suite.deployments.keys
|
163
|
+
if destroyed_deployments.length > 0
|
164
|
+
destroyed_deployments.each do |deployment_name|
|
165
|
+
answer = ask_question("State file has remins of an old deployment #{deployment_name}. Do you want to clean these now?", ['y', 'n'], force: options.force)
|
166
|
+
if answer == "y"
|
167
|
+
puts "Clearing #{deployment_name}"
|
168
|
+
state.node[:deployments].delete(deployment_name)
|
169
|
+
else
|
170
|
+
puts "Leaving #{deployment_name}, this might affect for example action kubectl."
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
142
175
|
unless state.node[:deployments][""].nil?
|
143
176
|
answer = ""
|
144
177
|
if !options.force
|
@@ -148,10 +181,10 @@ if options.src
|
|
148
181
|
end
|
149
182
|
|
150
183
|
if answer == "n"
|
151
|
-
|
184
|
+
puts "Remember to clean these out later, this state won't work with Kubernetes"
|
152
185
|
elsif answer == "y"
|
153
|
-
|
154
|
-
|
186
|
+
state.node[:deployments].delete("")
|
187
|
+
puts "\e[32mRemoved deployment with empty name\e[0m"
|
155
188
|
end
|
156
189
|
else
|
157
190
|
puts "Forcing since --force was set"
|
@@ -159,6 +192,14 @@ if options.src
|
|
159
192
|
end
|
160
193
|
end
|
161
194
|
|
195
|
+
# If we are doing something which is allowed to modify the state
|
196
|
+
if ["build", "action", "commit"].include?(ARGV[0])
|
197
|
+
if !state.node[:biosphere]
|
198
|
+
state.node[:biosphere] = {}
|
199
|
+
end
|
200
|
+
state.node[:biosphere][:version] = ::Biosphere::Version
|
201
|
+
end
|
202
|
+
|
162
203
|
if ARGV[0] == "build" && options.src
|
163
204
|
suite.evaluate_resources()
|
164
205
|
|
@@ -174,6 +215,8 @@ if ARGV[0] == "build" && options.src
|
|
174
215
|
end
|
175
216
|
|
176
217
|
puts "Wrote #{count} files under #{options.build_dir}"
|
218
|
+
state.node[:biosphere][:last_build_time] = Time.now.utc.strftime('%Y-%m-%dT%H:%M:%SZ')
|
219
|
+
|
177
220
|
state.save()
|
178
221
|
s3.save("#{options.build_dir}/state.node") unless localmode
|
179
222
|
|
@@ -229,6 +272,9 @@ elsif ARGV[0] == "statereset" && options.src
|
|
229
272
|
state.filename = "#{options.build_dir}/state.node"
|
230
273
|
state.save()
|
231
274
|
s3.save("#{options.build_dir}/state.node") unless localmode
|
275
|
+
suite.deployments.each do |name, deployment|
|
276
|
+
s3.delete_object()
|
277
|
+
end
|
232
278
|
end
|
233
279
|
|
234
280
|
elsif ARGV[0] == "commit" && options.src
|
@@ -327,6 +373,7 @@ elsif ARGV[0] == "commit" && options.src
|
|
327
373
|
|
328
374
|
puts "Loading outputs for #{deployment} from #{state_file}"
|
329
375
|
suite.deployments[deployment].load_outputs(state_file)
|
376
|
+
state.node[:biosphere][:last_commit_time] = Time.now.utc.strftime('%Y-%m-%dT%H:%M:%SZ')
|
330
377
|
state.save()
|
331
378
|
s3.save("#{options.build_dir}/#{deployment}.tfstate")
|
332
379
|
s3.save("#{options.build_dir}/state.node")
|
@@ -394,3 +441,4 @@ else
|
|
394
441
|
STDERR.puts "\nERROR: Unknown command #{ARGV[0]}. Maybe you wanted to do: \"biosphere action #{ARGV[0]}\"?"
|
395
442
|
exit -1
|
396
443
|
end
|
444
|
+
|
data/lib/biosphere/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: biosphere
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Juho Mäkinen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-06-
|
11
|
+
date: 2017-06-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|