dapp 0.5.8 → 0.5.9

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: b8a9ec9afc7917a8ecf1ba8d47e65defef16df8f
4
- data.tar.gz: 50c22e22781a24115fc79514ad9c71410784a75e
3
+ metadata.gz: 442f21d5a2d84a60587d83bf4e3578622d079c17
4
+ data.tar.gz: f63c5c35c355eca4929c7a3f7fe1670d4f12fb16
5
5
  SHA512:
6
- metadata.gz: 919231c2f8a6f6bf78780bcf969921472ddd416dee45fc46404cb9ff84f22848c780e8a76b342aa34d1024986fa651dd19e38d496328caa8610b297ac56d4c80
7
- data.tar.gz: 929a790d85767cc510136ed9283b6ec86cb473e18cdee69fec205b0277dba81a11952930edf0e6ac28e0d725359156c76a7fea3d390e8b61a51bf02c550575aa
6
+ metadata.gz: c56953614a510d5e1124080719375ac5c31545ad660f36749050f37918f7bdc3d90791e44b0a171f9099b7d1fc5723dd85a32814d85a47a87d9bae7b8ad8bbe7
7
+ data.tar.gz: d6c837e5d2d90544195a03f32c03a76167e23fab91c3f6bd803534987443ccaca06da497627ae6c96be3248a26aef127eff7bbeaa79353203e694b3a8bd3b0ce
data/config/en/common.yml CHANGED
@@ -10,11 +10,12 @@ en:
10
10
  process:
11
11
  artifact_copy: "copying artifact '%{name}'"
12
12
  artifact_building: "building artifact '%{name}'"
13
- git_artifact_loading: 'loading git_artifact'
14
13
  git_artifact_clone: "cloning remote git_artifact '%{name}'"
15
14
  git_artifact_fetch: "fetching remote git_artifact '%{name}'"
16
- chefdk_loading: 'loading chefdk'
17
15
  berks_vendor: 'berks_vendor'
16
+ gitartifact_container_loading: 'loading dappdeps/gitartifact container'
17
+ chefdk_container_loading: 'loading dappdeps/chefdk container'
18
+ system_shellout_container_loading: 'loading system shellout container'
18
19
  status:
19
20
  process:
20
21
  pushing: '[PUSHING]'
@@ -29,4 +30,4 @@ en:
29
30
  not_present: '[NOT PRESENT]'
30
31
  build: '[BUILD]'
31
32
  empty: '[EMPTY]'
32
- push: '[PUSH]'
33
+ push: '[PUSH]'
data/lib/dapp.rb CHANGED
@@ -85,6 +85,8 @@ require 'dapp/application/git_artifact'
85
85
  require 'dapp/application/logging'
86
86
  require 'dapp/application/path'
87
87
  require 'dapp/application/tags'
88
+ require 'dapp/application/deps/gitartifact'
89
+ require 'dapp/application/system_shellout'
88
90
  require 'dapp/application'
89
91
  require 'dapp/image/argument'
90
92
  require 'dapp/image/docker'
@@ -9,6 +9,8 @@ module Dapp
9
9
  include GitArtifact
10
10
  include Path
11
11
  include Tags
12
+ include Deps::Gitartifact
13
+ include SystemShellout
12
14
  include Dapp::Filelock
13
15
 
14
16
  attr_reader :config
