dapp 0.7.18 → 0.7.19

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: a0dcb2453cc6b24dceb7490d086e4c755c56d4c7
4
- data.tar.gz: 438de659b1cde4c9312e959cdb406a51a99e3363
3
+ metadata.gz: 0fb95faf56ca420cff6868898fb7507b2282f0d0
4
+ data.tar.gz: bf64455dcb33e447d8044c898d0159f2e5290eb9
5
5
  SHA512:
6
- metadata.gz: a2f7072fc7882ef94e2d9864ef7bad40dad70d820a679b2267da3316931118c6a02bfbced85ec3c451b5bc47ce58975e12d85e50225501ba90727ef6e27e61d0
7
- data.tar.gz: e682d5bc70806fcd53af05c2ded8dc9a16471dff0ee5d6774038ff8ec4f4035cc629320a787991e515cbc09defb3e2e84a113cc539085d8dcbfa2b7623489d74
6
+ metadata.gz: 5bd04cc708034bd5bdade09dba0bf77f0d2c0d8c0ed434409b32437fca1ffaa86bd25b3c296fc8eab22b80234caf3eeb0922ae6c834d541d8c60cb6eb0d9bfac
7
+ data.tar.gz: 2a992ce6691468ac9207592e3cea2011664213768a86189b2def78da5acea80ef5df6cb3116a3038b28268472b4670aeabcb703d4b9bd205866cfebb43d44e13
@@ -55,6 +55,7 @@ en:
55
55
  tag_ignored: "WARNING: tag `%{tag}` ignored."
56
56
  dimg_not_found_in_registry: "WARNING: Dimg not found in registry."
57
57
  stage_artifact_rewritten: "WARNING: Artifact stage rewritten from %{conflict_stage} to %{stage}."
58
+ recipe_does_not_used: "WARNING: Recipe `%{recipe}` doesn't used in any stage."
58
59
  group:
59
60
  install_group: 'Install group'
60
61
  setup_group: 'Setup group'
@@ -18,10 +18,10 @@ module Dapp
18
18
  group = artifact[:options][:group]
19
19
  to = artifact[:options][:to]
20
20
 
21
- command = safe_cp(to, artifact_dimg.container_tmp_path(artifact_name), Process.uid, Process.gid, cwd, include_paths, exclude_paths)
21
+ command = safe_cp(cwd, artifact_dimg.container_tmp_path(artifact_name).to_s, Process.uid, Process.gid, include_paths, exclude_paths)
22
22
  run_artifact_dimg(artifact_dimg, artifact_name, command)
23
23
 
24
- command = safe_cp(dimg.container_tmp_path('artifact', artifact_name), to, owner, group, '', include_paths, exclude_paths)
24
+ command = safe_cp(dimg.container_tmp_path('artifact', artifact_name).to_s, to, owner, group, include_paths, exclude_paths)
25
25
  image.add_command command
26
26
  image.add_volume "#{dimg.tmp_path('artifact', artifact_name)}:#{dimg.container_tmp_path('artifact', artifact_name)}:ro"
27
27
  end
@@ -30,33 +30,32 @@ module Dapp
30
30
  private
31
31
 
32
32
  # rubocop:disable Metrics/ParameterLists, Metrics/AbcSize, Metrics/MethodLength
33
- def safe_cp(from, to, owner, group, cwd = '', include_paths = [], exclude_paths = [])
33
+ def safe_cp(from, to, owner, group, include_paths = [], exclude_paths = [])
34
34
  credentials = ''
35
35
  credentials += "-o #{owner} " if owner
36
36
  credentials += "-g #{group} " if group
37
- excludes = find_command_excludes(from, cwd, exclude_paths).join(' ')
37
+ excludes = find_command_excludes(from, exclude_paths).join(' ')
38
38
 
39
- copy_files = proc do |from_, cwd_, path_ = ''|
40
- cwd_ = File.expand_path(File.join('/', cwd_))
41
- "if [[ -d #{File.join(from_, cwd_, path_)} ]]; then " \
42
- "#{dimg.project.find_bin} #{File.join(from_, cwd_, path_)} #{excludes} -type f -exec " \
39
+ copy_files = proc do |from_, path_ = ''|
40
+ "if [[ -d #{File.join(from_, path_)} ]]; then " \
41
+ "#{dimg.project.find_bin} #{File.join(from_, path_)} #{excludes} -type f -exec " \
43
42
  "#{dimg.project.bash_bin} -ec '#{dimg.project.install_bin} -D #{credentials} {} " \
44
43
  "#{File.join(to, '$(echo {} | ' \
45
- "#{dimg.project.sed_bin} -e \"s/#{File.join(from_, cwd_).gsub('/', '\\/')}//g\")")}' \\; ;" \
44
+ "#{dimg.project.sed_bin} -e \"s/#{from_.gsub('/', '\\/')}//g\")")}' \\; ;" \
46
45
  'fi'
47
46
  end
48
47
 
49
48
  commands = []
50
49
  commands << [dimg.project.install_bin, credentials, '-d', to].join(' ')
51
- commands.concat(include_paths.empty? ? Array(copy_files.call(from, cwd)) : include_paths.map { |path| copy_files.call(from, cwd, path) })
50
+ commands.concat(include_paths.empty? ? Array(copy_files.call(from)) : include_paths.map { |path| copy_files.call(from, path) })
52
51
  commands << "#{dimg.project.find_bin} #{to} -type d -exec " \
53
52
  "#{dimg.project.bash_bin} -ec '#{dimg.project.install_bin} -d #{credentials} {}' \\;"
