biosphere 0.2.8 → 0.2.9

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: 8e373f80b998cf5f1833a20208f7772d813ff7e5
4
- data.tar.gz: a2078ac110ba457f7717353acf22920c4955ef21
3
+ metadata.gz: fc7978fc42c73db8148546690ffdc26363814862
4
+ data.tar.gz: 62ab431bc12cfe129837619a221a2ab22da044d0
5
5
  SHA512:
6
- metadata.gz: c6c209289f626ca714b57a071e9799ba2a31e8cb8bb7a1235ab7da0d7fc7d56bceed84225dd365a063fc0dd630fe1bf94798b256950c2805541d607552950e87
7
- data.tar.gz: 76d440c43416e139bce31b8c85ba27a79eb9d93a62d8bb85ec4f6c98fef6866ff765af2cf0a09109a0018b4b9411433def3a2f5b4e56f9c1372a2db82863a4a2
6
+ metadata.gz: 5e6c4478856e452ea74f8f6deaa46d9ef75eeb66f7fdc10a07976b235939a8f5d6b235f7d891951c61c74e6b69283292317bbd7d4f28837cf01a8ed1b0c507cd
7
+ data.tar.gz: 390b6054285459b1870b6e1582d0ce3c1a4dfa147d39764d76277965b38b4a90db43403d33040f4683ba940c0f730a5914d0537c42923002d499b6bf94f8e6fd
@@ -97,18 +97,30 @@ if options.src
97
97
  end
98
98
 
99
99
  # We need to load the suite once so that we can find the Biosphere settings
100
- if suite.load_all(options.src) == 0 || suite.deployments.size == 0
101
- STDERR.puts "No files found. Are you in the right directory where your biosphere .rb files are?"
100
+ begin
101
+ if suite.load_all(options.src) == 0 || suite.deployments.size == 0
102
+ STDERR.puts "No files found. Are you in the right directory where your biosphere .rb files are?"
103
+ exit -1
104
+ end
105
+ rescue ::Biosphere::ConfigurationError => e
106
+ STDERR.puts "Configuration Error: #{e}".colorize(:red)
107
+ STDERR.puts "Relevant configuration part:"
108
+ ap e.settings
102
109
  exit -1
103
110
  end
104
111
 
105
- if suite.biosphere_settings[:s3_bucket].nil? || suite.biosphere_settings[:s3_bucket].empty? ||
106
- suite.biosphere_settings[:state_name].nil? || suite.biosphere_settings[:state_name].empty?
107
- puts "\nNo S3 bucket or cluster name defined in configuration, can't continue"
108
- exit 1
112
+ if suite.biosphere_settings[:local] == true
113
+ localmode = true
114
+ else
115
+ localmode = false
116
+ if suite.biosphere_settings[:s3_bucket].nil? || suite.biosphere_settings[:s3_bucket].empty? ||
117
+ suite.biosphere_settings[:state_name].nil? || suite.biosphere_settings[:state_name].empty?
118
+ puts "\nNo S3 bucket or cluster name defined in configuration, can't continue"
119
+ exit 1
120
+ end
121
+ s3 = S3.new(suite.biosphere_settings[:s3_bucket], suite.biosphere_settings[:state_name])
122
+ s3.retrieve("#{options.build_dir}/state.node")
109
123
  end
110
- s3 = S3.new(suite.biosphere_settings[:s3_bucket], suite.biosphere_settings[:state_name])
111
- s3.retrieve("#{options.build_dir}/state.node")
112
124
 
113
125
  # This will update the state which is already passed to the suite.
114
126
  state.filename = "#{options.build_dir}/state.node"
@@ -149,7 +161,7 @@ if ARGV[0] == "build" && options.src
149
161
 
150
162
  puts "Wrote #{count} files into #{options.build_dir}"
151
163
  state.save()
152
- s3.save("#{options.build_dir}/state.node")
164
+ s3.save("#{options.build_dir}/state.node") unless localmode
153
165
 
154
166
  elsif ARGV[0] == "plan" && options.src
155
167
  suite.evaluate_plans()
@@ -176,7 +188,7 @@ elsif ARGV[0] == "action" && options.src
176
188
  STDERR.puts "Could not find action #{ARGV[1]}"
177
189
  end
178
190
  state.save()
179
- s3.save("#{options.build_dir}/state.node")
191
+ s3.save("#{options.build_dir}/state.node") unless localmode
180
192
 
