dapp 0.6.17 → 0.7.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.
Files changed (125) hide show
  1. checksums.yaml +4 -4
  2. data/config/en/common.yml +2 -2
  3. data/config/en/net_status.yml +25 -23
  4. data/lib/dapp.rb +24 -16
  5. data/lib/dapp/artifact.rb +1 -1
  6. data/lib/dapp/build/stage/after_install_artifact.rb +2 -2
  7. data/lib/dapp/build/stage/after_setup_artifact.rb +4 -4
  8. data/lib/dapp/build/stage/artifact_base.rb +25 -25
  9. data/lib/dapp/build/stage/artifact_default.rb +16 -16
  10. data/lib/dapp/build/stage/base.rb +36 -31
  11. data/lib/dapp/build/stage/before_install.rb +8 -8
  12. data/lib/dapp/build/stage/before_install_artifact.rb +2 -2
  13. data/lib/dapp/build/stage/before_setup.rb +8 -8
  14. data/lib/dapp/build/stage/before_setup_artifact.rb +2 -2
  15. data/lib/dapp/build/stage/build_artifact.rb +10 -10
  16. data/lib/dapp/build/stage/docker_instructions.rb +3 -3
  17. data/lib/dapp/build/stage/from.rb +7 -3
  18. data/lib/dapp/build/stage/ga_archive.rb +2 -2
  19. data/lib/dapp/build/stage/ga_archive_dependencies.rb +3 -3
  20. data/lib/dapp/build/stage/ga_artifact_patch.rb +2 -2
  21. data/lib/dapp/build/stage/ga_base.rb +2 -2
  22. data/lib/dapp/build/stage/ga_dependencies_base.rb +2 -2
  23. data/lib/dapp/build/stage/ga_latest_patch.rb +3 -3
  24. data/lib/dapp/build/stage/import_artifact.rb +19 -19
  25. data/lib/dapp/build/stage/install/ga_post_install_patch.rb +2 -2
  26. data/lib/dapp/build/stage/install/ga_post_install_patch_dependencies.rb +2 -2
  27. data/lib/dapp/build/stage/install/ga_pre_install_patch.rb +2 -2
  28. data/lib/dapp/build/stage/install/ga_pre_install_patch_dependencies.rb +2 -2
  29. data/lib/dapp/build/stage/install/install.rb +9 -9
  30. data/lib/dapp/build/stage/mod/group.rb +2 -2
  31. data/lib/dapp/build/stage/mod/logging.rb +19 -19
  32. data/lib/dapp/build/stage/setup/chef_cookbooks.rb +4 -4
  33. data/lib/dapp/build/stage/setup/ga_post_setup_patch.rb +2 -2
  34. data/lib/dapp/build/stage/setup/ga_post_setup_patch_dependencies.rb +3 -3
  35. data/lib/dapp/build/stage/setup/ga_pre_setup_patch.rb +2 -2
  36. data/lib/dapp/build/stage/setup/ga_pre_setup_patch_dependencies.rb +2 -2
  37. data/lib/dapp/build/stage/setup/setup.rb +9 -9
  38. data/lib/dapp/builder/base.rb +4 -4
  39. data/lib/dapp/builder/chef.rb +65 -64
  40. data/lib/dapp/builder/none.rb +45 -0
  41. data/lib/dapp/builder/shell.rb +3 -3
  42. data/lib/dapp/cli.rb +9 -10
  43. data/lib/dapp/cli/base.rb +6 -1
  44. data/lib/dapp/cli/bp.rb +2 -2
  45. data/lib/dapp/cli/build.rb +2 -2
  46. data/lib/dapp/cli/cleanup.rb +2 -2
  47. data/lib/dapp/cli/list.rb +2 -2
  48. data/lib/dapp/cli/mrproper.rb +0 -4
  49. data/lib/dapp/cli/push.rb +3 -3
  50. data/lib/dapp/cli/run.rb +3 -3
  51. data/lib/dapp/cli/spush.rb +2 -2
  52. data/lib/dapp/cli/stage_image.rb +2 -2
  53. data/lib/dapp/cli/stages/cleanup_local.rb +3 -3
  54. data/lib/dapp/cli/stages/cleanup_repo.rb +3 -3
  55. data/lib/dapp/cli/stages/flush_local.rb +3 -3
  56. data/lib/dapp/cli/stages/flush_repo.rb +3 -3
  57. data/lib/dapp/cli/stages/pull.rb +3 -3
  58. data/lib/dapp/cli/stages/push.rb +3 -3
  59. data/lib/dapp/config/artifact_dimg.rb +18 -0
  60. data/lib/dapp/config/artifact_group.rb +54 -0
  61. data/lib/dapp/config/base.rb +19 -0
  62. data/lib/dapp/config/dimg.rb +23 -0
  63. data/lib/dapp/config/dimg/instance_methods.rb +179 -0
  64. data/lib/dapp/config/dimg/validation.rb +124 -0
  65. data/lib/dapp/config/dimg_group.rb +56 -0
  66. data/lib/dapp/config/dimg_group_base.rb +36 -0
  67. data/lib/dapp/config/dimg_group_main.rb +21 -0
  68. data/lib/dapp/config/directive/artifact.rb +29 -54
  69. data/lib/dapp/config/directive/artifact_base.rb +92 -0
  70. data/lib/dapp/config/directive/base.rb +22 -0
  71. data/lib/dapp/config/directive/chef.rb +23 -61
  72. data/lib/dapp/config/directive/docker/artifact.rb +3 -14
  73. data/lib/dapp/config/directive/docker/base.rb +3 -78
  74. data/lib/dapp/config/directive/docker/dimg.rb +81 -0
  75. data/lib/dapp/config/directive/git_artifact_local.rb +13 -0
  76. data/lib/dapp/config/directive/git_artifact_remote.rb +55 -0
  77. data/lib/dapp/config/directive/mount.rb +25 -0
  78. data/lib/dapp/config/directive/shell/artifact.rb +3 -24
  79. data/lib/dapp/config/directive/shell/dimg.rb +68 -0
  80. data/lib/dapp/{application.rb → dimg.rb} +12 -33
  81. data/lib/dapp/{application → dimg}/git_artifact.rb +3 -3
  82. data/lib/dapp/{application → dimg}/path.rb +9 -5
  83. data/lib/dapp/{application → dimg}/stages.rb +8 -8
  84. data/lib/dapp/{application → dimg}/tags.rb +6 -6
  85. data/lib/dapp/docker_registry.rb +11 -15
  86. data/lib/dapp/error/dimg.rb +6 -0
  87. data/lib/dapp/git_artifact.rb +19 -20
  88. data/lib/dapp/git_repo/base.rb +6 -6
  89. data/lib/dapp/git_repo/own.rb +4 -4
  90. data/lib/dapp/git_repo/remote.rb +5 -5
  91. data/lib/dapp/image/docker.rb +0 -15
  92. data/lib/dapp/image/stage.rb +12 -22
  93. data/lib/dapp/project.rb +14 -18
  94. data/lib/dapp/project/command/build.rb +2 -2
  95. data/lib/dapp/project/command/cleanup.rb +9 -11
  96. data/lib/dapp/project/command/common.rb +8 -20
  97. data/lib/dapp/project/command/list.rb +7 -1
  98. data/lib/dapp/project/command/mrproper.rb +12 -22
  99. data/lib/dapp/project/command/push.rb +3 -4
  100. data/lib/dapp/project/command/run.rb +2 -2
  101. data/lib/dapp/project/command/spush.rb +3 -4
  102. data/lib/dapp/project/command/stage_image.rb +2 -2
  103. data/lib/dapp/project/command/stages/cleanup_local.rb +20 -24
  104. data/lib/dapp/project/command/stages/cleanup_repo.rb +3 -3
  105. data/lib/dapp/project/command/stages/common.rb +2 -3
  106. data/lib/dapp/project/command/stages/flush_local.rb +5 -7
  107. data/lib/dapp/project/command/stages/flush_repo.rb +2 -2
  108. data/lib/dapp/project/command/stages/pull.rb +3 -4
  109. data/lib/dapp/project/command/stages/push.rb +3 -4
  110. data/lib/dapp/project/dappfile.rb +9 -26
  111. data/lib/dapp/project/logging/base.rb +14 -0
  112. data/lib/dapp/project/logging/process.rb +1 -1
  113. data/lib/dapp/project/shellout/system.rb +2 -4
  114. data/lib/dapp/version.rb +1 -1
  115. metadata +25 -17
  116. data/lib/dapp/cli/tag.rb +0 -24
  117. data/lib/dapp/config/application.rb +0 -288
  118. data/lib/dapp/config/artifact.rb +0 -20
  119. data/lib/dapp/config/directive/build_dir.rb +0 -9
  120. data/lib/dapp/config/directive/git_artifact.rb +0 -59
  121. data/lib/dapp/config/directive/shell/base.rb +0 -85
  122. data/lib/dapp/config/directive/tmp_dir.rb +0 -36
  123. data/lib/dapp/config/main.rb +0 -20
  124. data/lib/dapp/error/application.rb +0 -6
  125. data/lib/dapp/project/command/tag.rb +0 -18
