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
@@ -48,7 +48,7 @@ module Dapp
48
48
  # rubocop:enable Metrics/ParameterLists
49
49
 
50
50
  def log_secondary_process(message, **kwargs, &blk)
51
- log_process(message, **kwargs.merge(style: { message: :secondary, success: :secondary }, quiet: !log_verbose?), &blk)
51
+ log_process(message, **kwargs.merge(style: { message: :secondary, success: :secondary }), &blk)
52
52
  end
53
53
 
54
54
  protected
@@ -74,8 +74,8 @@ module Dapp
74
74
  # This is stupid container "live check" for now
75
75
  system_shellout! 'true'
76
76
  rescue Error::Shellout
77
- $stderr.puts "\033[1m\033[31mSystem shellout container failure, " +
78
- "try to remove if error persists: " +
77
+ $stderr.puts "\033[1m\033[31mSystem shellout container failure, " \
78
+ 'try to remove if error persists: ' \
79
79
  "docker rm -f #{system_shellout_container_name}\033[0m"
80
80
  raise
81
81
  end
@@ -90,8 +90,6 @@ module Dapp
90
90
  ].join(' && ')}'"
91
91
  end
92
92
 
93
- public
94
-
95
93
  class << self
96
94
  def default_env_keys
97
95
  @default_env_keys ||= []
@@ -1,5 +1,5 @@
1
1
  # Version
2
2
  module Dapp
3
- VERSION = '0.6.17'.freeze
3
+ VERSION = '0.7.1'.freeze
4
4
  BUILD_CACHE_VERSION = 5
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.6.17
4
+ version: 0.7.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-11-15 00:00:00.000000000 Z
11
+ date: 2016-11-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mixlib-shellout
@@ -346,11 +346,6 @@ files:
346
346
  - config/en/common.yml
347
347
  - config/en/net_status.yml
348
348
  - lib/dapp.rb
349
- - lib/dapp/application.rb
350
- - lib/dapp/application/git_artifact.rb
351
- - lib/dapp/application/path.rb
352
- - lib/dapp/application/stages.rb
353
- - lib/dapp/application/tags.rb
354
349
  - lib/dapp/artifact.rb
355
350
  - lib/dapp/build/stage/after_install_artifact.rb
356
351
  - lib/dapp/build/stage/after_setup_artifact.rb
@@ -389,6 +384,7 @@ files:
389
384
  - lib/dapp/builder/chef/berksfile.rb
390
385
  - lib/dapp/builder/chef/cookbook_metadata.rb
391
386
  - lib/dapp/builder/chef/error.rb
387
+ - lib/dapp/builder/none.rb
392
388
  - lib/dapp/builder/shell.rb
393
389
  - lib/dapp/cli.rb
394
390
  - lib/dapp/cli/base.rb
@@ -408,30 +404,43 @@ files:
408
404
  - lib/dapp/cli/stages/flush_repo.rb
409
405
  - lib/dapp/cli/stages/pull.rb
410
406
  - lib/dapp/cli/stages/push.rb
411
- - lib/dapp/cli/tag.rb
412
- - lib/dapp/config/application.rb
413
- - lib/dapp/config/artifact.rb
407
+ - lib/dapp/config/artifact_dimg.rb
408
+ - lib/dapp/config/artifact_group.rb
409
+ - lib/dapp/config/base.rb
410
+ - lib/dapp/config/dimg.rb
411
+ - lib/dapp/config/dimg/instance_methods.rb
412
+ - lib/dapp/config/dimg/validation.rb
413
+ - lib/dapp/config/dimg_group.rb
414
+ - lib/dapp/config/dimg_group_base.rb
415
+ - lib/dapp/config/dimg_group_main.rb
414
416
  - lib/dapp/config/directive/artifact.rb
415
- - lib/dapp/config/directive/build_dir.rb
417
+ - lib/dapp/config/directive/artifact_base.rb
418
+ - lib/dapp/config/directive/base.rb
416
419
  - lib/dapp/config/directive/chef.rb
