dapp 0.26.2 → 0.26.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e0c89aa17f75b85d02ff8e2d61509be25b24c255
4
- data.tar.gz: d74d06d30d4373f63ba4c7f72017ba040bcab164
3
+ metadata.gz: 1223a0b22f91c564551e09f54d54c02b253d4a84
4
+ data.tar.gz: cb646a75d24b8f3b045940d9c5dfeea1497e6188
5
5
  SHA512:
6
- metadata.gz: 718e02aeac16f13c76837713b9b6c0c131f6bcfe3d209c38880ca7651f7c136954ea059e3cd33cd694660271460cab1d8e8efdb33c6952acc9b48009ba3672b0
7
- data.tar.gz: 796cf6110efe254a07a73edfd4c662041d91abe11f8fda48f78f5dfcb2ede70cf5f68cbf56d663d96e377a52e1c2b601743fea1bff68082bdce4e18d07492fe0
6
+ metadata.gz: a49317f02f402ad669021275646da2792c8ea7ec3abd3f4eae3487b5a375869812d86186ba2c91af411ca09a682055f167f99c37059a90c4b0a20c94882d59f9
7
+ data.tar.gz: cc1034b50a63384ca0535d16f34dfe591b674864db78201bdb56e3f0efc8a3d8382113e86b4bb8de9f325e8d6051ce61c63156cd3c889e7ddf8c86fc55547fad
@@ -83,6 +83,8 @@ en:
83
83
  stage_artifact_not_supported_associated_stage: "Bad artifact stage `%{stage}`!"
84
84
  git_artifact_remote_branch_with_commit: "Remote git repo: use `commit` or `branch` directive!"
85
85
  artifact_conflict: "Conflict between artifacts!\n\n%{dappfile_context}"
86
+ artifact_not_found: "Invalid Dappfile: artifact `%{name}` should be defined before import directive!"
87
+ artifact_already_exists: "Invalid Dappfile: artifact `%{name}` already exists!"
86
88
  scratch_unsupported_directive: "Scratch dimg has unsupported directive `%{directive}`!"
87
89
  scratch_artifact_required: "Scratch dimg without artifacts!"
88
90
  scratch_artifact_associated: "Scratch artifact can't be associated: not expected `before`/`after` attribute!"
@@ -235,6 +235,7 @@ require 'dapp/dimg/dapp/command/build_context/import'
235
235
  require 'dapp/dimg/dapp/command/build_context/common'
236
236
  require 'dapp/dimg/dapp/dappfile'
237
237
  require 'dapp/dimg/dapp/dimg'
238
+ require 'dapp/dimg/dapp/config_artifact_group'
238
239
  require 'dapp/dimg/dapp/dapp'
239
240
  require 'dapp/dimg/docker_registry'
240
241
  require 'dapp/dimg/docker_registry/base/request'
@@ -48,7 +48,7 @@ module Dapp
48
48
  end
49
49
 
50
50
  def artifacts_dimgs_build!
51
- artifacts.each do |artifact|
51
+ artifacts.uniq { |artifact| artifact[:dimg] }.each do |artifact|
52
52
  process = dimg.dapp.t(code: 'process.artifact_building', data: { name: artifact[:name] })
53
53
  dimg.dapp.log_secondary_process(process) { artifact[:dimg].build! }
54
54
  end
@@ -22,6 +22,14 @@ module Dapp
22
22
  attr_accessor :_config
23
23
  attr_accessor :_before, :_after
24
24
 
25
+ def _cwd
26
+ @_cwd ||= @_to
27
+ end
28
+
29
+ def _to
30
+ @_to ||= @_cwd
31
+ end
32
+
25
33
  def before(stage)
26
34
  sub_directive_eval do
27
35
  stage = stage.to_sym
@@ -55,10 +55,6 @@ module Dapp
55
55
  }
56
56
  end
57
57
 
58
- def _cwd
59
- @_cwd ||= _to
60
- end
61
-
62
58
  def _cwd=(value)
63
59
  return if value.nil?
64
60
  raise ::Dapp::Error::Config, code: :export_cwd_absolute_path_required unless Pathname(value).absolute?
@@ -3,8 +3,23 @@ module Dapp
3
3
  module Config
4
4
  module Directive
5
5
  class ArtifactGroup < DimgGroup
6
+ attr_reader :_name
7
+
8
+ def initialize(name = nil, dapp:)
9
+ super(dapp: dapp)
10
+ @_name = name
11
+ end
12
+
6
13
  def export(*args, &blk)
7
- artifact_config = pass_to(ArtifactDimg.new("artifact-#{SecureRandom.hex(2)}", dapp: dapp))
14
+ _artifact_export(_artifact_config, *args, &blk)
15
+ end
16
+
17
+ def _artifact_config
18
+ artifact_config_name = "artifact-#{[_name, SecureRandom.hex(2)].compact.join('-')}"
19
+ pass_to(ArtifactDimg.new(artifact_config_name, dapp: dapp))
20
+ end
21
+
22
+ def _artifact_export(artifact_config, *args, &blk)
8
23
  artifact = Artifact.new(dapp: dapp, config: artifact_config)
