dapp 0.5.12 → 0.5.13

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: 099323795c3915334ad78240e4aaaac9b76e0299
4
- data.tar.gz: 23c70869e1cb2f25369af05d629e09692a349ae9
3
+ metadata.gz: 01676cf63c920ea0e92fe63a31a56b6675bc6292
4
+ data.tar.gz: 3301444d6c80446d4c1e692e941627db4ed3b60f
5
5
  SHA512:
6
- metadata.gz: afa7da11b4dc1c34e0817934c22cc8e2123f16e4c0c7c9c4ffec58b282c2c2d160301a5f6fa0a33adf6aa2df7df00b5b3f932b7f2254251fb2d6812836484632
7
- data.tar.gz: 0c71e6fc8f2de0a7ca9378934e8d26c64c9e4055589d246a3b11c43a50ccd4b6b64cca3ccf60a0946e0228398b3e17e7fbb63b7ba39bcd00db6aa1e3b941391a
6
+ metadata.gz: dc8a5ab0d2441d9382e7cd4a1f2f6f1d5cec834c040e31130ce47f76cbfbc2e632d4f557066655bb40e6f0201edf5a4ad54eb701c7c10e99c913d30ee24e8ef0
7
+ data.tar.gz: cc7078af0e3daa91ab5062538d64ad72cff9b4e87eeee7a0668ed33c19442c4cee2f1a44025265d7d44ff4656c1d176d519cbb80f91a99924d6fe03f52bcf4d4
@@ -12,7 +12,8 @@ en:
12
12
  artifact_building: "building artifact '%{name}'"
13
13
  git_artifact_clone: "cloning remote git_artifact '%{name}'"
14
14
  git_artifact_fetch: "fetching remote git_artifact '%{name}'"
15
- berks_vendor: 'berks_vendor'
15
+ berks_vendor: 'vendoring cookbooks'
16
+ chef_cookbooks_stage_berks_vendor: 'vendoring cookbooks for chef cookbooks stage'
16
17
  gitartifact_container_loading: 'loading dappdeps/gitartifact container'
17
18
  chefdk_container_loading: 'loading dappdeps/chefdk container'
18
19
  system_shellout_container_loading: 'loading system shellout container'
@@ -21,8 +21,6 @@ module Dapp
21
21
  define_method("#{stage}") do |image|
22
22
  unless stage_empty?(stage)
23
23
  image.add_volumes_from(chefdk_container)
24
- image.add_command "export DAPP_BUILD_STAGE=#{stage}"
25
-
26
24
  image.add_volume "#{stage_build_path(stage)}:#{container_stage_build_path(stage)}:ro"
