dapp 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/dapp/builder/chef.rb +95 -105
- data/lib/dapp/builder/chef/berksfile.rb +2 -1
- data/lib/dapp/helper/sha256.rb +7 -0
- data/lib/dapp/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: 179056218ee2a02f2ffdfde2690975b9488688ab
|
4
|
+
data.tar.gz: 3d11dfb1d6681698baf231ca52977fffeea3f89b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 45d2a40d9f64aed890272df4ec5c1e3a488f8b3d58cfa4018272a03ce33f012a81a80c8ac4dc60967cc3933aabb3d0b1058ea519fc504b8b2e5f533e5b6e75c4
|
7
|
+
data.tar.gz: 824abefb9e41019be8fb285a2b6350d05803382c4d1003ac4e6938149cbd50c1a2fe955801678ef0c3dc80a0b596f9e51cc5d8684b845d273aab1f9a0695b331
|
data/lib/dapp/builder/chef.rb
CHANGED
@@ -82,22 +82,6 @@ module Dapp
|
|
82
82
|
application.hashsum berksfile_lock_path.read if berksfile_lock_path.exist?
|
83
83
|
end
|
84
84
|
|
85
|
-
def local_cookbook_paths_for_checksum
|
86
|
-
@local_cookbook_paths_for_checksum ||= berksfile
|
87
|
-
.local_cookbooks
|
88
|
-
.values
|
89
|
-
.map { |cookbook| cookbook[:path] }
|
90
|
-
.product(LOCAL_COOKBOOK_CHECKSUM_PATTERNS)
|
91
|
-
.map { |cb, dir| Dir[cb.join(dir)] }
|
92
|
-
.flatten
|
93
|
-
.map(&Pathname.method(:new))
|
94
|
-
end
|
95
|
-
|
96
|
-
def stage_cookbooks_paths_for_checksum(stage)
|
97
|
-
install_stage_cookbooks(stage)
|
98
|
-
Dir[stage_cookbooks_path(stage, '**/*')].map(&Pathname.method(:new))
|
99
|
-
end
|
100
|
-
|
101
85
|
def stage_cookbooks_checksum_path(stage)
|
102
86
|
application.build_path("#{cookbooks_checksum}.#{stage}.checksum")
|
103
87
|
end
|
@@ -109,8 +93,11 @@ module Dapp
|
|
109
93
|
checksum = if stage == :chef_cookbooks
|
110
94
|
cookbooks_checksum
|
111
95
|
else
|
96
|
+
paths = Dir[stage_cookbooks_path(stage, '**/*')].map(&Pathname.method(:new))
|
97
|
+
|
112
98
|
application.hashsum [
|
113
|
-
|
99
|
+
application.paths_content_hashsum(paths),
|
100
|
+
*paths.map { |p| p.relative_path_from(stage_cookbooks_path(stage)).to_s }.sort,
|
114
101
|
*enabled_modules,
|
115
102
|
stage == :infra_install ? chefdk_image : nil
|
116
103
|
].compact
|
@@ -122,11 +109,23 @@ module Dapp
|
|
122
109
|
end
|
123
110
|
|
124
111
|
def cookbooks_checksum
|
125
|
-
@cookbooks_checksum ||=
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
112
|
+
@cookbooks_checksum ||= begin
|
113
|
+
paths = berksfile
|
114
|
+
.local_cookbooks
|
115
|
+
.values
|
116
|
+
.map { |cookbook| cookbook[:path] }
|
117
|
+
.product(LOCAL_COOKBOOK_CHECKSUM_PATTERNS)
|
118
|
+
.map { |cb, dir| Dir[cb.join(dir)] }
|
119
|
+
.flatten
|
120
|
+
.map(&Pathname.method(:new))
|
121
|
+
|
122
|
+
application.hashsum [
|
123
|
+
application.paths_content_hashsum(paths),
|
124
|
+
*paths.map { |p| p.relative_path_from(berksfile.home_path).to_s }.sort,
|
125
|
+
berksfile_lock_checksum,
|
126
|
+
*enabled_modules
|
127
|
+
]
|
128
|
+
end
|
130
129
|
end
|
131
130
|
|
132
131
|
def chefdk_image
|
@@ -193,8 +192,6 @@ module Dapp
|
|
193
192
|
"dappdeps/berksdeps:0.1.0 bash -ec '#{application.shellout_pack(vendor_commands.join(' && '))}'"].compact.join(' '),
|
194
193
|
log_verbose: application.log_verbose?
|
195
194
|
)
|
196
|
-
|
197
|
-
true
|
198
195
|
end
|
199
196
|
end
|
200
197
|
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize
|
@@ -211,80 +208,77 @@ module Dapp
|
|
211
208
|
|
212
209
|
# rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
213
210
|
def install_stage_cookbooks(stage)
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
["templates/#{stage}", 'templates/default']].select { |from, _| cookbook_path.join(from).exist? }
|
222
|
-
end
|
211
|
+
common_paths = proc do |cookbook_path|
|
212
|
+
[['metadata.json', 'metadata.json'],
|
213
|
+
['attributes/common', 'attributes'],
|
214
|
+
["attributes/#{stage}", 'attributes'],
|
215
|
+
["files/#{stage}", 'files/default'],
|
216
|
+
["templates/#{stage}", 'templates/default']].select { |from, _| cookbook_path.join(from).exist? }
|
217
|
+
end
|
223
218
|
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
else
|
241
|
-
[nil, *common_paths[cookbook_path]]
|
242
|
-
end
|
243
|
-
elsif is_mdapp && mdapp_enabled
|
244
|
-
recipe_path = "recipes/#{stage}.rb"
|
245
|
-
|
246
|
-
if cookbook_path.join(recipe_path).exist?
|
247
|
-
[[recipe_path, recipe_path], *common_paths[cookbook_path]]
|
248
|
-
else
|
249
|
-
[nil, *common_paths[cookbook_path]]
|
250
|
-
end
|
219
|
+
install_paths = Dir[cookbooks_vendor_path('*')]
|
220
|
+
.map(&Pathname.method(:new))
|
221
|
+
.map do |cookbook_path|
|
222
|
+
cookbook_name = File.basename cookbook_path
|
223
|
+
is_project = (cookbook_name == project_name)
|
224
|
+
is_mdapp = cookbook_name.start_with? 'mdapp-'
|
225
|
+
mdapp_name = (is_mdapp ? cookbook_name.split('mdapp-')[1] : nil)
|
226
|
+
mdapp_enabled = is_mdapp && enabled_modules.include?(mdapp_name)
|
227
|
+
|
228
|
+
paths = if is_project
|
229
|
+
recipe_paths = enabled_recipes
|
230
|
+
.map { |recipe| ["recipes/#{stage}/#{recipe}.rb", "recipes/#{recipe}.rb"] }
|
231
|
+
.select { |from, _| cookbook_path.join(from).exist? }
|
232
|
+
|
233
|
+
if recipe_paths.any?
|
234
|
+
[*recipe_paths, *common_paths[cookbook_path]]
|
251
235
|
else
|
252
|
-
[
|
236
|
+
[nil, *common_paths[cookbook_path]]
|
253
237
|
end
|
238
|
+
elsif is_mdapp && mdapp_enabled
|
239
|
+
recipe_path = "recipes/#{stage}.rb"
|
254
240
|
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
install_paths.each do |cookbook_path, paths|
|
260
|
-
cookbook = cookbook_path.basename
|
261
|
-
|
262
|
-
paths.each do |from, to|
|
263
|
-
if from.nil?
|
264
|
-
to_path = stage_cookbooks_path(stage, cookbook, 'recipes/void.rb')
|
265
|
-
to_path.parent.mkpath
|
266
|
-
FileUtils.touch to_path
|
267
|
-
else
|
268
|
-
from_path = cookbook_path.join(from)
|
269
|
-
to_path = stage_cookbooks_path(stage, cookbook, to)
|
270
|
-
if from_path.directory? && to_path.exist?
|
271
|
-
Dir[from_path.join('**/*')]
|
272
|
-
.map(&Pathname.method(:new))
|
273
|
-
.each do |from_subpath|
|
274
|
-
to_subpath = to_path.join(from_subpath.relative_path_from(from_path))
|
275
|
-
raise Error, code: :stage_path_overlap,
|
276
|
-
data: { stage: stage,
|
277
|
-
cookbook: cookbook,
|
278
|
-
from: from_subpath.relative_path_from(cookbook_path),
|
279
|
-
to: to_subpath.relative_path_from(stage_cookbooks_path(stage, cookbook)) } if to_subpath.exist?
|
280
|
-
|
281
|
-
to_subpath.parent.mkpath
|
282
|
-
FileUtils.cp_r from_subpath, to_subpath
|
241
|
+
if cookbook_path.join(recipe_path).exist?
|
242
|
+
[[recipe_path, recipe_path], *common_paths[cookbook_path]]
|
243
|
+
else
|
244
|
+
[nil, *common_paths[cookbook_path]]
|
283
245
|
end
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
246
|
+
else
|
247
|
+
[['.', '.']]
|
248
|
+
end
|
249
|
+
|
250
|
+
[cookbook_path, paths] if paths && paths.any?
|
251
|
+
end.compact
|
252
|
+
|
253
|
+
_stage_cookbooks_path(stage).mkpath
|
254
|
+
install_paths.each do |cookbook_path, paths|
|
255
|
+
cookbook = cookbook_path.basename
|
256
|
+
|
257
|
+
paths.each do |from, to|
|
258
|
+
if from.nil?
|
259
|
+
to_path = _stage_cookbooks_path(stage).join(cookbook, 'recipes/void.rb')
|
260
|
+
to_path.parent.mkpath
|
261
|
+
FileUtils.touch to_path
|
262
|
+
else
|
263
|
+
from_path = cookbook_path.join(from)
|
264
|
+
to_path = _stage_cookbooks_path(stage).join(cookbook, to)
|
265
|
+
if from_path.directory? && to_path.exist?
|
266
|
+
Dir[from_path.join('**/*')]
|
267
|
+
.map(&Pathname.method(:new))
|
268
|
+
.each do |from_subpath|
|
269
|
+
to_subpath = to_path.join(from_subpath.relative_path_from(from_path))
|
270
|
+
raise Error, code: :stage_path_overlap,
|
271
|
+
data: { stage: stage,
|
272
|
+
cookbook: cookbook,
|
273
|
+
from: from_subpath.relative_path_from(cookbook_path),
|
274
|
+
to: to_subpath.relative_path_from(_stage_cookbooks_path(stage).join(cookbook)) } if to_subpath.exist?
|
275
|
+
|
276
|
+
to_subpath.parent.mkpath
|
277
|
+
FileUtils.cp_r from_subpath, to_subpath
|
278
|
+
end
|
279
|
+
else
|
280
|
+
to_path.parent.mkpath
|
281
|
+
FileUtils.cp_r from_path, to_path
|
288
282
|
end
|
289
283
|
end
|
290
284
|
end
|
@@ -294,8 +288,6 @@ module Dapp
|
|
294
288
|
|
295
289
|
# rubocop:disable Metrics/AbcSize
|
296
290
|
def stage_cookbooks_runlist(stage)
|
297
|
-
install_stage_cookbooks(stage)
|
298
|
-
|
299
291
|
@stage_cookbooks_runlist ||= {}
|
300
292
|
@stage_cookbooks_runlist[stage] ||= begin
|
301
293
|
res = []
|
@@ -344,8 +336,15 @@ module Dapp
|
|
344
336
|
stage_cookbooks_runlist(stage).empty?
|
345
337
|
end
|
346
338
|
|
339
|
+
def _stage_cookbooks_path(stage)
|
340
|
+
stage_build_path(stage, 'cookbooks')
|
341
|
+
end
|
342
|
+
|
347
343
|
def stage_cookbooks_path(stage, *path)
|
348
|
-
|
344
|
+
_stage_cookbooks_path(stage).tap do |cookbooks_path|
|
345
|
+
@install_stage_cookbooks ||= {}
|
346
|
+
@install_stage_cookbooks[stage] ||= true.tap { install_stage_cookbooks(stage) }
|
347
|
+
end.join(*path)
|
349
348
|
end
|
350
349
|
|
351
350
|
def install_chef_solo_stage_config(stage)
|
@@ -370,15 +369,6 @@ module Dapp
|
|
370
369
|
def container_stage_build_path(_stage, *path)
|
371
370
|
path.compact.map(&:to_s).inject(Pathname.new('/.dapp/chef/build'), &:+)
|
372
371
|
end
|
373
|
-
|
374
|
-
def _paths_checksum(paths)
|
375
|
-
application.hashsum [
|
376
|
-
*paths.map(&:to_s).sort,
|
377
|
-
*paths.reject(&:directory?)
|
378
|
-
.sort
|
379
|
-
.reduce(nil) { |a, e| application.hashsum [a, e.read].compact }
|
380
|
-
]
|
381
|
-
end
|
382
372
|
end
|
383
373
|
end
|
384
374
|
end
|
@@ -26,6 +26,7 @@ module Dapp
|
|
26
26
|
end
|
27
27
|
end # Parser
|
28
28
|
|
29
|
+
attr_reader :home_path
|
29
30
|
attr_reader :path
|
30
31
|
attr_reader :local_cookbooks
|
31
32
|
|
@@ -39,7 +40,7 @@ module Dapp
|
|
39
40
|
def add_local_cookbook_path(name, path)
|
40
41
|
@local_cookbooks[name] = {
|
41
42
|
name: name,
|
42
|
-
path:
|
43
|
+
path: home_path.join(path)
|
43
44
|
}
|
44
45
|
end
|
45
46
|
|
data/lib/dapp/helper/sha256.rb
CHANGED
@@ -6,6 +6,13 @@ module Dapp
|
|
6
6
|
sha256(arg)
|
7
7
|
end
|
8
8
|
|
9
|
+
def paths_content_hashsum(paths)
|
10
|
+
paths.map(&:to_s)
|
11
|
+
.reject { |path| File.directory?(path) }
|
12
|
+
.sort
|
13
|
+
.reduce(nil) { |hash, path| hashsum [hash, File.read(path)].compact }
|
14
|
+
end
|
15
|
+
|
9
16
|
def sha256(arg)
|
10
17
|
Digest::SHA256.hexdigest Array(arg).compact.map(&:to_s).join(':::')
|
11
18
|
end
|
data/lib/dapp/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dapp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dmitry Stolyarov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-08-
|
11
|
+
date: 2016-08-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mixlib-shellout
|