dapp 0.14.11 → 0.14.12

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: 9ad114008afe7eb82b0d3ad627dabaccd88bcfcf
4
- data.tar.gz: fc5442598b8110af32df65852993e4b194691f4c
3
+ metadata.gz: 13bccb197061f7d78e8f74f498248f6aa2c19833
4
+ data.tar.gz: d5a9c8d733f8d3f9562d3af9219930220aa78c90
5
5
  SHA512:
6
- metadata.gz: 98fa765aa71da71698636960cb085f29e2bf4e08fc28c16d4f39339e000304904719c63a8658736217a99a5aa988d9a8ad3210ca8884af8ce9261f78bfe6945c
7
- data.tar.gz: e6a9b8fb77875c16d69be688d60cc82488db0d316717edcb13dd9636e87992374659810499f6b55a256da3f906f20749d1f04768636adc096fad2898ee2753fd
6
+ metadata.gz: ca8cf1edb04f43bfac8303ff27696214ce848a013d04c2c19c3e1ffa8f81274032f1e1a533459d1dce5b31a634a191e632b99d96880b9cc9030bef27e27320f9
7
+ data.tar.gz: b7a031ef19524e04b38cb274d5ddd5261275ffe94591401001eee285a9eff17ac78264ff39de5dc6cef1d1ad658ae95906ba54e265d83c8db7a44c8b7e2fdfbf
@@ -98,21 +98,26 @@ module Dapp
98
98
  name
99
99
  end
100
100
 
101
- def host_docker_bin
102
- self.class.host_docker_bin
101
+ def host_docker
102
+ self.class.host_docker
103
103
  end
104
104
 
105
- def self.host_docker_bin
106
- @host_docker_bin ||= begin
105
+ def self.host_docker
106
+ @host_docker ||= begin
107
107
  raise Error::Dapp, code: :docker_not_found if (res = shellout('which docker')).exitstatus.nonzero?
108
- res.stdout.strip.tap do |docker_bin|
109
- current_docker_version = shellout!("#{docker_bin} --version").stdout.strip
110
- required_docker_version = '1.10.0'
108
+ docker_bin = res.stdout.strip
111
109
 
112
- if Gem::Version.new(required_docker_version) >= Gem::Version.new(current_docker_version[/(\d+\.)+\d+/])
113
- raise Error::Dapp, code: :docker_version, data: { version: required_docker_version }
114
- end
110
+ current_docker_version = shellout!("#{docker_bin} --version").stdout.strip
111
+ required_docker_version = '1.10.0'
112
+
113
+ if Gem::Version.new(required_docker_version) >= Gem::Version.new(current_docker_version[/(\d+\.)+\d+/])
114
+ raise Error::Dapp, code: :docker_version, data: { version: required_docker_version }
115
115
  end
116
+
117
+ [].tap do |cmd|
118
+ cmd << docker_bin
119
+ cmd << "--config #{ENV['DAPP_DOCKER_CONFIG']}" if ENV.key?('DAPP_DOCKER_CONFIG')
120
+ end.join(' ')
116
121
  end
117
122
  end
118
123
  end # Dapp
@@ -10,10 +10,10 @@ module Dapp
10
10
 
11
11
  def base_container
12
12
  @base_container ||= begin
13
- if shellout("#{host_docker_bin} inspect #{base_container_name}").exitstatus.nonzero?
13
+ if shellout("#{host_docker} inspect #{base_container_name}").exitstatus.nonzero?
14
14
  log_secondary_process(t(code: 'process.base_container_creating'), short: true) do
