manifests-vmc-plugin 0.4.10 → 0.4.11

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.
@@ -78,8 +78,7 @@ module VMCManifests
78
78
 
79
79
  # merge the manifest at `path' into the `child'
80
80
  def merge_parent(child, path)
81
- file = File.expand_path(path, File.dirname(manifest_file))
82
- merge_manifest(child, build_manifest(file))
81
+ merge_manifest(child, build_manifest(from_manifest(path)))
83
82
  end
84
83
 
85
84
  # deep hash merge
@@ -221,11 +220,10 @@ module VMCManifests
221
220
  return unless manifest
222
221
 
223
222
  if apps = manifest["applications"]
224
- mandir = File.dirname(manifest_file)
225
- full_path = File.expand_path(find_path, mandir)
223
+ full_path = from_manifest(find_path)
226
224
 
227
225
  manifest["applications"].find do |path, info|
228
- File.expand_path(path, mandir) == full_path
226
+ from_manifest(path) == full_path
229
227
  end
230
228
  elsif find_path == "."
231
229
  [".", toplevel_attributes]
@@ -236,8 +234,7 @@ module VMCManifests
236
234
  path, info = app_by_name(path_or_name) || app_by_path(path_or_name)
237
235
  return unless info
238
236
 
239
- abspath = File.expand_path(path, File.dirname(manifest_file))
240
- data = { :path => abspath }
237
+ data = { :path => from_manifest(path) }
241
238
 
242
239
  toplevel_attributes.merge(info).each do |k, v|
243
240
  name = k.to_sym
@@ -275,6 +272,15 @@ module VMCManifests
275
272
  end
276
273
  end
277
274
 
275
+ def all_apps(input = nil)
276
+ apps = []
277
+
278
+ each_app(input) do |app|
279
+ apps << app
280
+ end
281
+
282
+ apps
283
+ end
278
284
 
279
285
  def no_apps
280
286
  fail "No applications or manifest to operate on."
@@ -295,14 +301,18 @@ module VMCManifests
295
301
  []
296
302
  end
297
303
 
304
+ input = input.without(:app, :apps)
305
+ in_manifest = []
306
+
298
307
  if names_or_paths.empty?
299
- each_app(input, &blk)
300
- return []
308
+ if app = app_info(Dir.pwd, input)
309
+ in_manifest << app
310
+ else
311
+ each_app(input, &blk)
312
+ return []
313
+ end
301
314
  end
302
315
 
303
- input = input.without(:app, :apps)
304
-
305
- in_manifest = []
306
316
  external = []
307
317
  names_or_paths.each do |x|
308
318
  if x.is_a?(String)
@@ -330,27 +340,29 @@ module VMCManifests
330
340
 
331
341
  private
332
342
 
343
+ # expand a path relative to the manifest file's directory
344
+ def from_manifest(path)
345
+ File.expand_path(path, File.dirname(manifest_file))
346
+ end
347
+
333
348
  # sort applications in dependency order
334
349
  # e.g. if A depends on B, B will be listed before A
335
350
  def ordered_by_deps(apps, abspaths = nil, processed = Set[])
336
- mandir = File.dirname(manifest_file)
337
-
338
351
  unless abspaths
339
352
  abspaths = {}
340
353
  apps.each do |p, i|
341
- ep = File.expand_path(p, mandir)
342
- abspaths[ep] = i
354
+ abspaths[from_manifest(p)] = i
343
355
  end
344
356
  end
345
357
 
346
358
  ordered = []
347
359
  apps.each do |path, info|
348
- epath = File.expand_path(path, mandir)
360
+ epath = from_manifest(path)
349
361
 
350
362
  if deps = info["depends-on"]
351
363
  dep_apps = {}
352
364
  deps.each do |dep|
353
- edep = File.expand_path(dep, mandir)
365
+ edep = from_manifest(dep)
354
366
 
355
367
  raise "Circular dependency detected." if processed.include? edep
356
368
 
@@ -381,7 +393,8 @@ module VMCManifests
381
393
  "runtime" => app.runtime.name,