@@ -1,6 +1,6 @@
1
1
  module Dapp
2
- # Application
3
- class Application
2
+ # Dimg
3
+ class Dimg
4
4
  # Tags
5
5
  module Tags
6
6
  protected
@@ -21,7 +21,7 @@ module Dapp
21
21
 
22
22
  def branch_tags
23
23
  return [] unless project.cli_options[:tag_branch]
24
- raise Error::Application, code: :git_branch_without_name if (branch = git_repo.branch) == 'HEAD'
24
+ raise Error::Dimg, code: :git_branch_without_name if (branch = git_repo.branch) == 'HEAD'
25
25
  [branch]
26
26
  end
27
27
 
@@ -39,7 +39,7 @@ module Dapp
39
39
  elsif ENV['TRAVIS']
40
40
  build_id = ENV['TRAVIS_BUILD_NUMBER']
41
41
  else
42
- raise Error::Application, code: :ci_environment_required
42
+ raise Error::Dimg, code: :ci_environment_required
43
43
  end
44
44
 
45
45
  [build_id]
@@ -55,11 +55,11 @@ module Dapp
55
55
  branch = ENV['TRAVIS_BRANCH']
56
56
  tag = ENV['TRAVIS_TAG']
57
57
  else
58
- raise Error::Application, code: :ci_environment_required
58
+ raise Error::Dimg, code: :ci_environment_required
59
59
  end