15
15
  shellout!(
16
- ["#{host_docker_bin} create",
16
+ ["#{host_docker} create",
17
17
  "--name #{base_container_name}",
18
18
  "--volume /.dapp/deps/base/#{BASE_VERSION} dappdeps/base:#{BASE_VERSION}"].join(' ')
19
19
  )
@@ -10,10 +10,10 @@ module Dapp
10
10
 
11
11
  def gitartifact_container
12
12
  @gitartifact_container ||= begin
13
- if shellout("#{host_docker_bin} inspect #{gitartifact_container_name}").exitstatus.nonzero?
13
+ if shellout("#{host_docker} inspect #{gitartifact_container_name}").exitstatus.nonzero?
14
14
  log_secondary_process(t(code: 'process.gitartifact_container_creating'), short: true) do
15
15
  shellout!(
16
- ["#{host_docker_bin} create",
16
+ ["#{host_docker} create",
17
17
  "--name #{gitartifact_container_name}",
18
18
  "--volume /.dapp/deps/gitartifact/#{GITARTIFACT_VERSION}",
19
19
  "dappdeps/gitartifact:#{GITARTIFACT_VERSION}"].join(' ')
@@ -54,10 +54,10 @@ module Dapp
54
54
 
55
55
  def chefdk_container
56
56
  @chefdk_container ||= begin
57
- if dimg.dapp.shellout("#{dimg.dapp.host_docker_bin} inspect #{chefdk_container_name}").exitstatus.nonzero?
57
+ if dimg.dapp.shellout("#{dimg.dapp.host_docker} inspect #{chefdk_container_name}").exitstatus.nonzero?
58
58
  dimg.dapp.log_secondary_process(dimg.dapp.t(code: 'process.chefdk_container_creating'), short: true) do
59
59
  dimg.dapp.shellout!(
60
- ["#{dimg.dapp.host_docker_bin} create",
60
+ ["#{dimg.dapp.host_docker} create",
61
61
  "--name #{chefdk_container_name}",
62
62
  "--volume /.dapp/deps/chefdk #{chefdk_image}"].join(' ')
63
63
  )
@@ -107,7 +107,7 @@ module Dapp
107
107
  ]
108
108
 
109
109
  builder.dimg.dapp.shellout!(
110
- [ "#{builder.dimg.dapp.host_docker_bin} run --rm",
110
+ [ "#{builder.dimg.dapp.host_docker} run --rm",
111
111
  volumes_from.map {|container| "--volumes-from #{container}"}.join(' '),
112
112
  *local_paths.map {|path| "--volume #{path}:#{path}"},
113
113
  "--volume #{builder.dimg.tmp_path}:#{builder.dimg.tmp_path}",
@@ -65,6 +65,11 @@ BANNER
65
65
  option :build_context_directory,
66
66
  long: '--build-context-directory DIR_PATH',
67
67
  default: nil
68
+
69
+ option :use_system_tar,
70
+ long: '--use-system-tar',
71
+ boolean: true,
72
+ default: false
68
73
  end
69
74
  end
70
75
  end
@@ -9,7 +9,7 @@ module Dapp
9
9
  dapp_containers_flush
10
10
  dapp_dangling_images_flush
11
11
  remove_images_by_query([
12
- "#{host_docker_bin} images",
12
+ "#{host_docker} images",
13
13
  %(--format '{{if ne "#{stage_cache}" .Repository }}{{.Repository}}:{{.Tag}}{{ end }}'),
14
14
  %(-f "label=dapp=#{stage_dapp_label}")
15
15
  ].join(' ')) # FIXME: negative filter is not currently supported by the Docker CLI
@@ -6,19 +6,19 @@ module Dapp
6
6
  protected
7
7
 
8
8
  def dapp_images_names
9
- shellout!(%(#{host_docker_bin} images --format="{{.Repository}}:{{.Tag}}" #{stage_cache})).stdout.lines.map(&:strip)
9
+ shellout!(%(#{host_docker} images --format="{{.Repository}}:{{.Tag}}" #{stage_cache})).stdout.lines.map(&:strip)
10
10
  end
11
11
 
12
12
  def dapp_images_ids
13
- shellout!(%(#{host_docker_bin} images #{stage_cache} -q --no-trunc)).stdout.lines.map(&:strip)
13
+ shellout!(%(#{host_docker} images #{stage_cache} -q --no-trunc)).stdout.lines.map(&:strip)
14
14
  end
15
15
 
16
16
  def dapp_containers_flush
17
- remove_containers_by_query(%(#{host_docker_bin} ps -a -f "label=dapp" -f "name=#{container_name_prefix}" -q), force: true)
17
+ remove_containers_by_query(%(#{host_docker} ps -a -f "label=dapp" -f "name=#{container_name_prefix}" -q), force: true)
18
18
  end
19
19
 
20
20
  def dapp_dangling_images_flush
21
- remove_images_by_query(%(#{host_docker_bin} images -f "dangling=true" -f "label=dapp=#{stage_dapp_label}" -q), force: true)
21
+ remove_images_by_query(%(#{host_docker} images -f "dangling=true" -f "label=dapp=#{stage_dapp_label}" -q), force: true)
22
22
  end
23
23
 
24
24
  def remove_images_by_query(images_query, force: false)
@@ -28,13 +28,13 @@ module Dapp
28
28
  def remove_images(ids, force: false)
29
29
  ids.uniq!
30
30
  check_user_containers!(ids) unless force
31
- remove_base("#{host_docker_bin} rmi%{force_option} %{ids}", ids, force: force)
31
+ remove_base("#{host_docker} rmi%{force_option} %{ids}", ids, force: force)
32
32
  end
33
33
 
34
34
  def check_user_containers!(images_ids)
35
35
  return if images_ids.empty?
36
36
  log_step_with_indent(:'check user containers') do
37
- run_command(%(#{host_docker_bin} ps -a -q #{images_ids.uniq.map { |image_id| "--filter=ancestor=#{image_id}" }.join(' ')})).tap do |res|
37
+ run_command(%(#{host_docker} ps -a -q #{images_ids.uniq.map { |image_id| "--filter=ancestor=#{image_id}" }.join(' ')})).tap do |res|
38
38
  raise Error::Command, code: :user_containers_detected, data: { ids: res.stdout.strip } if res && !res.stdout.strip.empty? && !dry_run?
39
39
  end
40
40
  end
@@ -45,7 +45,7 @@ module Dapp
45
45
  end
46
46
 
47
47
  def remove_containers(ids, force: false)
48
- remove_base("#{host_docker_bin} rm%{force_option} %{ids}", ids.uniq, force: force)
48
+ remove_base("#{host_docker} rm%{force_option} %{ids}", ids.uniq, force: force)
49
49
  end
50
50
 
51
51
  def remove_base(query_format, ids, force: false)
@@ -45,11 +45,11 @@ module Dapp
45
45
  end
46
46
 
47
47
  def dapp_containers_flush_by_label(label)
48
- remove_containers_by_query(%(#{host_docker_bin} ps -a -f "label=#{label}" -q), force: true)
48
+ remove_containers_by_query(%(#{host_docker} ps -a -f "label=#{label}" -q), force: true)
49
49
  end
50
50
 
51
51
  def dapp_dangling_images_flush_by_label(label)
52
- remove_images_by_query(%(#{host_docker_bin} images -f "dangling=true" -f "label=#{label}" -q), force: true)
52
+ remove_images_by_query(%(#{host_docker} images -f "dangling=true" -f "label=#{label}" -q), force: true)
53
53
  end
54
54
 
55
55
  def dapp_images_flush_by_label(label)
@@ -59,7 +59,7 @@ module Dapp
59
59
 
60
60
  def dapp_images_by_label(label)
61
61
  @dapp_images ||= begin
62
- shellout!(%(#{host_docker_bin} images -f "dangling=false" --format="{{.Repository}}:{{.Tag}}" -f "label=#{label}"))
62
+ shellout!(%(#{host_docker} images -f "dangling=false" --format="{{.Repository}}:{{.Tag}}" -f "label=#{label}"))
63
63
  .stdout
64
64
  .lines
65
65
  .map(&:strip)
@@ -68,7 +68,7 @@ module Dapp
68
68
 
69
69
  def proper_cache_all_images
70
70
  shellout!([
71
- "#{host_docker_bin} images",
71
+ "#{host_docker} images",
72
72
  '--format="{{.Repository}}:{{.Tag}}"',
73
73
  %(-f "label=dapp-cache-version=#{::Dapp::BUILD_CACHE_VERSION}" -f "dangling=false")
74
74
  ].join(' ')).stdout.lines.map(&:strip)
@@ -51,7 +51,7 @@ module Dapp
51
51
  def actual_cache_images
52
52
  @actual_cache_images ||= begin
53
53
  shellout!([
54
- "#{host_docker_bin} images",
54
+ "#{host_docker} images",
55
55
  '--format="{{.Repository}}:{{.Tag}}"',
56
56
  %(-f "label=dapp-cache-version=#{::Dapp::BUILD_CACHE_VERSION}"),
57
57
  stage_cache
@@ -60,7 +60,7 @@ module Dapp
60
60
  end
61
61
 
62
62
  def dapp_images_hash
63
- shellout!(%(#{host_docker_bin} images --format "{{.Repository}}:{{.Tag}};{{.ID}}" --no-trunc #{stage_cache})).stdout.lines.map do |line|
63
+ shellout!(%(#{host_docker} images --format "{{.Repository}}:{{.Tag}};{{.ID}}" --no-trunc #{stage_cache})).stdout.lines.map do |line|
64
64
  line.strip.split(';')
65
65
  end.to_h
66
66
  end
@@ -79,7 +79,7 @@ module Dapp
79
79
  end
80
80
 
81
81
  def image_exist?(image_id)
82
- shellout!(%(#{host_docker_bin} inspect #{image_id}))
82
+ shellout!(%(#{host_docker} inspect #{image_id}))
83
83
  true
84
84
  rescue ::Dapp::Error::Shellout
85
85
  false
@@ -90,7 +90,7 @@ module Dapp
90
90
  end
91
91
 
92
92
  def image_parent(image_id)
93
- shellout!(%(#{host_docker_bin} inspect -f {{.Parent}} #{image_id})).stdout.strip
93
+ shellout!(%(#{host_docker} inspect -f {{.Parent}} #{image_id})).stdout.strip
94
94
  end
95
95
 
96
96
  def proper_git_commit
@@ -109,7 +109,7 @@ module Dapp
109
109
  def dapp_images_detailed
110
110
  @dapp_images_detailed ||= {}.tap do |images|
111
111
  dapp_images_names.each do |image_name|
112
- shellout!(%(#{host_docker_bin} inspect --format='{{json .}}' #{image_name})).stdout.strip.tap do |output|
112
+ shellout!(%(#{host_docker} inspect --format='{{json .}}' #{image_name})).stdout.strip.tap do |output|
113
113
  images[image_name] = output == 'null' ? {} : JSON.parse(output)
114
114
  end
115
115
  end
@@ -120,7 +120,7 @@ module Dapp
120
120
  end
121
121
 
122
122
  def run(docker_options, command)
123
- cmd = "#{dapp.host_docker_bin} run #{[docker_options, last_stage.image.built_id, command].flatten.compact.join(' ')}"
123
+ cmd = "#{dapp.host_docker} run #{[docker_options, last_stage.image.built_id, command].flatten.compact.join(' ')}"
124
124
  if dapp.dry_run?
125
125
  dapp.log(cmd)
126
126
  else
@@ -157,7 +157,7 @@ module Dapp
157
157
  end
158
158
 
159
159
  def introspect_image!(image:, options:)
160
- cmd = "#{dapp.host_docker_bin} run -ti --rm --entrypoint #{dapp.bash_bin} #{options} #{image}"
160
+ cmd = "#{dapp.host_docker} run -ti --rm --entrypoint #{dapp.bash_bin} #{options} #{image}"
161
161
  system(cmd)
162
162
  end
163
163
 
@@ -167,7 +167,7 @@ module Dapp
167
167
  # Чтобы от них избавиться — запускаем docker-контейнер под root-пользователем
168
168
  # и удаляем примонтированную tmp-директорию.
169
169
  cmd = "".tap do |cmd|
170
- cmd << "#{dapp.host_docker_bin} run --rm"
170
+ cmd << "#{dapp.host_docker} run --rm"
171
171
  cmd << " --volume #{dapp.tmp_base_dir}:#{dapp.tmp_base_dir}"
172
172
  cmd << " alpine:3.6"
173
173
  cmd << " rm -rf #{tmp_path}"
@@ -67,13 +67,13 @@ module Dapp
67
67
  when :directory
68
68
  stage.image.add_service_change_label :"dapp-git-#{paramshash}-type" => 'directory'
69
69
 
70
- commands << "#{repo.dimg.dapp.install_bin} #{credentials.join(' ')} -d #{to}"
71
- commands << "#{sudo}#{repo.dimg.dapp.tar_bin} -xf #{archive_file(stage, *archive_stage_commits(stage))} -C #{to}"
70
+ commands << "#{repo.dimg.dapp.install_bin} #{credentials.join(' ')} -d \"#{to}\""
71
+ commands << "#{sudo}#{repo.dimg.dapp.tar_bin} -xf #{archive_file(stage, *archive_stage_commits(stage))} -C \"#{to}\""
72
72
  when :file
73
73
  stage.image.add_service_change_label :"dapp-git-#{paramshash}-type" => 'file'
74
74
 
75
- commands << "#{repo.dimg.dapp.install_bin} #{credentials.join(' ')} -d #{File.dirname(to)}"
76
- commands << "#{sudo}#{repo.dimg.dapp.tar_bin} -xf #{archive_file(stage, *archive_stage_commits(stage))} -C #{File.dirname(to)}"
75
+ commands << "#{repo.dimg.dapp.install_bin} #{credentials.join(' ')} -d \"#{File.dirname(to)}\""
76
+ commands << "#{sudo}#{repo.dimg.dapp.tar_bin} -xf #{archive_file(stage, *archive_stage_commits(stage))} -C \"#{File.dirname(to)}\""
77
77
  end
78
78
  end
79
79
  end
@@ -89,14 +89,14 @@ module Dapp
89
89
  if any_changes?(*dev_patch_stage_commits(stage))
90
90
  case archive_type
91
91
  when :directory
92
- changed_files = diff_patches(*dev_patch_stage_commits(stage)).map {|p| File.join(to, cwd, p.delta.new_file[:path])}
92
+ changed_files = diff_patches(*dev_patch_stage_commits(stage)).map {|p| "\"#{File.join(to, cwd, p.delta.new_file[:path])}\""}
93
93
  commands << "#{repo.dimg.dapp.rm_bin} -rf #{changed_files.join(' ')}"
94
- commands << "#{repo.dimg.dapp.install_bin} #{credentials.join(' ')} -d #{to}"
95
- commands << "#{sudo}#{repo.dimg.dapp.tar_bin} -xf #{archive_file(stage, *dev_patch_stage_commits(stage))} -C #{to}"
94
+ commands << "#{repo.dimg.dapp.install_bin} #{credentials.join(' ')} -d \"#{to}\""
95
+ commands << "#{sudo}#{repo.dimg.dapp.tar_bin} -xf #{archive_file(stage, *dev_patch_stage_commits(stage))} -C \"#{to}\""
96
96
  when :file
97
- commands << "#{repo.dimg.dapp.rm_bin} -rf #{to}"
98
- commands << "#{repo.dimg.dapp.install_bin} #{credentials.join(' ')} -d #{File.dirname(to)}"
99
- commands << "#{sudo}#{repo.dimg.dapp.tar_bin} -xf #{archive_file(stage, *dev_patch_stage_commits(stage))} -C #{File.dirname(to)}"
97
+ commands << "#{repo.dimg.dapp.rm_bin} -rf \"#{to}\""
98
+ commands << "#{repo.dimg.dapp.install_bin} #{credentials.join(' ')} -d \"#{File.dirname(to)}\""
99
+ commands << "#{sudo}#{repo.dimg.dapp.tar_bin} -xf #{archive_file(stage, *dev_patch_stage_commits(stage))} -C \"#{File.dirname(to)}\""
100
100
  else
101
101
  raise
102
102
  end
@@ -105,11 +105,11 @@ module Dapp
105
105
  if patch_any_changes?(stage)
106
106
  case archive_type
107
107
  when :directory
108
- commands << "#{repo.dimg.dapp.install_bin} #{credentials.join(' ')} -d #{to}"
109
- commands << "#{sudo}#{repo.dimg.dapp.git_bin} apply --whitespace=nowarn --directory=#{to} --unsafe-paths #{patch_file(stage, *patch_stage_commits(stage))}"
108
+ commands << "#{repo.dimg.dapp.install_bin} #{credentials.join(' ')} -d \"#{to}\""
109
+ commands << "#{sudo}#{repo.dimg.dapp.git_bin} apply --whitespace=nowarn --directory=\"#{to}\" --unsafe-paths #{patch_file(stage, *patch_stage_commits(stage))}"
110
110
  when :file
111
- commands << "#{repo.dimg.dapp.install_bin} #{credentials.join(' ')} -d #{File.dirname(to)}"
112
- commands << "#{sudo}#{repo.dimg.dapp.git_bin} apply --whitespace=nowarn --directory=#{File.dirname(to)} --unsafe-paths #{patch_file(stage, *patch_stage_commits(stage))}"
111
+ commands << "#{repo.dimg.dapp.install_bin} #{credentials.join(' ')} -d \"#{File.dirname(to)}\""
112
+ commands << "#{sudo}#{repo.dimg.dapp.git_bin} apply --whitespace=nowarn --directory=\"#{File.dirname(to)}\" --unsafe-paths #{patch_file(stage, *patch_stage_commits(stage))}"
113
113
  else
114
114
  raise
115
115
  end
@@ -213,33 +213,65 @@ module Dapp
213
213
  end
214
214
 
215
215
  def archive_file(stage, from_commit, to_commit)
216
- tar_write(repo.dimg.tmp_path('archives', archive_file_name(from_commit, to_commit))) do |tar|
217
- diff_patches(from_commit, to_commit).each do |patch|
218
- entry = patch.delta.new_file
219
-
220
- content = begin
221
- if to_commit == nil
222
- next unless (path = repo.path.dirname.join(entry[:path])).file?
223
- File.read(path)
224
- else
225
- repo.lookup_object(entry[:oid]).content
226
- end
227
- end
216
+ if repo.dimg.dapp.options[:use_system_tar]
217
+ archive_file_with_system_tar(stage, from_commit, to_commit)
218
+ else
219
+ archive_file_with_tar_writer(stage, from_commit, to_commit)
220
+ end
221
+ repo.dimg.container_tmp_path('archives', archive_file_name(from_commit, to_commit))
222
+ end
228
223
 
229
- if entry[:mode] == 40960 # symlink
230
- tar.add_symlink slice_cwd(stage, entry[:path]), content, entry[:mode]
224
+ def archive_file_with_tar_writer(stage, from_commit, to_commit)
225
+ tar_write(repo.dimg.tmp_path('archives', archive_file_name(from_commit, to_commit))) do |tar|
226
+ archive_diff_pathes(stage,from_commit, to_commit) do |path, content, mode|
227
+ if mode == 40960 # symlink
228
+ tar.add_symlink path, content, mode
231
229
  else
232
- tar.add_file slice_cwd(stage, entry[:path]), entry[:mode] do |tf|
230
+ tar.add_file path, mode do |tf|
233
231
  tf.write content
234
232
  end
235
233
  end
236
234
  end
237
235
  end
238
- repo.dimg.container_tmp_path('archives', archive_file_name(from_commit, to_commit))
239
236
  rescue Gem::Package::TooLongFileName => e
240
237
  raise Error::TarWriter, message: e.message
241
238
  end
242
239
 
240
+ def archive_file_with_system_tar(stage, from_commit, to_commit)
241
+ repo.dimg.tmp_path('archives', archive_file_name(from_commit, to_commit)).tap do |archive_path|
242
+ relative_archive_file_path = File.join('archives_files', file_name(from_commit, to_commit))
243
+ archive_diff_pathes(stage, from_commit, to_commit) do |path, content, mode|
244
+ file_path = repo.dimg.tmp_path(relative_archive_file_path, path)
245
+
246
+ if mode == 40960 # symlink
247
+ FileUtils.symlink(content, file_path)
248
+ else
249
+ IO.write(file_path, content)
250
+ FileUtils.chmod(mode, file_path)
251
+ end
252
+ end
253
+
254
+ repo.dimg.dapp.shellout!("tar -C #{repo.dimg.tmp_path(relative_archive_file_path)} -cf #{archive_path} .")
255
+ end
256
+ end
257
+
258
+ def archive_diff_pathes(stage, from_commit, to_commit)
259
+ diff_patches(from_commit, to_commit).each do |patch|
260
+ entry = patch.delta.new_file
261
+
262
+ content = begin
263
+ if to_commit == nil
264
+ next unless (path = repo.path.dirname.join(entry[:path])).file?
265
+ File.read(path)
266
+ else
267
+ repo.lookup_object(entry[:oid]).content
268
+ end
269
+ end
270
+
271
+ yield slice_cwd(stage, entry[:path]), content, entry[:mode]
272
+ end
273
+ end
274
+
243
275
  def slice_cwd(stage, path)
244
276
  return path if cwd.empty?
245
277
 
@@ -248,6 +280,7 @@ module Dapp
248
280
  path
249
281
  .reverse
250
282
  .chomp(cwd.reverse)
283
+ .chomp('/')
251
284
  .reverse
252
285
  when :file
253
286
  File.basename(to)
@@ -257,7 +290,7 @@ module Dapp
257
290
  end
258
291
 
259
292
  def archive_file_name(from_commit, to_commit)
260
- file_name(from_commit, to_commit, 'tar')
293
+ file_name(from_commit, to_commit, ext: 'tar')
261
294
  end
262
295
 
263
296
  def patch_file(stage, from_commit, to_commit)
@@ -271,7 +304,7 @@ module Dapp
271
304
  def change_patch_new_file_path(stage, patch)
272
305
  patch.to_s.lines.tap do |lines|
273
306
  modify_patch_line = proc do |line_number, path_char|
274
- action_part, path_part = lines[line_number].split
307
+ action_part, path_part = lines[line_number].strip.split(' ', 2)
275
308
  if (path_with_cwd = path_part.partition("#{path_char}/").last).start_with?(cwd)
276
309
  native_path = case archive_type
277
310
  when :directory
@@ -321,11 +354,11 @@ module Dapp
321
354
  end
322
355
 
323
356
  def patch_file_name(from_commit, to_commit)
324
- file_name(from_commit, to_commit, 'patch')
357
+ file_name(from_commit, to_commit, ext: 'patch')
325
358
  end
326
359
 
327
- def file_name(*args, ext)
328
- "#{[paramshash, args].flatten.compact.join('_')}.#{ext}"
360
+ def file_name(*args, ext: nil)
361
+ "#{[paramshash, args].flatten.compact.join('_')}#{".#{ext}" unless ext.nil? }"
329
362
  end
330
363
 
331
364
  def diff_patches(from_commit, to_commit, paths: include_paths_or_cwd)
@@ -22,21 +22,21 @@ module Dapp
22
22
 
23
23
  def untag!
24
24
  raise Error::Build, code: :image_already_untagged, data: { name: name } unless tagged?
25
- dapp.shellout!("#{dapp.host_docker_bin} rmi #{name}")
25
+ dapp.shellout!("#{dapp.host_docker} rmi #{name}")
26
26
  cache_reset
27
27
  end
28
28
 
29
29
  def push!
30
30
  raise Error::Build, code: :image_not_exist, data: { name: name } unless tagged?
31
31
  dapp.log_secondary_process(dapp.t(code: 'process.image_push', data: { name: name })) do
32
- dapp.shellout!("#{dapp.host_docker_bin} push #{name}", verbose: true)
32
+ dapp.shellout!("#{dapp.host_docker} push #{name}", verbose: true)
33
33
  end
34
34
  end
35
35
 
36
36
  def pull!
37
37
  return if tagged?
38
38
  dapp.log_secondary_process(dapp.t(code: 'process.image_pull', data: { name: name })) do
39
- dapp.shellout!("#{dapp.host_docker_bin} pull #{name}", verbose: true)
39
+ dapp.shellout!("#{dapp.host_docker} pull #{name}", verbose: true)
40
40
  end
41
41
  cache_reset
42
42
  end
@@ -56,7 +56,7 @@ module Dapp
56
56
  end
57
57
 
58
58
  def self.image_config_option(image_id:, option:)
59
- output = ::Dapp::Dapp.shellout!("#{::Dapp::Dapp.host_docker_bin} inspect --format='{{json .Config.#{option.to_s.capitalize}}}' #{image_id}").stdout.strip
59
+ output = ::Dapp::Dapp.shellout!("#{::Dapp::Dapp.host_docker} inspect --format='{{json .Config.#{option.to_s.capitalize}}}' #{image_id}").stdout.strip
60
60
  output == 'null' ? [] : JSON.parse(output)
61
61
  end
62
62
 
@@ -88,17 +88,17 @@ module Dapp
88
88
  end
89
89
 
90
90
  def tag!(id:, tag:, verbose: false, quiet: false)
91
- ::Dapp::Dapp.shellout!("#{::Dapp::Dapp.host_docker_bin} tag #{id} #{tag}", verbose: verbose, quiet: quiet)
91
+ ::Dapp::Dapp.shellout!("#{::Dapp::Dapp.host_docker} tag #{id} #{tag}", verbose: verbose, quiet: quiet)
92
92
  cache_reset
93
93
  end
94
94
 
95
95
  def save!(image_or_images, file_path, verbose: false, quiet: false)
96
96
  images = Array(image_or_images).join(' ')
97
- ::Dapp::Dapp.shellout!("#{::Dapp::Dapp.host_docker_bin} save -o #{file_path} #{images}", verbose: verbose, quiet: quiet)
97
+ ::Dapp::Dapp.shellout!("#{::Dapp::Dapp.host_docker} save -o #{file_path} #{images}", verbose: verbose, quiet: quiet)
98
98
  end
99
99
 
100
100
  def load!(file_path, verbose: false, quiet: false)
101
- ::Dapp::Dapp.shellout!("#{::Dapp::Dapp.host_docker_bin} load -i #{file_path}", verbose: verbose, quiet: quiet)
101
+ ::Dapp::Dapp.shellout!("#{::Dapp::Dapp.host_docker} load -i #{file_path}", verbose: verbose, quiet: quiet)
102
102
  end
103
103
 
104
104
  def cache
@@ -107,7 +107,7 @@ module Dapp
107
107
 
108
108
  def cache_reset(name = '')
109
109
  cache.delete(name)
110
- ::Dapp::Dapp.shellout!("#{::Dapp::Dapp.host_docker_bin} images --format='{{.Repository}}:{{.Tag}};{{.ID}};{{.CreatedAt}};{{.Size}}' --no-trunc #{name}")
110
+ ::Dapp::Dapp.shellout!("#{::Dapp::Dapp.host_docker} images --format='{{.Repository}}:{{.Tag}};{{.ID}};{{.CreatedAt}};{{.Size}}' --no-trunc #{name}")
111
111
  .stdout
112
112
  .lines
113
113
  .each do |l|
@@ -25,7 +25,7 @@ module Dapp
25
25
  run!
26
26
  @built_id = commit!
27
27
  ensure
28
- dapp.shellout("#{dapp.host_docker_bin} rm #{container_name}")
28
+ dapp.shellout("#{dapp.host_docker} rm #{container_name}")
29
29
  end
30
30
 
31
31
  def built?
@@ -70,7 +70,7 @@ module Dapp
70
70
 
71
71
  def run!
72
72
  raise Error::Build, code: :built_id_not_defined if from.built_id.nil?
73
- dapp.shellout!("#{dapp.host_docker_bin} run #{prepared_options} #{from.built_id} -ec '#{prepared_bash_command}'", verbose: true)
73
+ dapp.shellout!("#{dapp.host_docker} run #{prepared_options} #{from.built_id} -ec '#{prepared_bash_command}'", verbose: true)
74
74
  rescue ::Dapp::Error::Shellout => error
75
75
  dapp.log_warning(desc: { code: :launched_command, data: { command: prepared_commands.join(' && ') }, context: :container })
76
76
 
@@ -83,7 +83,7 @@ module Dapp
83
83
  end
84
84
 
85
85
  def commit!
86
- dapp.shellout!("#{dapp.host_docker_bin} commit #{prepared_change} #{container_name}").stdout.strip
86
+ dapp.shellout!("#{dapp.host_docker} commit #{prepared_change} #{container_name}").stdout.strip
87
87
  end
88
88
 
89
89
  def clone!(name)
@@ -64,7 +64,7 @@ spec:
64
64
  secretName: {{ .Chart.Name }}-backend
65
65
  containers:
66
66
  - command: [ '/bin/bash', '-l', '-c', 'bundle exec ctl start' ]
67
- image: {{ tuple . 'specific_name' | include "dimg" }} # or nameless dimg {{ tuple . | include "dimg" }}
67
+ image: {{ tuple "specific-name" . | include "dimg" }} # or nameless dimg {{ tuple . | include "dimg" }}
68
68
  imagePullPolicy: Always
69
69
  name: {{ .Chart.Name }}-backend
70
70
  livenessProbe:
@@ -79,10 +79,10 @@ module Dapp
79
79
  {{- if (ge (len (index .)) 2) -}}
80
80
  {{- $name := index . 0 -}}
81
81
  {{- $context := index . 1 -}}
82
- {{- printf "%s:%s-%s" $context.Values.global.dapp.repo $name $context.Values.global.dapp.image_version -}}
82
+ {{- printf "%v:%v-%v" $context.Values.global.dapp.repo $name $context.Values.global.dapp.image_version -}}
83
83
  {{- else -}}
84
84
  {{- $context := index . 0 -}}
85
- {{- printf "%s:%s" $context.Values.global.dapp.repo $context.Values.global.dapp.image_version -}}
85
+ {{- printf "%v:%v" $context.Values.global.dapp.repo $context.Values.global.dapp.image_version -}}
86
86
  {{- end -}}
87
87
  {{- end -}}
88
88
 
@@ -1,4 +1,4 @@
1
1
  module Dapp
2
- VERSION = '0.14.11'.freeze
2
+ VERSION = '0.14.12'.freeze
3
3
  BUILD_CACHE_VERSION = 16
4
4
  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.14.11
4
+ version: 0.14.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitry Stolyarov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-06 00:00:00.000000000 Z
11
+ date: 2017-09-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mixlib-shellout