@@ -0,0 +1,39 @@
1
+ module Dapp
2
+ # Application
3
+ class Application
4
+ # Deps
5
+ module Deps
6
+ # Gitartifact
7
+ module Gitartifact
8
+ GITARTIFACT_IMAGE = 'dappdeps/gitartifact:0.1.5'.freeze
9
+
10
+ def gitartifact_container_name # FIXME: hashsum(image) or dockersafe()
11
+ GITARTIFACT_IMAGE.tr('/', '_').tr(':', '_')
12
+ end
13
+
14
+ def gitartifact_container
15
+ @gitartifact_container ||= begin
16
+ if shellout("docker inspect #{gitartifact_container_name}").exitstatus.nonzero?
17
+ log_secondary_process(t(code: 'process.gitartifact_container_loading'), short: true) do
18
+ shellout ['docker run',
19
+ '--restart=no',
20
+ "--name #{gitartifact_container_name}",
21
+ "--volume /.dapp/deps/gitartifact #{GITARTIFACT_IMAGE}",
22
+ '2>/dev/null'].join(' ')
23
+ end
24
+ end
25
+ gitartifact_container_name
26
+ end
27
+ end
28
+
29
+ def git_path
30
+ '/.dapp/deps/gitartifact/bin/git'
31
+ end
32
+
33
+ def sudo_path
34
+ '/.dapp/deps/gitartifact/bin/sudo'
35
+ end
36
+ end # Gitartifact
37
+ end # Deps
38
+ end # Application
39
+ end # Dapp
@@ -0,0 +1,57 @@
1
+ module Dapp
2
+ # Application
3
+ class Application
4
+ # SystemShellout
5
+ module SystemShellout
6
+ SYSTEM_SHELLOUT_IMAGE = 'ubuntu:14.04'
7
+ SYSTEM_SHELLOUT_VERSION = 2
8
+
9
+ def system_shellout_container_name
10
+ "dapp_system_shellout_#{hashsum [SYSTEM_SHELLOUT_VERSION,
11
+ SYSTEM_SHELLOUT_IMAGE,
12
+ Deps::Gitartifact::GITARTIFACT_IMAGE]}"
13
+ end
14
+
15
+ def system_shellout_container
16
+ @system_shellout_container ||= begin
17
+ if shellout("docker inspect #{system_shellout_container_name}").exitstatus.nonzero?
18
+ volumes_from = [gitartifact_container]
19
+ log_secondary_process(t(code: 'process.system_shellout_container_loading'), short: true) do
20
+ shellout! ['docker run --detach --privileged',
21
+ "--name #{system_shellout_container_name}",
22
+ *volumes_from.map { |container| "--volumes-from #{container}" },
23
+ '--volume /:/.system_shellout_root',
24
+ "#{SYSTEM_SHELLOUT_IMAGE} bash -ec 'while true ; do sleep 1 ; done'"].join(' ')
25
+
26
+ shellout! ["docker exec #{system_shellout_container_name}",
27
+ "bash -ec '#{[
28
+ 'mkdir -p /.system_shellout_root/.dapp',
29
+ 'mount --rbind /.dapp /.system_shellout_root/.dapp',
30
+ 'mount --rbind /usr/bin /.system_shellout_root/usr/bin',
31
+ 'apt-get update -qq',
32
+ 'apt-get install -qq openssh-client',
33
+ ].join(' && ')}'"].join(' ')
34
+ end
35
+ end
36
+
37
+ system_shellout_container_name
38
+ end
39
+ end
40
+
41
+ def system_shellout(command, **kwargs)
42
+ shellout _to_system_shellout_command(command), **kwargs
43
+ end
44
+
45
+ def system_shellout!(command, **kwargs)
46
+ shellout! _to_system_shellout_command(command), **kwargs
47
+ end
48
+
49
+ private
50
+
51
+ def _to_system_shellout_command(command)
52
+ cmd = shellout_pack ["cd #{Dir.pwd}", command].join(' && ')
53
+ "docker exec #{system_shellout_container} chroot /.system_shellout_root bash -ec '#{cmd}'"
54
+ end
55
+ end # SystemShellout
56
+ end # Application
57
+ end # Dapp
@@ -5,8 +5,6 @@ module Dapp
5
5
  class SourceBase < Base
6
6
  attr_accessor :prev_source_stage, :next_source_stage
7
7
 
8
- GITARTIFACT_IMAGE = 'dappdeps/gitartifact:0.1.5'.freeze
9
-
10
8
  def prev_source_stage
11
9
  dependencies_stage.prev_stage.prev_stage
12
10
  end
@@ -21,7 +19,7 @@ module Dapp
21
19
 
22
20
  def image
23
21
  super do |image|
