manifests-vmc-plugin 0.4.4 → 0.4.5
Sign up to get free protection for your applications and to get access to all the features.
data/lib/manifests-vmc-plugin.rb
CHANGED
@@ -366,105 +366,6 @@ module VMCManifests
|
|
366
366
|
ordered
|
367
367
|
end
|
368
368
|
|
369
|
-
# detect changes in app info, and update the app if necessary.
|
370
|
-
#
|
371
|
-
# redeploys the app if necessary (after prompting the user), e.g. for
|
372
|
-
# runtime/framework change
|
373
|
-
def sync_changes(info)
|
374
|
-
app = client.app_by_name(info[:name])
|
375
|
-
return unless app
|
376
|
-
|
377
|
-
diff = {}
|
378
|
-
need_restage = []
|
379
|
-
info.each do |k, v|
|
380
|
-
case k.to_s
|
381
|
-
when /ur[li]s?/
|
382
|
-
old = app.urls
|
383
|
-
new = Array(v)
|
384
|
-
if old != new
|
385
|
-
diff[:urls] = [old.inspect, new.inspect]
|
386
|
-
app.urls = new
|
387
|
-
end
|
388
|
-
when "env"
|
389
|
-
old = app.env
|
390
|
-
if old != v
|
391
|
-
diff[k] = [old.inspect, v.inspect]
|
392
|
-
app.env = v
|
393
|
-
end
|
394
|
-
when "framework", "runtime"
|
395
|
-
old = app.send(k)
|
396
|
-
new = client.send(:"#{k}_by_name", v)
|
397
|
-
|
398
|
-
if old != new
|
399
|
-
diff[k] = [old.name, new.name]
|
400
|
-
app.send(:"#{k}=", new)
|
401
|
-
need_restage << k
|
402
|
-
end
|
403
|
-
when "command"
|
404
|
-
old = app.command
|
405
|
-
if old != v
|
406
|
-
diff[k] = [old, v]
|
407
|
-
app.send(:"#{k}=", v)
|
408
|
-
need_restage << k
|
409
|
-
end
|
410
|
-
when "instances"
|
411
|
-
old = app.total_instances
|
412
|
-
if old != v
|
413
|
-
diff[k] = [old, v]
|
414
|
-
app.total_instances = v
|
415
|
-
end
|
416
|
-
when "mem", "memory"
|
417
|
-
old = app.memory
|
418
|
-
new = megabytes(v)
|
419
|
-
|
420
|
-
if old != new
|
421
|
-
diff[:memory] = [human_size(old * 1024 * 1024, 0), v]
|
422
|
-
app.memory = new
|
423
|
-
end
|
424
|
-
end
|
425
|
-
end
|
426
|
-
|
427
|
-
return if diff.empty?
|
428
|
-
|
429
|
-
unless quiet?
|
430
|
-
puts "Detected the following changes to #{c(app.name, :name)}:"
|
431
|
-
diff.each do |k, d|
|
432
|
-
old, new = d
|
433
|
-
label = c(k, need_restage.include?(k) ? :bad : :good)
|
434
|
-
puts " #{label}: #{old} #{c("->", :dim)} #{new}"
|
435
|
-
end
|
436
|
-
|
437
|
-
puts ""
|
438
|
-
end
|
439
|
-
|
440
|
-
if need_restage.empty?
|
441
|
-
with_progress("Updating #{c(app.name, :name)}") do
|
442
|
-
app.update!
|
443
|
-
end
|
444
|
-
else
|
445
|
-
unless quiet?
|
446
|
-
puts "The following changes require the app to be recreated:"
|
447
|
-
need_restage.each do |n|
|
448
|
-
puts " #{c(n, :error)}"
|
449
|
-
end
|
450
|
-
puts ""
|
451
|
-
end
|
452
|
-
|
453
|
-
if force? || ask("Redeploy?", :default => false)
|
454
|
-
bindings = app.services
|
455
|
-
|
456
|
-
with_progress("Deleting #{c(app.name, :name)}") do
|
457
|
-
app.delete!
|
458
|
-
end
|
459
|
-
|
460
|
-
with_progress("Recreating #{c(app.name, :name)}") do
|
461
|
-
app.create!
|
462
|
-
app.bind(*bindings)
|
463
|
-
end
|
464
|
-
end
|
465
|
-
end
|
466
|
-
end
|
467
|
-
|
468
369
|
def ask_to_save(input, app)
|
469
370
|
return if manifest_file
|
470
371
|
|
@@ -79,7 +79,11 @@ class Manifests < VMC::CLI
|
|
79
79
|
# vmc push [name in manifest] = push that app from its path
|
80
80
|
# vmc push [name not in manifest] = push new app using given name
|
81
81
|
# vmc push [path] = push app from its path
|
82
|
-
change_argument
|
82
|
+
change_argument :push, :name, :optional
|
83
|
+
|
84
|
+
add_input :push, :reset, :type => :boolean, :default => false,
|
85
|
+
:desc => "Reset to values in the manifest"
|
86
|
+
|
83
87
|
around(:push) do |push, input|
|
84
88
|
app =
|
85
89
|
if input.given?(:name)
|
@@ -92,8 +96,6 @@ class Manifests < VMC::CLI
|
|
92
96
|
app ||= app_info(".", input)
|
93
97
|
|
94
98
|
if app
|
95
|
-
sync_changes(app)
|
96
|
-
|
97
99
|
with_filters(
|
98
100
|
:push => {
|
99
101
|
:create_app => proc { |a|
|
@@ -105,7 +107,13 @@ class Manifests < VMC::CLI
|
|
105
107
|
a
|
106
108
|
}
|
107
109
|
}) do
|
108
|
-
|
110
|
+
# only set inputs if creating app or updating with --reset
|
111
|
+
if input[:reset] || !client.app_by_name(app[:name])
|
112
|
+
input = input.merge_given(app)
|
113
|
+
end
|
114
|
+
|
115
|
+
push.call(input.merge(
|
116
|
+
:name => app[:name],
|
109
117
|
:bind_services => false,
|
110
118
|
:create_services => false))
|
111
119
|
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:
|
4
|
+
hash: 5
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 4
|
9
|
-
-
|
10
|
-
version: 0.4.
|
9
|
+
- 5
|
10
|
+
version: 0.4.5
|
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-
|
18
|
+
date: 2012-09-12 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: cfoundry
|