417
420
  - lib/dapp/config/directive/docker/artifact.rb
418
421
  - lib/dapp/config/directive/docker/base.rb
419
- - lib/dapp/config/directive/git_artifact.rb
422
+ - lib/dapp/config/directive/docker/dimg.rb
423
+ - lib/dapp/config/directive/git_artifact_local.rb
424
+ - lib/dapp/config/directive/git_artifact_remote.rb
425
+ - lib/dapp/config/directive/mount.rb
420
426
  - lib/dapp/config/directive/shell/artifact.rb
421
- - lib/dapp/config/directive/shell/base.rb
422
- - lib/dapp/config/directive/tmp_dir.rb
423
- - lib/dapp/config/main.rb
427
+ - lib/dapp/config/directive/shell/dimg.rb
424
428
  - lib/dapp/core_ext/hash.rb
429
+ - lib/dapp/dimg.rb
430
+ - lib/dapp/dimg/git_artifact.rb
431
+ - lib/dapp/dimg/path.rb
432
+ - lib/dapp/dimg/stages.rb
433
+ - lib/dapp/dimg/tags.rb
425
434
  - lib/dapp/docker_registry.rb
426
435
  - lib/dapp/docker_registry/base.rb
427
436
  - lib/dapp/docker_registry/default.rb
428
437
  - lib/dapp/docker_registry/mod/authorization.rb
429
438
  - lib/dapp/docker_registry/mod/request.rb
430
- - lib/dapp/error/application.rb
431
439
  - lib/dapp/error/base.rb
432
440
  - lib/dapp/error/build.rb
433
441
  - lib/dapp/error/config.rb
434
442
  - lib/dapp/error/dappfile.rb
443
+ - lib/dapp/error/dimg.rb
435
444
  - lib/dapp/error/image.rb
436
445
  - lib/dapp/error/project.rb
437
446
  - lib/dapp/error/registry.rb
@@ -474,7 +483,6 @@ files:
474
483
  - lib/dapp/project/command/stages/flush_repo.rb
475
484
  - lib/dapp/project/command/stages/pull.rb
476
485
  - lib/dapp/project/command/stages/push.rb
477
- - lib/dapp/project/command/tag.rb
478
486
  - lib/dapp/project/dappfile.rb
479
487
  - lib/dapp/project/deps/base.rb
480
488
  - lib/dapp/project/deps/gitartifact.rb