24
- image.add_volumes_from gitartifact_container
22
+ image.add_volumes_from application.gitartifact_container
25
23
  application.git_artifacts.each do |git_artifact|
26
24
  image.add_volume "#{git_artifact.repo.path}:#{git_artifact.repo.container_path}:ro"
27
25
  image.add_command git_artifact.send(apply_command_method, self)
@@ -44,31 +42,8 @@ module Dapp
44
42
  end
45
43
  end
46
44
 
47
- def git_dappdeps_path
48
- '/.dapp/deps/gitartifact/bin/git'
49
- end
50
-
51
45
  protected
52
46
 
53
- def gitartifact_container_name # FIXME: hashsum(image) or dockersafe()
54
- GITARTIFACT_IMAGE.tr('/', '_').tr(':', '_')
55
- end
56
-
57
- def gitartifact_container
58
- @gitartifact_container ||= begin
59
- if application.shellout("docker inspect #{gitartifact_container_name}").exitstatus.nonzero?
60
- application.log_secondary_process(application.t(code: 'process.git_artifact_loading'), short: true) do
61
- application.shellout ['docker run',
62
- '--restart=no',
63
- "--name #{gitartifact_container_name}",
64
- "--volume /.dapp/deps/gitartifact #{GITARTIFACT_IMAGE}",
65
- '2>/dev/null'].join(' ')
66
- end
67
- end
68
- gitartifact_container_name
69
- end
70
- end
71
-
72
47
  def should_not_be_detailed?
73
48
  true
74
49
  end
@@ -22,7 +22,7 @@ module Dapp
22
22
  image.add_command "export DAPP_BUILD_STAGE=#{stage}"
23
23
 
24
24
  image.add_volume "#{stage_build_path(stage)}:#{container_stage_build_path(stage)}:ro"