9
24
  artifact.export(*args, &blk).tap do
10
25
  _export.concat artifact._export
@@ -22,9 +22,17 @@ module Dapp
22
22
  directive_eval(_docker, &blk)
23
23
  end
24
24
 
25
- def artifact(&blk)
26
- pass_to(ArtifactGroup.new(dapp: dapp), :clone_to_artifact).tap do |artifact_group|
25
+ def artifact(name = nil, &blk)
26
+ pass_to(ArtifactGroup.new(name, dapp: dapp), :clone_to_artifact).tap do |artifact_group|
27
27
  _context_artifact_groups << directive_eval(artifact_group, &blk)
28
+ dapp.artifact_config(name, artifact_group._artifact_config) unless name.nil?
29
+ end
30
+ end
31
+
32
+ def import(name, from = nil, &blk)
33
+ ArtifactGroup.new(dapp: dapp).tap do |artifact_group|
34
+ artifact_group._artifact_export(dapp.artifact_config_by_name(name), from, &blk)
35
+ _context_artifact_groups << artifact_group
28
36
  end
29
37
  end
30
38
 
@@ -29,6 +29,7 @@ module Dapp
29
29
  elm.validate! if elm.respond_to?(:validate!)
30
30
  end
31
31
  end
32
+ _context_artifact_groups.each(&:validate!)
32
33
  _mount.map(&:_to).tap do |mounts_points|
33
34
  mounts_points.each do |path|
34
35
  raise ::Dapp::Error::Config, code: :mount_duplicate_to, data: { path: path } if mounts_points.count(path) > 1
@@ -21,7 +21,7 @@ module Dapp
21
21
  super
22
22
  end
23
23
 
24
- def artifact(&blk)
24
+ def artifact(name = nil, &blk)
25
25
  check_dimg_group_directive_order(:artifact)
26
26
  super
27
27
  end
@@ -0,0 +1,20 @@
1
+ module Dapp
2
+ module Dimg
3
+ module Dapp
4
+ module ConfigArtifactGroup
5
+ def artifact_config_by_name(name)
6
+ artifacts_configs[name] || raise(::Dapp::Error::Config, code: :artifact_not_found, data: { name: name })
7
+ end
8
+
9
+ def artifact_config(name, artifact_config)
10
+ raise(::Dapp::Error::Config, code: :artifact_already_exists, data: { name: name }) if artifacts_configs.key?(name)
11
+ artifacts_configs[name] = artifact_config
12
+ end
13
+
14
+ def artifacts_configs
15
+ @artifacts_configs ||= {}
16
+ end
17
+ end # Dimg
18
+ end # Dapp
19
+ end # Dimg
20
+ end # Dapp
@@ -4,6 +4,7 @@ module Dapp
4
4
  module Dapp
5
5
  include Dappfile
6
6
  include Dimg
7
+ include ConfigArtifactGroup
7
8
 
8
9
  include Command::Common
9
10
  include Command::Run
@@ -189,6 +189,8 @@ module Dapp
189
189
  end
190
190
 
191
191
  def cleanup_tmp
192
+ return unless tmp_dir_exists?
193
+
192
194
  # В tmp-директории могли остаться файлы, владельцами которых мы не являемся.
193
195
  # Такие файлы могут попасть туда при экспорте файлов артефакта.
194
196
  # Чтобы от них избавиться — запускаем docker-контейнер под root-пользователем
@@ -6,6 +6,10 @@ module Dapp
6
6
  dapp.path(*path).expand_path
7
7
  end
8
8
 
9
+ def tmp_dir_exists?
10
+ @tmp_path != nil
11
+ end
12
+
9
13
  def tmp_path(*path)
10
14
  @tmp_path ||= Dir.mktmpdir('dapp-', dapp.tmp_base_dir)
11
15
  make_path(@tmp_path, *path).expand_path.tap { |p| p.parent.mkpath }
@@ -1,4 +1,4 @@
1
1
  module Dapp
2
- VERSION = "0.26.2"
2
+ VERSION = "0.26.3"
3
3
  BUILD_CACHE_VERSION = 26
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dapp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.26.2
4
+ version: 0.26.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitry Stolyarov
@@ -612,6 +612,7 @@ files:
612
612
  - lib/dapp/dimg/dapp/command/stages/pull.rb
613
613
  - lib/dapp/dimg/dapp/command/stages/push.rb
614
614
  - lib/dapp/dimg/dapp/command/tag.rb
615
+ - lib/dapp/dimg/dapp/config_artifact_group.rb
615
616
  - lib/dapp/dimg/dapp/dapp.rb
616
617
  - lib/dapp/dimg/dapp/dappfile.rb
617
618
  - lib/dapp/dimg/dapp/dimg.rb