27
25
  image.add_command ['/.dapp/deps/chefdk/bin/chef-solo',
28
26
  '--legacy-mode',
@@ -37,7 +35,7 @@ module Dapp
37
35
  end
38
36
 
39
37
  def chef_cookbooks(image)
40
- image.add_volume "#{cookbooks_vendor_path}:#{application.container_dapp_path('chef_vendored_cookbooks')}"
38
+ image.add_volume "#{cookbooks_vendor_path(chef_cookbooks_stage: true)}:#{application.container_dapp_path('chef_vendored_cookbooks')}"
41
39
  image.add_command(
42
40
  'mkdir -p /usr/share/dapp/chef_repo',
43
41
  ["cp -a #{application.container_dapp_path('chef_vendored_cookbooks')} ",
@@ -155,41 +153,61 @@ module Dapp
155
153
  end
156
154
 
157
155
  # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
158
- def install_cookbooks
156
+ def install_cookbooks(dest_path, chef_cookbooks_stage: false)
159
157
  volumes_from = chefdk_container
160
- application.log_secondary_process(application.t(code: 'process.berks_vendor')) do
158
+ application.log_secondary_process(application.t(code: "process.#{chef_cookbooks_stage ? 'chef_cookbooks_stage_berks_vendor' : 'berks_vendor'}")) do
161
159
  ssh_auth_socket_path = nil
162
160
  ssh_auth_socket_path = Pathname.new(ENV['SSH_AUTH_SOCK']).expand_path if ENV['SSH_AUTH_SOCK'] && File.exist?(ENV['SSH_AUTH_SOCK'])
163
161
 
164
- vendor_commands = [
162
+ before_berks_vendor = [
165
163
  'mkdir -p ~/.ssh',
166
164
  'echo "Host *" >> ~/.ssh/config',
167
165
  'echo " StrictHostKeyChecking no" >> ~/.ssh/config',
168
- 'if [ ! -f Berksfile.lock ] ; then echo "Berksfile.lock not found" 1>&2 ; exit 1 ; fi',
169
- 'cp -a Berksfile.lock /tmp/Berksfile.lock.orig',
170
- "/.dapp/deps/chefdk/bin/berks vendor /tmp/vendored_cookbooks",
171
- 'export LOCKDIFF=$(diff -u0 Berksfile.lock /tmp/Berksfile.lock.orig)',
172
- ['if [ "$LOCKDIFF" != "" ] ; then ',
173
- 'cp -a /tmp/Berksfile.lock.orig Berksfile.lock ; ',
174
- 'echo -e "Bad Berksfile.lock\n$LOCKDIFF" 1>&2 ; exit 1 ; fi'].join,
166
+ ('if [ ! -f Berksfile.lock ] ; then echo "Berksfile.lock not found" 2>&2 ; exit 1 ; fi' unless chef_cookbooks_stage),
167
+ 'if [ -f Berksfile.lock ] ; then cp -a Berksfile.lock /tmp/Berksfile.lock.orig ; fi'
168
+ ]
169
+
170
+ after_berks_vendor = []
171
+ if chef_cookbooks_stage
172
+ after_berks_vendor.concat [
173
+ 'cp -a /tmp/Berksfile.lock.orig Berksfile.lock'
174
+ ]
175
+ else
176
+ after_berks_vendor.concat [
177
+ 'export LOCKDIFF=$(diff -u0 Berksfile.lock /tmp/Berksfile.lock.orig)',
178
+ ['if [ "$LOCKDIFF" != "" ] ; then ',
179
+ 'cp -a /tmp/Berksfile.lock.orig Berksfile.lock ; ',
180
+ 'echo -e "Bad Berksfile.lock\n$LOCKDIFF" 1>&2 ; exit 1 ; fi'].join
181
+ ]
182
+ end
183
+
184
+ move_cookbooks = [
175
185
  ["find /tmp/vendored_cookbooks -type d -exec bash -ec '",
176
186
  "install -o #{Process.uid} -g #{Process.gid} --mode $(stat -c %a {}) -d ",
177
- "#{_cookbooks_vendor_path}/$(echo {} | sed -e \"s/^\\/tmp\\/vendored_cookbooks//\")' \\;"].join,
187
+ "#{dest_path}/$(echo {} | sed -e \"s/^\\/tmp\\/vendored_cookbooks//\")' \\;"].join,
178
188
  ["find /tmp/vendored_cookbooks -type f -exec bash -ec '",
179
189
  "install -o #{Process.uid} -g #{Process.gid} --mode $(stat -c %a {}) {} ",
180
- "#{_cookbooks_vendor_path}/$(echo {} | sed -e \"s/\\/tmp\\/vendored_cookbooks//\")' \\;"].join
190
+ "#{dest_path}/$(echo {} | sed -e \"s/\\/tmp\\/vendored_cookbooks//\")' \\;"].join
191
+ ]
192
+
193
+ vendor_commands = [
194
+ *before_berks_vendor.compact,
195
+ "/.dapp/deps/chefdk/bin/berks vendor /tmp/vendored_cookbooks",
196
+ *after_berks_vendor.compact,
197
+ *move_cookbooks.compact
181
198
  ]
182
199
 
183
200
  application.shellout!(
184
201
  ['docker run --rm',
185
202
  ("--volume #{ssh_auth_socket_path}:#{ssh_auth_socket_path}" if ssh_auth_socket_path),
186
- "--volume #{_cookbooks_vendor_path.tap(&:mkpath)}:#{_cookbooks_vendor_path}",
203
+ "--volume #{dest_path.tap(&:mkpath)}:#{dest_path}",
187
204
  *berksfile.local_cookbooks
188
205
  .values
189
206
  .map { |cookbook| "--volume #{cookbook[:path]}:#{cookbook[:path]}" },
190
207
  "--volumes-from #{volumes_from}",
191
208
  "--workdir #{berksfile_path.parent}",
192
209
  ("--env SSH_AUTH_SOCK=#{ssh_auth_socket_path}" if ssh_auth_socket_path),
210
+ ('--env DAPP_CHEF_COOKBOOKS_VENDORING=1' if chef_cookbooks_stage),
193
211
  "dappdeps/berksdeps:0.1.0 bash -ec '#{application.shellout_pack(vendor_commands.join(' && '))}'"].compact.join(' '),
194
212
  log_verbose: application.log_verbose?
195
213
  )
@@ -197,13 +215,18 @@ module Dapp
197
215
  end
198
216
  # rubocop:enable Metrics/MethodLength, Metrics/AbcSize
199
217
 
200
- def _cookbooks_vendor_path
201
- application.tmp_path(application.config._name, "cookbooks.#{cookbooks_checksum}")
218
+ def _cookbooks_vendor_path(chef_cookbooks_stage: false)
219
+ application.tmp_path(
220
+ application.config._name,
221
+ ['cookbooks',
222
+ chef_cookbooks_stage ? 'chef_cookbooks_stage' : nil,
223
+ cookbooks_checksum].compact.join('.')
224
+ )
202
225
  end
203
226
 
204
- def cookbooks_vendor_path(*path)
205
- _cookbooks_vendor_path.tap do |cookbooks_path|
206
- install_cookbooks unless cookbooks_path.exist?
227
+ def cookbooks_vendor_path(*path, chef_cookbooks_stage: false)
228
+ _cookbooks_vendor_path(chef_cookbooks_stage: chef_cookbooks_stage).tap do |cookbooks_path|
229
+ install_cookbooks(cookbooks_path, chef_cookbooks_stage: chef_cookbooks_stage) unless cookbooks_path.exist?
207
230
  end.join(*path)
208
231
  end
209
232
 
@@ -9,8 +9,7 @@ module Dapp
9
9
  end
10
10
  define_method("#{stage}?") { !stage_empty?(stage) }
11
11
  define_method("#{stage}") do |image|
12
- image.add_command("export DAPP_BUILD_STAGE=#{stage}",
13
- *stage_commands(stage)) unless stage_empty?(stage)
12
+ image.add_command(*stage_commands(stage)) unless stage_empty?(stage)
14
13
  end
15
14
  end
16
15
 
@@ -1,5 +1,5 @@
1
1
  # Version
2
2
  module Dapp
3
- VERSION = '0.5.12'.freeze
3
+ VERSION = '0.5.13'.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.12
4
+ version: 0.5.13
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-09-06 00:00:00.000000000 Z
11
+ date: 2016-09-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mixlib-shellout