25
- image.add_command [chef_solo_dappdeps_path,
25
+ image.add_command ['/.dapp/deps/chefdk/bin/chef-solo',
26
26
  '--legacy-mode',
27
27
  "-c #{container_stage_config_path(stage)}",
28
28
  "-o #{stage_cookbooks_runlist(stage).join(',')}"].join(' ')
@@ -139,7 +139,7 @@ module Dapp
139
139
  def chefdk_container
140
140
  @chefdk_container ||= begin
141
141
  if application.shellout("docker inspect #{chefdk_container_name}").exitstatus.nonzero?
142
- application.log_secondary_process(application.t(code: 'process.chefdk_loading'), short: true) do
142
+ application.log_secondary_process(application.t(code: 'process.chefdk_container_loading'), short: true) do
143
143
  application.shellout(
144
144
  ['docker run',
145
145
  '--restart=no',
@@ -166,7 +166,7 @@ module Dapp
166
166
  'echo " StrictHostKeyChecking no" >> ~/.ssh/config',
167
167
  'if [ ! -f Berksfile.lock ] ; then echo "Berksfile.lock not found" 1>&2 ; exit 1 ; fi',
168
168
  'cp -a Berksfile.lock /tmp/Berksfile.lock.orig',
169
- "#{berks_dappdeps_path} vendor /tmp/vendored_cookbooks",
169
+ "/.dapp/deps/chefdk/bin/berks vendor /tmp/vendored_cookbooks",
170
170
  'export LOCKDIFF=$(diff -u0 Berksfile.lock /tmp/Berksfile.lock.orig)',
171
171
  ['if [ "$LOCKDIFF" != "" ] ; then ',
172
172
  'cp -a /tmp/Berksfile.lock.orig Berksfile.lock ; ',
@@ -381,14 +381,6 @@ module Dapp
381
381
  def container_stage_build_path(_stage, *path)
382
382
  path.compact.map(&:to_s).inject(Pathname.new('/.dapp/chef/build'), &:+)
383
383
  end
384
-
385
- def chef_solo_dappdeps_path
386
- '/.dapp/deps/chefdk/bin/chef-solo'
387
- end
388
-
389
- def berks_dappdeps_path
390
- '/.dapp/deps/chefdk/bin/berks'
391
- end
392
384
  end
393
385
  end
394
386
  end
@@ -27,7 +27,7 @@ module Dapp
27
27
  credentials = [:owner, :group].map { |attr| "--#{attr}=#{send(attr)}" unless send(attr).nil? }.compact
28
28
 
29
29
  ["install #{credentials.join(' ')} -d #{where_to_add}",
30
- ["#{stage.git_dappdeps_path} --git-dir=#{repo.container_path} archive #{stage.layer_commit(self)}:#{cwd} #{paths}",
30
+ ["#{repo.application.git_path} --git-dir=#{repo.container_path} archive #{stage.layer_commit(self)}:#{cwd} #{paths}",
31
31
  "#{sudo}tar -x -C #{where_to_add}"].join(' | ')]
32
32
  end
33
33
 
@@ -36,8 +36,8 @@ module Dapp
36
36
  prev_commit = stage.prev_source_stage.layer_commit(self)
37
37
 
38
38
  if prev_commit != current_commit || any_changes?(prev_commit, current_commit)
39
- [["#{stage.git_dappdeps_path} --git-dir=#{repo.container_path} #{diff_command(prev_commit, current_commit)}",
40
- "#{sudo}#{stage.git_dappdeps_path} apply --whitespace=nowarn --directory=#{where_to_add} --unsafe-paths"].join(' | ')]
39
+ [["#{repo.application.git_path} --git-dir=#{repo.container_path} #{diff_command(prev_commit, current_commit)}",
40
+ "#{sudo}#{repo.application.git_path} apply --whitespace=nowarn --directory=#{where_to_add} --unsafe-paths"].join(' | ')]
41
41
  else
42
42
  []
43
43
  end
@@ -84,7 +84,7 @@ module Dapp
84
84
  sudo = ''
85
85
 
86
86
  if owner || group
87
- sudo = 'sudo -E '
87
+ sudo = "#{repo.application.sudo_path} -E "
88
88
  sudo += "-u #{sudo_format_user(owner)} " if owner
89
89
  sudo += "-g #{sudo_format_user(group)} " if group
90
90
  end
@@ -44,7 +44,7 @@ module Dapp
44
44
  protected
45
45
 
46
46
  def git(command, **kwargs)
47
- application.shellout!("git #{command}", **kwargs)
47
+ application.system_shellout! "#{application.git_path} #{command}", **kwargs
48
48
  end
49
49
  end
50
50
  end
@@ -52,7 +52,8 @@ module Dapp
52
52
 
53
53
  def git(command, **kwargs)
54
54
  if use_ssh_key && ssh_key_path
55
- application.shellout!("ssh-agent bash -ec 'ssh-add #{ssh_key_path}; git #{command}'", **kwargs)
55
+ cmd = application.shellout_pack("/usr/bin/ssh-agent bash -ec '/usr/bin/ssh-add #{ssh_key_path}; #{application.git_path} #{command}'")
56
+ application.system_shellout!("bash -ec '#{cmd}'")
56
57
  else
57
58
  super
58
59
  end
data/lib/dapp/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # Version
2
2
  module Dapp
3
- VERSION = '0.5.8'.freeze
3
+ VERSION = '0.5.9'.freeze
4
4
  BUILD_CACHE_VERSION = 3
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.5.8
4
+ version: 0.5.9
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-08-31 00:00:00.000000000 Z
11
+ date: 2016-09-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mixlib-shellout
@@ -327,9 +327,11 @@ files:
327
327
  - config/en/net_status.yml
328
328
  - lib/dapp.rb
329
329
  - lib/dapp/application.rb
330
+ - lib/dapp/application/deps/gitartifact.rb
330
331
  - lib/dapp/application/git_artifact.rb
331
332
  - lib/dapp/application/logging.rb
332
333
  - lib/dapp/application/path.rb
334
+ - lib/dapp/application/system_shellout.rb
333
335
  - lib/dapp/application/tags.rb
334
336
  - lib/dapp/build/stage/artifact.rb
335
337
  - lib/dapp/build/stage/base.rb