manifests-vmc-plugin 0.3.0 → 0.3.1
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.
- data/lib/manifests-vmc-plugin.rb +70 -40
- data/lib/manifests-vmc-plugin/plugin.rb +41 -34
- data/lib/manifests-vmc-plugin/version.rb +1 -1
- metadata +3 -3
data/lib/manifests-vmc-plugin.rb
CHANGED
@@ -41,10 +41,27 @@ module VMCManifests
|
|
41
41
|
@manifest_file
|
42
42
|
end
|
43
43
|
|
44
|
+
# convert any deprecated structuring to the modern format
|
45
|
+
def simplify_info(info)
|
46
|
+
if info["framework"].is_a?(Hash)
|
47
|
+
info["framework"] = info["framework"]["name"]
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
44
51
|
# load and resolve a given manifest file
|
45
52
|
def load_manifest(file)
|
46
53
|
manifest = build_manifest(file)
|
47
54
|
resolve_manifest(manifest)
|
55
|
+
|
56
|
+
# single-app manifest
|
57
|
+
simplify_info(manifest)
|
58
|
+
|
59
|
+
if apps = manifest["applications"]
|
60
|
+
apps.each do |path, info|
|
61
|
+
simplify_info(info)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
48
65
|
manifest
|
49
66
|
end
|
50
67
|
|
@@ -180,37 +197,43 @@ module VMCManifests
|
|
180
197
|
MANIFEST_META.include? k
|
181
198
|
end
|
182
199
|
|
183
|
-
if info["framework"].is_a?(Hash)
|
184
|
-
info["framework"] = info["framework"]["name"]
|
185
|
-
end
|
186
|
-
|
187
200
|
info
|
188
201
|
end
|
189
202
|
end
|
190
203
|
|
191
|
-
def
|
204
|
+
def app_by_name(name, input = nil)
|
192
205
|
return unless manifest
|
193
206
|
|
194
|
-
|
195
|
-
|
207
|
+
if apps = manifest["applications"]
|
208
|
+
manifest["applications"].find do |path, info|
|
209
|
+
info["name"] == name
|
210
|
+
end
|
211
|
+
elsif name == manifest["name"]
|
212
|
+
[".", toplevel_attributes]
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
def app_by_path(find_path)
|
217
|
+
return unless manifest
|
196
218
|
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
if info["framework"].is_a?(Hash)
|
201
|
-
info["framework"] = info["framework"]["name"]
|
202
|
-
end
|
219
|
+
if apps = manifest["applications"]
|
220
|
+
mandir = File.dirname(manifest_file)
|
221
|
+
full_path = File.expand_path(find_path, mandir)
|
203
222
|
|
204
|
-
|
205
|
-
|
206
|
-
end
|
207
|
-
elsif find_path == "."
|
208
|
-
[".", {}]
|
223
|
+
manifest["applications"].find do |path, info|
|
224
|
+
File.expand_path(path, mandir) == full_path
|
209
225
|
end
|
226
|
+
elsif find_path == "."
|
227
|
+
[".", toplevel_attributes]
|
228
|
+
end
|
229
|
+
end
|
210
230
|
|
231
|
+
def app_info(path_or_name, input = nil)
|
232
|
+
path, info = app_by_name(path_or_name) || app_by_path(path_or_name)
|
211
233
|
return unless info
|
212
234
|
|
213
|
-
|
235
|
+
abspath = File.expand_path(path, File.dirname(manifest_file))
|
236
|
+
data = { :path => abspath }
|
214
237
|
|
215
238
|
toplevel_attributes.merge(info).each do |k, v|
|
216
239
|
name = k.to_sym
|
@@ -248,51 +271,58 @@ module VMCManifests
|
|
248
271
|
end
|
249
272
|
end
|
250
273
|
|
274
|
+
|
275
|
+
def no_apps
|
276
|
+
fail "No applications or manifest to operate on."
|
277
|
+
end
|
278
|
+
|
251
279
|
# like each_app, but only acts on apps specified as paths instead of names
|
252
280
|
#
|
253
281
|
# returns the names that were not paths
|
254
282
|
def specific_apps_or_all(input = nil, use_name = true, &blk)
|
255
|
-
return false unless manifest && apps = manifest["applications"]
|
256
|
-
|
257
|
-
use_name = false if apps.size > 1
|
258
|
-
|
259
283
|
names_or_paths =
|
260
284
|
if input.given?(:names)
|
261
|
-
|
285
|
+
# names may be given but be [], which will still cause
|
286
|
+
# interaction, so use #given instead of #[] here
|
287
|
+
input.given(:names)
|
262
288
|
elsif input.given?(:name)
|
263
289
|
[input[:name]]
|
264
290
|
else
|
265
291
|
[]
|
266
292
|
end
|
267
293
|
|
268
|
-
|
294
|
+
unless manifest
|
295
|
+
if names_or_paths.empty?
|
296
|
+
return false
|
297
|
+
else
|
298
|
+
return names_or_paths
|
299
|
+
end
|
300
|
+
end
|
301
|
+
|
302
|
+
if names_or_paths.empty?
|
303
|
+
each_app(input, &blk)
|
304
|
+
return []
|
305
|
+
end
|
269
306
|
|
270
307
|
input = input.without(:name, :names)
|
271
308
|
|
272
|
-
|
273
|
-
|
309
|
+
in_manifest = []
|
310
|
+
external = []
|
274
311
|
names_or_paths.each do |x|
|
275
312
|
path = File.expand_path(x)
|
276
313
|
|
277
|
-
if File.exists?(path)
|
278
|
-
|
314
|
+
if app = app_info(File.exists?(path) ? path : x, input)
|
315
|
+
in_manifest << app
|
279
316
|
else
|
280
|
-
|
317
|
+
external << x
|
281
318
|
end
|
282
319
|
end
|
283
320
|
|
284
|
-
|
285
|
-
blk.call
|
286
|
-
end
|
287
|
-
|
288
|
-
if use_name && names.size == 1
|
289
|
-
blk.call(
|
290
|
-
app_info(
|
291
|
-
manifest["applications"].keys.first,
|
292
|
-
input.merge(:name => names.first)))
|
321
|
+
in_manifest.each do |app|
|
322
|
+
blk.call app
|
293
323
|
end
|
294
324
|
|
295
|
-
|
325
|
+
external
|
296
326
|
end
|
297
327
|
|
298
328
|
|
@@ -10,7 +10,7 @@ class Manifests < VMC::CLI
|
|
10
10
|
|
11
11
|
|
12
12
|
def no_apps
|
13
|
-
|
13
|
+
fail "No applications or manifest to operate on."
|
14
14
|
end
|
15
15
|
|
16
16
|
|
@@ -19,21 +19,22 @@ class Manifests < VMC::CLI
|
|
19
19
|
[ :start, :instances, :logs, :file, :files, :env,
|
20
20
|
:health, :stats, :scale
|
21
21
|
].each do |wrap|
|
22
|
-
change_argument(wrap, :name, :optional)
|
22
|
+
optional_name = change_argument(wrap, :name, :optional)
|
23
23
|
|
24
24
|
around(wrap) do |cmd, input|
|
25
|
-
|
25
|
+
rest =
|
26
26
|
specific_apps_or_all(input) do |app|
|
27
|
-
cmd.call(input.merge(:name => app[:name]))
|
27
|
+
cmd.call(input.without(:names).merge(:name => app[:name]))
|
28
28
|
puts "" unless quiet?
|
29
29
|
end
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
|
31
|
+
if rest
|
32
|
+
rest.each do |n|
|
33
|
+
cmd.call(input.merge(:name => n))
|
34
|
+
end
|
34
35
|
|
35
|
-
#
|
36
|
-
elsif
|
36
|
+
# fail manually for commands whose name we made optional
|
37
|
+
elsif optional_name
|
37
38
|
no_apps
|
38
39
|
end
|
39
40
|
end
|
@@ -46,48 +47,54 @@ class Manifests < VMC::CLI
|
|
46
47
|
next cmd.call if input[:all]
|
47
48
|
|
48
49
|
reversed = []
|
49
|
-
|
50
|
+
rest =
|
50
51
|
specific_apps_or_all(input) do |app|
|
51
52
|
reversed.unshift app[:name]
|
52
53
|
end
|
53
54
|
|
54
|
-
|
55
|
-
|
56
|
-
cmd.call(input.merge(:names => use_manifest))
|
57
|
-
|
58
|
-
# no manifest or no apps described by it
|
59
|
-
elsif !use_manifest
|
60
|
-
next no_apps
|
55
|
+
unless reversed.empty?
|
56
|
+
cmd.call(input.merge(:names => reversed))
|
61
57
|
end
|
62
58
|
|
63
|
-
|
59
|
+
if rest
|
60
|
+
cmd.call(input.merge(:names => rest)) unless rest.empty?
|
61
|
+
else
|
62
|
+
cmd.call(input.without(:names))
|
63
|
+
end
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
67
|
|
68
68
|
# push and sync meta changes in the manifest
|
69
69
|
# also sets env data on creation if present in manifest
|
70
|
+
#
|
71
|
+
# vmc push [name in manifest] = push that app from its path
|
72
|
+
# vmc push [name not in manifest] = push new app using given name
|
73
|
+
# vmc push [path] = push app from its path
|
70
74
|
change_argument(:push, :name, :optional)
|
71
75
|
around(:push) do |push, input|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
:push_app =>
|
79
|
-
proc { |a| setup_app(a, app); a }
|
80
|
-
}) do
|
81
|
-
push.call(
|
82
|
-
input.merge(app).merge(
|
83
|
-
:bind_services => false,
|
84
|
-
:create_services => false))
|
85
|
-
end
|
76
|
+
app =
|
77
|
+
if input.given?(:name)
|
78
|
+
path = File.expand_path(input[:name])
|
79
|
+
find_by = File.exists?(path) ? path : input[:name]
|
80
|
+
|
81
|
+
app_info(find_by, input.without(:name))
|
86
82
|
end
|
87
83
|
|
88
|
-
|
89
|
-
bound = []
|
84
|
+
app ||= app_info(".", input)
|
90
85
|
|
86
|
+
if app
|
87
|
+
sync_changes(app)
|
88
|
+
|
89
|
+
with_filters(
|
90
|
+
:push => {
|
91
|
+
:push_app => proc { |a| setup_app(a, app); a }
|
92
|
+
}) do
|
93
|
+
push.call(input.merge(app).merge(
|
94
|
+
:bind_services => false,
|
95
|
+
:create_services => false))
|
96
|
+
end
|
97
|
+
else
|
91
98
|
with_filters(
|
92
99
|
:push => {
|
93
100
|
:push_app =>
|
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: 17
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 1
|
10
|
+
version: 0.3.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Alex Suraci
|