54
53
  commands.join(' && ')
55
54
  end
56
55
  # rubocop:enable Metrics/ParameterLists, Metrics/AbcSize, Metrics/MethodLength
57
56
 
58
- def find_command_excludes(from, cwd, exclude_paths)
59
- exclude_paths.map { |path| "-not \\( -path #{File.join(from, cwd, path)} -prune \\)" }
57
+ def find_command_excludes(from, exclude_paths)
58
+ exclude_paths.map { |path| "-not \\( -path #{File.join(from, path)} -prune \\)" }
60
59
  end
61
60
  end # ArtifactDefault
62
61
  end # Stage
@@ -50,11 +50,7 @@ module Dapp
50
50
  container_archive_path = File.join(artifact_dimg.container_tmp_path(artifact_name), 'archive.tar.gz')
51
51
 
52
52
  exclude_paths = artifact[:options][:exclude_paths].map { |path| "--exclude=#{path}" }.join(' ')
53
- include_paths = if include_paths.empty?
54
- [File.join(to, cwd, '*')]
55
- else
56
- include_paths.map { |path| File.join(to, cwd, path, '*') }
57
- end
53
+ include_paths = include_paths.empty? ? [File.join(cwd, '*')] : include_paths.map { |path| File.join(cwd, path, '*') }
58
54
  include_paths.map! { |path| path[1..-1] } # relative path
59
55
 
60
56
  command = "#{sudo} #{dimg.project.tar_bin} -czf #{container_archive_path} #{exclude_paths} #{include_paths.join(' ')} #{credentials}"
@@ -8,6 +8,9 @@ module Dapp
8
8
  @dimg = dimg
9
9
  end
10
10
 
11
+ def before_build_check
12
+ end
13
+
11
14
  def before_dimg_should_be_built_check
12
15
  end
13
16
 
@@ -57,8 +57,26 @@ module Dapp
57
57
  end
58
58
  end
59
59
 
60
+ def before_build_check
61
+ %i(before_install install before_setup setup build_artifact).tap do |stages|
62
+ (enabled_recipes - stages.map { |stage| stage_enabled_recipes(stage) }.flatten.uniq).each do |recipe|
63
+ dimg.project.log_warning(desc: { code: :recipe_does_not_used, data: { recipe: recipe } })
64
+ end
65
+ end
66
+ end
67
+
60
68
  private
61
69
 
70
+ def stage_enabled_modules(stage)
71
+ @stage_enabled_modules ||= {}
72
+ @stage_enabled_modules[stage] ||= enabled_modules.select { |cookbook| stage_entry_exist?(stage, cookbook, stage) }
73
+ end
74
+
75
+ def stage_enabled_recipes(stage)
76
+ @stage_enabled_recipes ||= {}
77
+ @stage_enabled_recipes[stage] ||= enabled_recipes.select { |recipe| stage_entry_exist?(stage, project_name, recipe) }
78
+ end
79
+
62
80
  def enabled_modules
63
81
  dimg.config._chef._dimod
64
82
  end
@@ -440,26 +458,21 @@ module Dapp
440
458
  @stage_cookbooks_runlist[stage] ||= begin
441
459
  res = []
442
460
 
443
- does_entry_exist = proc do |cookbook, entrypoint|
444
- stage_cookbooks_path(stage, cookbook, 'recipes', "#{entrypoint}.rb").exist?
445
- end
446
-
447
461
  format_entry = proc do |cookbook, entrypoint|
448
462
  entrypoint = 'void' if entrypoint.nil?
449
463
  "#{cookbook}::#{entrypoint}"
450
464
  end
451
465
 
452
466
  enabled_modules.map do |cookbook|
453
- if does_entry_exist[cookbook, stage]
467
+ if stage_enabled_modules(stage).include? cookbook
454
468
  [cookbook, stage]
455
469
  else
456
470
  [cookbook, nil]
457
471
  end
458
472
  end.tap { |entries| res.concat entries }
459
473
 
460
- enabled_recipes.map { |recipe| [project_name, recipe] }
461
- .select { |entry| does_entry_exist[*entry] }
462
- .tap do |entries|
474
+ stage_enabled_recipes(stage).map { |recipe| [project_name, recipe] }
475
+ .tap do |entries|
463
476
  if entries.any?
464
477
  res.concat entries
465
478
  else
@@ -480,6 +493,10 @@ module Dapp
480
493
  stage_cookbooks_runlist(stage).empty?
481
494
  end
482
495
 
496
+ def stage_entry_exist?(stage, cookbook, entrypoint)
497
+ stage_cookbooks_path(stage, cookbook, 'recipes', "#{entrypoint}.rb").exist?
498
+ end
499
+
483
500
  def _stage_cookbooks_path(stage)
484
501
  stage_build_path(stage, 'cookbooks')
485
502
  end
@@ -29,6 +29,7 @@ module Dapp
29
29
  project.lock("#{project.name}.images", readonly: true) do
30
30
  last_stage.build_lock! do
31
31
  begin
32
+ builder.before_build_check
32
33
  last_stage.build!
33
34
  ensure
34
35
  last_stage.save_in_cache! if last_stage.image.built? || dev_mode?
@@ -1,5 +1,5 @@
1
1
  # Version
2
2
  module Dapp
3
- VERSION = '0.7.18'.freeze
3
+ VERSION = '0.7.19'.freeze
4
4
  BUILD_CACHE_VERSION = 6
5
5
  end
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.7.18
4
+ version: 0.7.19
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-12-12 00:00:00.000000000 Z
11
+ date: 2016-12-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mixlib-shellout