181
193
  elsif ARGV[0] == "deployment" && options.src
182
194
 
@@ -198,10 +210,14 @@ elsif ARGV[0] == "statereset" && options.src
198
210
  state = Biosphere::State.new
199
211
  state.filename = "#{options.build_dir}/state.node"
200
212
  state.save()
201
- s3.save("#{options.build_dir}/state.node")
213
+ s3.save("#{options.build_dir}/state.node") unless localmode
202
214
  end
203
215
 
204
216
  elsif ARGV[0] == "commit" && options.src
217
+ if localmode
218
+ STDERR.puts "commit not supported in local mode (set in Settings :biosphere[:local] = true"
219
+ exit -1
220
+ end
205
221
 
206
222
  if !ARGV[1]
207
223
  puts "Please specify deployment name as the second parameter."
@@ -242,7 +258,7 @@ elsif ARGV[0] == "commit" && options.src
242
258
  plan.print
243
259
 
244
260
  targets = plan.get_resources.collect { |x| "-target=#{x}" }.join(" ")
245
-
261
+ puts "Targets: #{targets}"
246
262
  answer = ""
247
263
  while answer.empty? || (answer != "y" && answer != "n")
248
264
  print "\nDoes the plan look reasonable? (Answering yes will apply the changes) y/n: "
@@ -292,6 +308,10 @@ elsif ARGV[0] == "commit" && options.src
292
308
  s3.release_lock()
293
309
 
294
310
  elsif ARGV[0] == "destroy" && options.src
311
+ if localmode
312
+ STDERR.puts "destroy not supported in local mode (set in Settings :biosphere[:local] = true"
313
+ exit -1
314
+ end
295
315
 
296
316
  if !ARGV[1]
297
317
  puts "Please specify deployment name as the second parameter."
@@ -324,9 +344,19 @@ elsif ARGV[0] == "destroy" && options.src
324
344
  s3.release_lock()
325
345
 
326
346
  elsif ARGV[0] == "lock"
347
+ if localmode
348
+ STDERR.puts "lock not supported in local mode (set in Settings :biosphere[:local] = true"
349
+ exit -1
350
+ end
351
+
327
352
  s3.set_lock()
328
353
 
329
354
  elsif ARGV[0] == "unlock"
355
+ if localmode
356
+ STDERR.puts "unlock not supported in local mode (set in Settings :biosphere[:local] = true"
357
+ exit -1
358
+ end
359
+
330
360
  s3.release_lock()
331
361
 
332
362
  else
@@ -5,6 +5,7 @@ require 'deep_merge'
5
5
 
6
6
  require "biosphere/ipaddressallocator"
7
7
  require "biosphere/version"
8
+ require "biosphere/exceptions"
8
9
  require "biosphere/settings"
9
10
  require "biosphere/node"
10
11
  require "biosphere/state"
@@ -0,0 +1,16 @@
1
+
2
+ class Biosphere
3
+
4
+ class ConfigurationError < ::RuntimeError
5
+
6
+ attr_reader :settings
7
+
8
+ def initialize(msg, settings)
9
+ super(msg)
10
+
11
+ @settings = settings
12
+ end
13
+ end
14
+
15
+ end
16
+
@@ -81,6 +81,9 @@ class Biosphere
81
81
 
82
82
  # Finds files from relative path
83
83
  def find_files(p)
84
+ if !$current_biosphere_path_stack
85
+ $current_biosphere_path_stack = "."
86
+ end
84
87
  relative_path = $current_biosphere_path_stack + "/" + p
85
88
  entries = Dir[(relative_path)] - [".", ".."]
86
89
  return entries
@@ -1,3 +1,3 @@
1
1
  class Biosphere
2
- Version = "0.2.8"
2
+ Version = "0.2.9"
3
3
  end
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.8
4
+ version: 0.2.9
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-05-30 00:00:00.000000000 Z
11
+ date: 2017-05-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -180,6 +180,7 @@ files:
180
180
  - lib/biosphere/cli/terraformplanning.rb
181
181
  - lib/biosphere/cli/updatemanager.rb
182
182
  - lib/biosphere/deployment.rb
183
+ - lib/biosphere/exceptions.rb
183
184
  - lib/biosphere/ipaddressallocator.rb
184
185
  - lib/biosphere/kube.rb
185
186
  - lib/biosphere/mixing/from_file.rb