@@ -1,24 +0,0 @@
1
- module Dapp
2
- class CLI
3
- # CLI tag subcommand
4
- class Tag < Base
5
- banner <<BANNER.freeze
6
- Version: #{Dapp::VERSION}
7
-
8
- Usage:
9
- dapp tag [options] [APP PATTERN ...] TAG
10
-
11
- APP PATTERN Application to process [default: *].
12
- REPO Pushed image name.
13
-
14
- Options:
15
- BANNER
16
-
17
- def run(argv = ARGV)
18
- self.class.parse_options(self, argv)
19
- tag = self.class.required_argument(self)
20
- Project.new(cli_options: config, apps_patterns: cli_arguments).public_send(class_to_lowercase, tag)
21
- end
22
- end
23
- end
24
- end
@@ -1,288 +0,0 @@
1
- module Dapp
2
- module Config
3
- # Application
4
- class Application
5
- attr_reader :_home_path
6
- attr_reader :_basename
7
- attr_reader :_parent
8
- attr_reader :_builder, :_chef, :_shell
9
- attr_reader :_install_dependencies, :_setup_dependencies
10
- attr_reader :_docker
11
- attr_reader :_git_artifact
12
- attr_reader :_before_install_artifact, :_before_setup_artifact, :_after_install_artifact, :_after_setup_artifact, :_import_artifact
13
- attr_reader :_tmp_dir, :_build_dir
14
-
15
- def initialize(parent)
16
- @_parent = parent
17
-
18
- @_docker = Directive::Docker::Base.new
19
- @_git_artifact = Directive::GitArtifact.new
20
- @_shell = Directive::Shell::Base.new
21
- @_chef = Directive::Chef.new
22
- @_tmp_dir = Directive::TmpDir.new
23
- @_build_dir = Directive::BuildDir.new
24
-
25
- @_apps = []
26
-
27
- @_before_install_artifact = []
28
- @_before_setup_artifact = []
29
- @_after_install_artifact = []
30
- @_after_setup_artifact = []
31
- @_import_artifact = []
32
-
33
- @_install_dependencies = []
34
- @_setup_dependencies = []
35
-
36
- yield self if block_given?
37
- end
38
-
39
- def install_depends_on(*args)
40
- @_install_dependencies.concat(args)
41
- end
42
-
43
- def setup_depends_on(*args)
44
- @_setup_dependencies.concat(args)
45
- end
46
-
47
- def builder(type)
48
- project.log_warning(desc: { code: 'excess_builder_instruction' }) if @_chef.send(:empty?) && @_shell.send(:empty?)
49
- raise Error::Config, code: :builder_type_unsupported, data: { type: type } unless [:chef, :shell].include?((type = type.to_sym))
50
- another_builder = [:chef, :shell].find { |t| t != type }
51
- instance_variable_set(:"@_#{another_builder}", instance_variable_get(:"@_#{another_builder}").class.new)
52
- @_builder = type
53
- end
54
-
55
- def chef
56
- @_chef.tap { raise Error::Config, code: :builder_type_conflict unless _builder == :chef }
57
- end
58
-
59
- def shell
60
- @_shell.tap { raise Error::Config, code: :builder_type_conflict unless _builder == :shell }
61
- end
62
-
63
- def docker
64
- @_docker
65
- end
66
-
67
- def artifact(where_to_add, before: nil, after: nil, **options, &blk)
68
- raise Error::Config, code: :stage_artifact_double_associate unless before.nil? || after.nil?
69
- artifact_base(instance_variable_get(:"@_#{artifact_variable_name(before, after)}"), where_to_add, **options, &blk)
70
- end
71
-
72
- def git_artifact
73
- @_git_artifact ||= Directive::GitArtifact.new
74
- end
75
-
76
- def tmp_dir
77
- @_tmp_dir
78
- end
79
-
80
- def build_dir
81
- @_build_dir
82
- end
83
-
84
- def dev_mode
85
- @_dev_mode = true
86
- end
87
-
88
- def _name
89
- (@_name || @_basename).tap do |name|
90
- reg = '^[[[:alnum:]]_.-]*$'
91
- raise Error::Config, code: :app_name_incorrect, data: { name: name, reg: reg } unless name =~ /#{reg}/
92
- end
93
- end
94
-
95
- def _dev_mode
96
- !!@_dev_mode
97
- end
98
-
99
- def _apps
100
- @_apps.empty? ? [self] : @_apps.flatten
101
- end
102
-
103
- def _app_chain
104
- @_app_chain ||= (_parent ? _parent._app_chain : []) + [self]
105
- end
106
-
107
- def _app_runlist
108
- _app_chain.map(&:_name).map do |name|
109
- if (subname = name.split("#{_root_app._name}-", 2)[1])
110
- subname_parts = subname.split('-')
111
- subname_parts.join('_') if subname_parts.any?
112
- end
113
- end.compact
114
- end
115
-
116
- def _root_app
117
- _app_chain.first
118
- end
119
-
120
- protected
121
-
122
- attr_accessor :project
123
-
124
- def clone_to_application
125
- clone_to(Application.new(self))
126
- end
127
-
128
- def clone_to_artifact
129
- clone_to(Artifact.new(self))
130
- end
131
-
132
- # rubocop:disable Metrics/AbcSize
133
- def clone_to(app)
134
- app.instance_variable_set(:'@project', project)
135
- app.instance_variable_set(:'@_builder', _builder)
136
- app.instance_variable_set(:'@_home_path', _home_path)
137
- app.instance_variable_set(:'@_basename', _basename)
138
- app.instance_variable_set(:'@_install_dependencies', _install_dependencies)
139
- app.instance_variable_set(:'@_setup_dependencies', _setup_dependencies)
140
- [:_before_install_artifact, :_before_setup_artifact, :_after_install_artifact, :_after_setup_artifact, :_import_artifact].each do |artifact|
141
- app.instance_variable_set(:"@#{artifact}", instance_variable_get(:"@#{artifact}").map { |a| a.send(:clone) })
142
- end
143
- app.instance_variable_set(:'@_docker', _docker.send(:clone))
144
- app.instance_variable_set(:'@_git_artifact', _git_artifact.send(:clone))
145
- app.instance_variable_set(:'@_chef', _chef.send(:clone))
146
- app.instance_variable_set(:'@_shell', _shell.send(:clone))
147
- app.instance_variable_set(:'@_tmp_dir', _tmp_dir.send(:clone))
148
- app.instance_variable_set(:'@_build_dir', _build_dir.send(:clone))
149
- app
150
- end
151
- # rubocop:enable Metrics/AbcSize
152
-
153
- def app(sub_name, &blk)
154
- clone_to_application.tap do |app|
155
- app.instance_variable_set(:'@_name', app_name(sub_name))
156
- app.instance_eval(&blk) if block_given?
157
- @_apps += app._apps
158
- end
159
- end
160
-
161
- def app_name(sub_name)
162
- [_name, sub_name].compact.join('-')
163
- end
164
-
165
- def artifact_variable_name(before, after)
166
- return :import_artifact if before.nil? && after.nil?
167
-
168
- if before.nil?
169
- prefix = :after
170
- stage = after
171
- else
172
- prefix = :before
173
- stage = before
174
- end
175
-
176
- return [prefix, stage, :artifact].join('_') if [:install, :setup].include?(stage.to_sym)
177
- raise Error::Config, code: :stage_artifact_not_supported_associated_stage, data: { stage: stage }
178
- end
179
-
180
- def artifact_base(artifact, where_to_add, **options, &blk)
181
- artifact << begin
182
- config = clone_to_artifact.tap do |app|
183
- app.instance_variable_set(:'@_shell', _shell.send(:clone_to_artifact))
184
- app.instance_variable_set(:'@_docker', _docker.send(:clone_to_artifact))
185
- app.instance_variable_set(:'@_name', app_name("artifact-#{SecureRandom.hex(2)}"))
186
- app.instance_eval(&blk) if block_given?
187
- end
188
- Directive::Artifact::Stage.new(where_to_add, config: config, **options)
189
- end
190
- end
191
-
192
- def validate!
193
- if _docker._from.nil?
194
- validate_scratch_directives!
195
- validate_scratch_artifacts!
196
- else
197
- raise Error::Config, code: :stage_artifact_not_associated unless _import_artifact.empty?
198
- end
199
- validate_artifacts!
200
- validate_artifacts_artifacts!
201
- end
202
-
203
- def validate_scratch_directives!
204
- raise Error::Config, code: :scratch_unsupported_directive, data: { directive: :app } unless _apps.length == 1
205
-
206
- directives = [:_shell, :_chef, :_git_artifact, :_install_dependencies, :_setup_dependencies, :_tmp_dir, :_build_dir]
207
- directives.each do |directive|
208
- raise Error::Config,
209
- code: :scratch_unsupported_directive,
210
- data: { directive: directive[1..-1] } unless public_send(directive).send(:empty?)
211
- end
212
-
213
- docker_directives = [:_expose, :_env, :_cmd, :_onbuild, :_workdir, :_user, :_entrypoint]
214
- docker_directives.each do |directive|
215
- value = _docker.public_send(directive)
216
- raise Error::Config,
217
- code: :scratch_unsupported_directive,
218
- data: { directive: "docker.#{directive[1..-1]}" } unless value.nil? || value.send(:empty?)
219
- end
220
- end
221
-
222
- def validate_scratch_artifacts!
223
- raise Error::Config, code: :scratch_artifact_associated unless associated_artifacts.empty?
224
- raise Error::Config, code: :scratch_artifact_required if _import_artifact.empty?
225
- _import_artifact.each do |artifact|
226
- raise Error::Config, code: :scratch_artifact_docker_from if artifact._config._docker._from.nil?
227
- end
228
- end
229
-
230
- def validate_artifacts_artifacts!
231
- associated_artifacts.each { |artifact| artifact._config.validate! }
232
- end
233
-
234
- def associated_artifacts
235
- _before_install_artifact + _before_setup_artifact + _after_install_artifact + _after_setup_artifact
236
- end
237
-
238
- def validate_artifacts!
239
- artifacts = validate_artifact_format(associated_artifacts + _import_artifact + _git_artifact._remote + _git_artifact._local)
240
- loop do
241
- break if artifacts.empty?
242
- verifiable_artifact = artifacts.shift
243
- artifacts.select { |artifact| artifact[:where_to_add] == verifiable_artifact[:where_to_add] }.each do |artifact|
244
- next if verifiable_artifact[:index] == artifact[:index]
245
- validate_artifact!(verifiable_artifact, artifact)
246
- validate_artifact!(artifact, verifiable_artifact)
247
- end
248
- end
249
- end
250
-
251
- def validate_artifact_format(artifacts)
252
- artifacts.map do |a|
253
- path_format = proc { |path| File.expand_path(File.join('/', path, '/'))[1..-1] }
254
-
255
- path_format.call(a._where_to_add) =~ %r{^([^\/]*)\/?(.*)$}
256
- where_to_add = Regexp.last_match(1)
257
- includes = a._paths.dup
258
- includes << Regexp.last_match(2) unless Regexp.last_match(2).empty?
259
- excludes = a._exclude_paths.dup
260
-
261
- {
262
- index: artifacts.index(a),
263
- where_to_add: where_to_add,
264
- includes: includes.map(&path_format),
265
- excludes: excludes.map(&path_format)
266
- }
267
- end
268
- end
269
-
270
- def validate_artifact!(verifiable_artifact, artifact)
271
- verifiable_artifact[:includes].each do |verifiable_path|
272
- potential_conflicts = artifact[:includes].select { |path| path.start_with?(verifiable_path) }
273
- validate_artifact_path!(verifiable_artifact, potential_conflicts)
274
- end.empty? && verifiable_artifact[:excludes].empty? && raise(Error::Config, code: :artifact_conflict)
275
- validate_artifact_path!(verifiable_artifact, artifact[:includes]) if verifiable_artifact[:includes].empty?
276
- end
277
-
278
- def validate_artifact_path!(verifiable_artifact, potential_conflicts)
279
- potential_conflicts.all? do |path|
280
- loop do
281
- break if verifiable_artifact[:excludes].include?(path) || ((path = File.dirname(path)) == '.')
282
- end
283
- verifiable_artifact[:excludes].include?(path)
284
- end.tap { |res| res || raise(Error::Config, code: :artifact_conflict) }
285
- end
286
- end
287
- end
288
- end
@@ -1,20 +0,0 @@
1
- module Dapp
2
- module Config
3
- # Artifact
4
- class Artifact < Application
5
- attr_reader :_artifact_dependencies
6
-
7
- def initialize(parent)
8
- @_artifact_dependencies = []
9
- super
10
- end
11
-
12
- def artifact_depends_on(*args)
13
- @_artifact_dependencies.concat(args)
14
- end
15
-
16
- undef_method :app
17
- undef_method :artifact
18
- end
19
- end
20
- end