60
60
 
61
61
  [branch, tag].compact
62
62
  end
63
63
  end # Tags
64
- end # Application
64
+ end # Dimg
65
65
  end # Dapp
@@ -2,9 +2,9 @@ module Dapp
2
2
  # DockerRegistry
3
3
  module DockerRegistry
4
4
  def self.new(repo)
5
- /^#{repo_name_format}$/ =~ repo
6
- expected_hostname = Regexp.last_match(:hostname)
7
- expected_repo_suffix = Regexp.last_match(:repo_suffix)
5
+ repo_regex =~ repo
6
+ expected_hostname = Regexp.last_match(1)
7
+ expected_repo_suffix = Regexp.last_match(2)
8
8
  expected_hostname_url = expected_hostname ? "http://#{expected_hostname}" : nil
9
9
 
10
10
  if hostname_exist?(expected_hostname_url)
@@ -14,18 +14,14 @@ module Dapp
14
14
  end
15
15
  end
16
16
 
17
- def self.repo_name_format
18
- separator = '[_.]|__|[-]*'
19
- alpha_numeric = '[[:alnum:]]*'
20
- component = "#{alpha_numeric}[#{separator}#{alpha_numeric}]*"
21
- port_number = '[[:digit:]]+'
22
- hostcomponent = '[[:alnum:]_-]*[[:alnum:]]'
23
- hostname = "#{hostcomponent}[\\.#{hostcomponent}]*(?<port>:#{port_number})?"
24
- "(?<hostname>#{hostname}/)?(?<repo_suffix>#{component}[/#{component}]*)"
25
- end
26
-
27
- def self.repo_name?(name)
28
- !(/^#{repo_name_format}$/ =~ name).nil?
17
+ def self.repo_regex
18
+ separator = /[_.]|__|[-]*/
19
+ alpha_numeric = /[[:alnum:]]*/
20
+ component = /#{alpha_numeric}[#{separator}#{alpha_numeric}]*/
21
+ port_number = /[0-9]+/
22
+ hostcomponent = /[[:alnum:]-]*[[:alnum:]]/
23
+ hostname = /#{hostcomponent}[\.#{hostcomponent}]*[:#{port_number}]?/
24
+ %r{^(#{hostname}/)?(#{component}[/#{component}]*)$}
29
25
  end
30
26
 
31
27
  def self.hostname_exist?(url)
@@ -0,0 +1,6 @@
1
+ module Dapp
2
+ module Error
3
+ # Dimg
4
+ class Dimg < Base; end
5
+ end
6
+ end
@@ -5,19 +5,18 @@ module Dapp
5
5
  attr_reader :name
6
6
 
7
7
  # rubocop:disable Metrics/ParameterLists
8
- def initialize(repo, where_to_add:, name: nil, branch: nil, commit: nil,
9
- cwd: nil, paths: nil, exclude_paths: nil, owner: nil, group: nil)
8
+ def initialize(repo, to:, name: nil, branch: nil, commit: nil,
9
+ cwd: nil, include_paths: nil, exclude_paths: nil, owner: nil, group: nil)
10
10
  @repo = repo
11
11
  @name = name
12
12
 
13
- @where_to_add = where_to_add
14
-
15
- @branch = branch || repo.application.project.cli_options[:git_artifact_branch] || repo.branch
13
+ @branch = branch || repo.dimg.project.cli_options[:git_artifact_branch] || repo.branch
16
14
  @commit = commit
17
15
 
18
- cwd = File.expand_path(File.join('/', cwd))[1..-1] unless cwd.nil? || cwd.empty?
16
+ @to = to
17
+ cwd = File.expand_path(File.join('/', cwd))[1..-1] unless cwd.nil? || cwd.empty? # must be relative!!!
19
18
  @cwd = cwd
20
- @paths = paths
19
+ @include_paths = include_paths
21
20
  @exclude_paths = exclude_paths
22
21
  @owner = owner
23
22
  @group = group
@@ -27,18 +26,18 @@ module Dapp
27
26
  def apply_archive_command(stage)
28
27
  credentials = [:owner, :group].map { |attr| "--#{attr}=#{send(attr)}" unless send(attr).nil? }.compact
29
28
 
30
- ["#{repo.application.project.install_path} #{credentials.join(' ')} -d #{where_to_add}",
31
- ["#{repo.application.project.git_path} --git-dir=#{repo.container_path} archive #{stage.layer_commit(self)}:#{cwd} #{paths.join(' ')}",
32
- "#{sudo}#{repo.application.project.tar_path} -x -C #{where_to_add} #{archive_command_excludes.join(' ')}"].join(' | ')]
29
+ ["#{repo.dimg.project.install_path} #{credentials.join(' ')} -d #{to}",
30
+ ["#{repo.dimg.project.git_path} --git-dir=#{repo.container_path} archive #{stage.layer_commit(self)}:#{cwd} #{include_paths.join(' ')}",
31
+ "#{sudo}#{repo.dimg.project.tar_path} -x -C #{to} #{archive_command_excludes.join(' ')}"].join(' | ')]
33
32
  end
34
33
 
35
34
  def apply_patch_command(stage)
36
35
  current_commit = stage.layer_commit(self)
37
36
  prev_commit = stage.prev_g_a_stage.layer_commit(self)
38
37
 
39
- if prev_commit != current_commit && any_changes?(prev_commit, current_commit)
40
- [["#{repo.application.project.git_path} --git-dir=#{repo.container_path} #{diff_command(prev_commit, current_commit)}",
41
- "#{sudo}#{repo.application.project.git_path} apply --whitespace=nowarn --directory=#{where_to_add} #{patch_command_excludes.join(' ')} --unsafe-paths"].join(' | ')]
38
+ if prev_commit != current_commit || any_changes?(prev_commit, current_commit)
39
+ [["#{repo.dimg.project.git_path} --git-dir=#{repo.container_path} #{diff_command(prev_commit, current_commit)}",
40
+ "#{sudo}#{repo.dimg.project.git_path} apply --whitespace=nowarn --directory=#{to} #{patch_command_excludes.join(' ')} --unsafe-paths"].join(' | ')]
42
41
  else
43
42
  []
44
43
  end
@@ -50,7 +49,7 @@ module Dapp
50
49
 
51
50
  def patch_command_excludes
52
51
  exclude_paths.map do |path|
53
- base = File.join(where_to_add, path)
52
+ base = File.join(to, path)
54
53
  path =~ /[\*\?\[\]\{\}]/ ? %(--exclude=#{base} ) : %(--exclude=#{base} --exclude=#{File.join(base, '*')})
55
54
  end
56
55
  end
@@ -68,15 +67,15 @@ module Dapp
68
67
  end
69
68
 
70
69
  def paramshash
71
- Digest::SHA256.hexdigest [where_to_add, cwd, *paths, *exclude_paths, owner, group].map(&:to_s).join(':::')
70
+ Digest::SHA256.hexdigest [to, cwd, *include_paths, *exclude_paths, owner, group].map(&:to_s).join(':::')
72
71
  end
73
72
 
74
73
  def exclude_paths(with_cwd = false)
75
74
  base_paths(@exclude_paths, with_cwd)
76
75
  end
77
76
 
78
- def paths(with_cwd = false)
79
- base_paths(@paths, with_cwd)
77
+ def include_paths(with_cwd = false)
78
+ base_paths(@include_paths, with_cwd)
80
79
  end
81
80
 
82
81
  def base_paths(paths, with_cwd = false)
@@ -89,7 +88,7 @@ module Dapp
89
88
 
90
89
  protected
91
90
 
92
- attr_reader :where_to_add
91
+ attr_reader :to
93
92
  attr_reader :commit
94
93
  attr_reader :branch
95
94
  attr_reader :cwd
@@ -97,11 +96,11 @@ module Dapp
97
96
  attr_reader :group
98
97
 
99
98
  def sudo
100
- repo.application.project.sudo_command(owner: owner, group: group)
99
+ repo.dimg.project.sudo_command(owner: owner, group: group)
101
100
  end
102
101
 
103
102
  def diff_command(from, to, quiet: false)
104
- "diff --binary #{'--quiet' if quiet} #{from}..#{to} #{"--relative=#{cwd}" if cwd} -- #{paths(true).join(' ')}"
103
+ "diff --binary #{'--quiet' if quiet} #{from}..#{to} #{"--relative=#{cwd}" if cwd} -- #{include_paths(true).join(' ')}"
105
104
  end
106
105
  end
107
106
  end
@@ -2,20 +2,20 @@ module Dapp
2
2
  module GitRepo
3
3
  # Base class for any Git repo (remote, gitkeeper, etc)
4
4
  class Base
5
- attr_reader :application
5
+ attr_reader :dimg
6
6
  attr_reader :name
7
7
 
8
- def initialize(application, name)
9
- @application = application
8
+ def initialize(dimg, name)
9
+ @dimg = dimg
10
10
  @name = name
11
11
  end
12
12
 
13
13
  def container_path
14
- application.container_tmp_path "#{name}.git"
14
+ dimg.container_tmp_path "#{name}.git"
15
15
  end
16
16
 
17
17
  def path
18
- application.tmp_path "#{name}.git"
18
+ dimg.tmp_path "#{name}.git"
19
19
  end
20
20
 
21
21
  def git_bare(command, **kwargs)
@@ -44,7 +44,7 @@ module Dapp
44
44
  protected
45
45
 
46
46
  def git(command, **kwargs)
47
- application.project.system_shellout! "#{application.project.git_path} #{command}", **kwargs
47
+ dimg.project.system_shellout! "#{dimg.project.git_path} #{command}", **kwargs
48
48
  end
49
49
  end
50
50
  end
@@ -2,16 +2,16 @@ module Dapp
2
2
  module GitRepo
3
3
  # Own Git repo
4
4
  class Own < Base
5
- def initialize(application)
6
- super(application, 'own')
5
+ def initialize(dimg)
6
+ super(dimg, 'own')
7
7
  end
8
8
 
9
9
  def container_path
10
- application.container_dapp_path('own', "#{name}.git")
10
+ dimg.container_dapp_path('own', "#{name}.git")
11
11
  end
12
12
 
13
13
  def path
14
- @path ||= Pathname(git("-C #{application.home_path} rev-parse --git-dir").stdout.strip).expand_path
14
+ @path ||= Pathname(git("-C #{dimg.home_path} rev-parse --git-dir").stdout.strip).expand_path
15
15
  end
16
16
 
17
17
  def latest_commit(branch = nil)
@@ -2,20 +2,20 @@ module Dapp
2
2
  module GitRepo
3
3
  # Normal Git repo
4
4
  class Remote < Base
5
- def initialize(application, name, url:)
6
- super(application, name)
5
+ def initialize(dimg, name, url:)
6
+ super(dimg, name)
7
7
 
8
8
  @url = url
9
9
 
10
- application.project.log_secondary_process(application.project.t(code: 'process.git_artifact_clone', data: { name: name }), short: true) do
10
+ dimg.project.log_secondary_process(dimg.project.t(code: 'process.git_artifact_clone', data: { name: name }), short: true) do
11
11
  git "clone --bare --depth 1 #{url} #{path}"
12
12
  end unless File.directory?(path)
13
13
  end
14
14
 
15
15
  def fetch!(branch = 'master')
16
- application.project.log_secondary_process(application.project.t(code: 'process.git_artifact_fetch', data: { name: name }), short: true) do
16
+ dimg.project.log_secondary_process(dimg.project.t(code: 'process.git_artifact_fetch', data: { name: name }), short: true) do
17
17
  git_bare "fetch origin #{branch}:#{branch}"
18
- end unless application.ignore_git_fetch || application.project.dry_run?
18
+ end unless dimg.ignore_git_fetch || dimg.project.dry_run?
19
19
  end
20
20
 
21
21
  def cleanup!
@@ -68,21 +68,6 @@ module Dapp
68
68
  end
69
69
 
70
70
  class << self
71
- def image_name_format
72
- separator = '[_.]|__|[-]*'
73
- tag = "[[:alnum:]][[[:alnum:]]#{separator}]{0,127}"
74
- "#{DockerRegistry.repo_name_format}(:(?<tag>#{tag}))?"
75
- end
76
-
77
- def image_name?(name)
78
- !(/^#{image_name_format}$/ =~ name).nil?
79
- end
80
-
81
- def tag!(id:, tag:)
82
- Project.shellout!("docker tag #{id} #{tag}")
83
- cache_reset
84
- end
85
-
86
71
  def cache
87
72
  @cache ||= (@cache = {}).tap { cache_reset }
88
73
  end
@@ -33,30 +33,24 @@ module Dapp
33
33
  end
34
34
 
35
35
  def export!(name)
36
- tag!(name).tap do |image|
37
- image.push!
38
- image.untag!
39
- end
40
- end
41
-
42
- def tag!(name)
43
- clone!(name).tap do |image|
44
- self.class.tag!(id: image.built_id, tag: image.name)
45
- end
36
+ image = self.class.new(name: name, project: project, built_id: built_id)
37
+ image.tag!
38
+ image.push!
39
+ image.untag!
46
40
  end
47
41
 
48
42
  def import!(name)
49
- clone!(name).tap do |image|
50
- image.pull!
51
- @built_id = image.built_id
52
- save_in_cache!
53
- image.untag!
54
- end
43
+ image = self.class.new(name: name, project: project)
44
+ image.pull!
45
+ @built_id = image.built_id
46
+ tag!
47
+ image.untag!
55
48
  end
56
49
 
57
- def save_in_cache!
50
+ def tag!
58
51
  project.log_warning(desc: { code: :another_image_already_tagged }) if !(existed_id = id).nil? && built_id != existed_id
59
- self.class.tag!(id: built_id, tag: name)
52
+ project.shellout!("docker tag #{built_id} #{name}")
53
+ cache_reset
60
54
  end
61
55
 
62
56
  def labels
@@ -83,10 +77,6 @@ module Dapp
83
77
  def commit!
84
78
  project.shellout!("docker commit #{prepared_change} #{container_name}").stdout.strip
85
79
  end
86
-
87
- def clone!(name)
88
- self.class.new(name: name, project: project, built_id: built_id)
89
- end
90
80
  end # Stage
91
81
  end # Image
92
82
  end # Dapp
@@ -10,7 +10,6 @@ module Dapp
10
10
  include Command::Bp
11
11
  include Command::Push
12
12
  include Command::Spush
13
- include Command::Tag
14
13
  include Command::List
15
14
  include Command::Stages::CleanupLocal
16
15
  include Command::Stages::CleanupRepo
@@ -38,12 +37,12 @@ module Dapp
38
37
  include Shellout::System
39
38
 
40
39
  attr_reader :cli_options
41
- attr_reader :apps_patterns
40
+ attr_reader :dimgs_patterns
42
41
 
43
- def initialize(cli_options: {}, apps_patterns: nil)
42
+ def initialize(cli_options: {}, dimgs_patterns: nil)
44
43
  @cli_options = cli_options
45
- @apps_patterns = apps_patterns || []
46
- @apps_patterns << '*' unless @apps_patterns.any?
44
+ @dimgs_patterns = dimgs_patterns || []
45
+ @dimgs_patterns << '*' unless @dimgs_patterns.any?
47
46
 
48
47
  Logging::Paint.initialize(cli_options[:log_color])
49
48
  Logging::I18n.initialize
@@ -52,7 +51,11 @@ module Dapp
52
51
  def name
53
52
  @name ||= begin
54
53
  if File.exist? File.join(path, '.git')
55
- system_shellout("#{git_path} -C #{path} config --get remote.origin.url").stdout.strip.split('/').last[/.*(?=.git)/] rescue File.basename(path)
54
+ begin
55
+ system_shellout("#{git_path} -C #{path} config --get remote.origin.url").stdout.strip.split('/').last[/.*(?=.git)/]
56
+ rescue
57
+ File.basename(path)
58
+ end
56
59
  else
57
60
  File.basename(path)
58
61
  end
@@ -60,14 +63,7 @@ module Dapp
60
63
  end
61
64
 
62
65
  def path
63
- @path ||= begin
64
- dappfile_path = dappfiles.first
65
- if File.basename(expand_path(dappfile_path, 2)) == '.dapps'
66
- expand_path(dappfile_path, 3)
67
- else
68
- expand_path(dappfile_path)
69
- end
70
- end
66
+ @path ||= expand_path(dappfile_path)
71
67
  end
72
68
 
73
69
  def build_path
@@ -80,12 +76,12 @@ module Dapp
80
76
  end
81
77
  end
82
78
 
83
- def cache_format
84
- "dappstage-#{name}-%{application_name}"
79
+ def stage_cache
80
+ "dimgstage-#{name}"
85
81
  end
86
82
 
87
- def stage_dapp_label_format
88
- '%{application_name}'
83
+ def stage_dapp_label
84
+ name
89
85
  end
90
86
 
91
87
  def dev_mode?
@@ -9,8 +9,8 @@ module Dapp
9
9
  setup_ssh_agent
10
10
 
11
11
  build_configs.each do |config|
12
- log_step_with_indent(config._name) do
13
- Application.new(config: config, project: self).build!
12
+ log_dimg_name_with_indent(config) do
13
+ Dimg.new(config: config, project: self).build!
14
14
  end
15
15
  end
16
16
  end
@@ -6,17 +6,15 @@ module Dapp
6
6
  # Cleanup
7
7
  module Cleanup
8
8
  def cleanup
9
- build_configs.map(&:_basename).uniq.each do |basename|
10
- lock("#{basename}.images") do
11
- log_step_with_indent(basename) do
12
- project_containers_flush(basename)
13
- project_dangling_images_flush(basename)
14
- remove_images_by_query([
15
- 'docker images',
16
- %(--format '{{if ne "#{stage_cache(basename)}" .Repository }}{{.ID}}{{ end }}'),
17
- %(-f "label=dapp=#{stage_dapp_label(basename)}")
18
- ].join(' ')) # FIXME: negative filter is not currently supported by the Docker CLI
19
- end
9
+ lock("#{name}.images") do
10
+ log_step_with_indent(name) do
11
+ project_containers_flush
12
+ project_dangling_images_flush
13
+ remove_images_by_query([
14
+ 'docker images',
15
+ %(--format '{{if ne "#{stage_cache}" .Repository }}{{.ID}}{{ end }}'),
16
+ %(-f "label=dapp=#{stage_dapp_label}")
17
+ ].join(' ')) # FIXME: negative filter is not currently supported by the Docker CLI
20
18
  end
21
19
  end
22
20
  end