382
394
  "memory" => human_size(app.memory * 1024 * 1024, 0),
383
395
  "instances" => app.total_instances,
384
- "url" => app.url && app.url.sub(target_base, '${target-base}')
396
+ "url" => app.url && app.url.sub(target_base, '${target-base}'),
397
+ "path" => input[:path]
385
398
  }
386
399
 
387
400
  unless service_instances.empty?
@@ -413,17 +426,10 @@ module VMCManifests
413
426
  end
414
427
 
415
428
  if ask("Save configuration?", :default => false)
416
- if input[:path] =~ /\.[[:alnum:]]+$/
417
- root = ask("Application root", :default => ".")
418
- meta["path"] = input[:path]
419
- else
420
- root = input[:path]
421
- end
422
-
423
429
  with_progress("Saving to #{c("manifest.yml", :name)}") do
424
430
  File.open("manifest.yml", "w") do |io|
425
431
  YAML.dump(
426
- { "applications" => { root => meta } },
432
+ { "applications" => { "." => meta } },
427
433
  io)
428
434
  end
429
435
  end
@@ -519,4 +525,5 @@ module VMCManifests
519
525
 
520
526
  format("%.#{precision}fB", num)
521
527
  end
528
+
522
529
  end
@@ -87,7 +87,7 @@ class Manifests < VMC::CLI
87
87
  :desc => "Reset to values in the manifest"
88
88
 
89
89
  around(:push) do |push, input|
90
- app =
90
+ single =
91
91
  if input.given?(:name)
92
92
  path = File.expand_path(input[:name])
93
93
  find_by = File.exists?(path) ? path : input[:name]
@@ -95,31 +95,11 @@ class Manifests < VMC::CLI
95
95
  app_info(find_by, input.without(:name))
96
96
  end
97
97
 
98
- app ||= app_info(".", input)
98
+ single ||= app_info(Dir.pwd, input)
99
99
 
100
- if app
101
- with_filters(
102
- :push => {
103
- :create_app => proc { |a|
104
- setup_env(a, app)
105
- a
106
- },
107
- :push_app => proc { |a|
108
- setup_services(a, app)
109
- a
110
- }
111
- }) do
112
- # only set inputs if creating app or updating with --reset
113
- if input[:reset] || !client.app_by_name(app[:name])
114
- input = input.merge_given(app)
115
- end
100
+ apps = single ? [single] : all_apps(input)
116
101
 
117
- push.call(input.merge(
118
- :name => app[:name],
119
- :bind_services => false,
120
- :create_services => false))
121
- end
122
- else
102
+ if apps.empty?
123
103
  with_filters(
124
104
  :push => {
125
105
  :push_app =>
@@ -127,6 +107,32 @@ class Manifests < VMC::CLI
127
107
  }) do
128
108
  push.call
129
109
  end
110
+ else
111
+ apps.each do |app|
112
+ with_filters(
113
+ :push => {
114
+ :create_app => proc { |a|
115
+ setup_env(a, app)
116
+ a
117
+ },
118
+ :push_app => proc { |a|
119
+ setup_services(a, app)
120
+ a
121
+ }
122
+ }) do
123
+ # only set inputs if creating app or updating with --reset
124
+ if input[:reset] || !client.app_by_name(app[:name])
125
+ app_input = input.merge_given(app)
126
+ else
127
+ app_input = input.merge(:path => from_manifest(app[:path]))
128
+ end
129
+
130
+ push.call(app_input.merge(
131
+ :name => app[:name],
132
+ :bind_services => false,
133
+ :create_services => false))
134
+ end
135
+ end
130
136
  end
131
137
  end
132
138
  end
@@ -1,3 +1,3 @@
1
1
  module VMCManifests
2
- VERSION = "0.4.10"
2
+ VERSION = "0.4.11"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: manifests-vmc-plugin
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
- - 10
10
- version: 0.4.10
9
+ - 11
10
+ version: 0.4.11
11
11
  platform: ruby
12
12
  authors:
13
13
  - Alex Suraci
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-10-19 00:00:00 Z
18
+ date: 2012-11-02 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: cfoundry