kitchen-habitat 0.7.0 → 0.8.0

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: 24e28546bbe3eb127598d6f93d8c283770a2ceb6
4
- data.tar.gz: fb278ba7a725265367e588ff3e522ac17016c3c5
3
+ metadata.gz: f200f91d0c7bde6766da07d73786157e6e8411a7
4
+ data.tar.gz: 480d7f26a3eaa96a26ef3bc3cc8d5ef4024f2e04
5
5
  SHA512:
6
- metadata.gz: 54e12cd0a926b6e7c978134000db2f33f8b5e15284f61fbec38fe6a71d7bc7549a9e5027ae20aba70b450407ef1e0e35a3a25642f2ea4f20cf46ec107c70c88b
7
- data.tar.gz: 1cd47e9aee9bdee8179cae232627d3402787a7b2dc29c67692cb9f0358dfd882471bbd35888b33f3c22a47eac040a4b6ecd2c8e95518feeffd521eb48e6fff5d
6
+ metadata.gz: 6a51d73ed9e043222f030b3816bd7284cc5a64a43d3ac208c4ad81c8dadd8ca64fc64095c41b673263747f435b17331e446691349678c0f1442eaefcf40827cc
7
+ data.tar.gz: d86d2b14dff2b18685b59e2fad715ce0968f9736fbb1f4b978a0770d506f2d82e82f1587d4993950f8b4016225969e1bca6a3b3b580f2ae58bb6232b252ccc89
@@ -1,5 +1,5 @@
1
1
  module Kitchen
2
2
  module Habitat
3
- VERSION = "0.7.0".freeze
3
+ VERSION = "0.8.0".freeze
4
4
  end
5
5
  end
@@ -82,14 +82,14 @@ module Kitchen
82
82
  then
83
83
  echo "Habitat CLI already installed."
84
84
  else
85
- curl 'https://raw.githubusercontent.com/habitat-sh/habitat/master/components/hab/install.sh' | sudo bash
85
+ curl 'https://raw.githubusercontent.com/habitat-sh/habitat/master/components/hab/install.sh' | sudo -E bash
86
86
  fi
87
87
  BASH
88
88
  end
89
89
 
90
90
  def init_command
91
91
  wrap_shell_code <<-EOH
92
- id -u hab >/dev/null 2>&1 || sudo useradd hab >/dev/null 2>&1
92
+ id -u hab >/dev/null 2>&1 || sudo -E useradd hab >/dev/null 2>&1
93
93
  rm -rf /tmp/kitchen
94
94
  mkdir -p /tmp/kitchen/results
95
95
  #{'mkdir -p /tmp/kitchen/config' unless config[:override_package_config]}
@@ -131,12 +131,12 @@ module Kitchen
131
131
  def clean_up_screen_sessions
132
132
  return unless config[:use_screen]
133
133
  <<-CLEAN
134
- if sudo screen -ls | grep -q #{clean_package_name}
134
+ if sudo -E screen -ls | grep -q #{clean_package_name}
135
135
  then
136
136
  echo "Killing previous supervisor session."
137
- sudo screen -S \"#{clean_package_name}\" -X quit > /dev/null
137
+ sudo -E screen -S \"#{clean_package_name}\" -X quit > /dev/null
138
138
  echo "Removing dead session."
139
- sudo screen -wipe > /dev/null
139
+ sudo -E screen -wipe > /dev/null
140
140
  fi
141
141
  CLEAN
142
142
  end
@@ -144,29 +144,31 @@ module Kitchen
144
144
  def clean_up_previous_supervisor
145
145
  return if config[:use_screen]
146
146
  <<-EOH
147
- [ -f ./run.pid ] && echo "Removing previous supervisor. "
148
- [ -f ./run.pid ] && sudo kill $(cat run.pid)
147
+ [ -f ./run.pid ] && echo "Removing previous supervisor and unloading package. "
148
+ [ -f ./run.pid ] && sudo -E hab svc unload #{package_ident}
149
+ [ -f ./run.pid ] && sleep 5
150
+ [ -f ./run.pid ] && sudo -E kill $(cat run.pid)
149
151
  [ -f ./run.pid ] && sleep 5
150
152
  EOH
151
153
  end
152
154
 
153
155
  def run_package_in_background
154
156
  if config[:use_screen]
155
- "sudo screen -mdS \"#{clean_package_name}\" hab start #{package_ident} #{supervisor_options}"
157
+ "sudo -E screen -mdS \"#{clean_package_name}\" hab start #{package_ident} #{supervisor_options}"
156
158
  else
157
159
  <<-RUN
158
160
  [ -f ./run.pid ] && rm -f run.pid
159
161
  [ -f ./nohup.out ] && rm -f nohup.out
160
- nohup sudo hab sup run & echo $! > run.pid
162
+ nohup sudo -E hab sup run #{supervisor_options} & echo $! > run.pid
161
163
 
162
- until hab svc status
164
+ until sudo -E hab svc status
163
165
  do
164
166
  sleep 1
165
167
  done
166
168
 
167
- sudo hab start #{package_ident} #{supervisor_options}
168
-
169
- until hab svc status | grep #{package_ident}
169
+ sudo -E hab svc load #{package_ident} #{service_options}
170
+
171
+ until sudo -E hab svc status | grep #{package_ident}
170
172
  do
171
173
  sleep 1
172
174
  done
@@ -241,9 +243,14 @@ module Kitchen
241
243
  else
242
244
  return
243
245
  end
246
+ parsed_name = artifact_name.split("-")
247
+ config[:package_origin] = parsed_name[0]
248
+ config[:package_name] = parsed_name[1]
249
+ config[:package_version] = parsed_name[2]
250
+ config[:package_release] = parsed_name[3]
244
251
 
245
252
  artifact_path = File.join(File.join(config[:root_path], "results"), artifact_name)
246
- "sudo hab pkg install #{artifact_path}"
253
+ "sudo -E hab pkg install #{artifact_path}"
247
254
  end
248
255
 
249
256
  def latest_artifact_name
@@ -252,21 +259,22 @@ module Kitchen
252
259
 
253
260
  artifact_path = Dir.glob(File.join(results_dir, "#{config[:package_origin]}-#{config[:package_name]}-*.hart")).max_by { |f| File.mtime(f) }
254
261
 
262
+
255
263
  File.basename(artifact_path)
256
264
  end
257
265
 
258
266
  def copy_user_toml_to_service_directory
259
267
  return unless !config[:config_directory].nil? && File.exist?(full_user_toml_path)
260
268
  <<-EOH
261
- sudo mkdir -p /hab/svc/#{config[:package_name]}
262
- sudo cp #{File.join(File.join(config[:root_path], 'config'), 'user.toml')} /hab/svc/#{config[:package_name]}/user.toml
269
+ sudo -E mkdir -p /hab/svc/#{config[:package_name]}
270
+ sudo -E cp #{File.join(File.join(config[:root_path], 'config'), 'user.toml')} /hab/svc/#{config[:package_name]}/user.toml
263
271
  EOH
264
272
  end
265
273
 
266
274
  def remove_previous_user_toml
267
275
  <<-REMOVE
268
276
  if [ -d "/hab/svc/#{config[:package_name]}" ]; then
269
- sudo find /hab/svc/#{config[:package_name]} -name user.toml -delete
277
+ sudo -E find /hab/svc/#{config[:package_name]} -name user.toml -delete
270
278
  fi
271
279
  REMOVE
272
280
  end
@@ -277,11 +285,11 @@ module Kitchen
277
285
  end
278
286
 
279
287
  def install_supervisor_command
280
- "sudo hab pkg install #{hab_sup_ident}"
288
+ "sudo -E hab pkg install #{hab_sup_ident}"
281
289
  end
282
290
 
283
291
  def binlink_supervisor_command
284
- "sudo hab pkg binlink #{hab_sup_ident} hab-sup"
292
+ "sudo -E hab pkg binlink #{hab_sup_ident} hab-sup"
285
293
  end
286
294
 
287
295
  def artifact_name_to_package_ident_regex
@@ -301,7 +309,7 @@ module Kitchen
301
309
  "#{config[:package_name]}/" \
302
310
  "#{config[:package_version]}/" \
303
311
  "#{config[:package_release]}".chomp("/").chomp("/")
304
- @pkg_ident ||= ident
312
+ @pkg_ident = ident
305
313
  end
306
314
 
307
315
  def clean_package_name
@@ -321,6 +329,17 @@ module Kitchen
321
329
 
322
330
  options
323
331
  end
332
+
333
+ def service_options
334
+ options = ""
335
+ options += config[:hab_sup_bind].map { |b| " --bind #{b}" }.join(" ") if config[:hab_sup_bind].any?
336
+ options += " --group #{config[:hab_sup_group]}" unless config[:hab_sup_group].nil?
337
+ options += " --topology #{config[:service_topology]}" unless config[:service_topology].nil?
338
+ options += " --strategy #{config[:service_update_strategy]}" unless config[:service_update_strategy].nil?
339
+ options += " --channel #{config[:channel]}" unless config[:channel].nil?
340
+
341
+ options
342
+ end
324
343
  end
325
344
  end
326
345
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kitchen-habitat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steven Murawski
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-10 00:00:00.000000000 Z
11
+ date: 2018-06-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: test-kitchen
@@ -133,7 +133,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
133
133
  version: '0'
134
134
  requirements: []
135
135
  rubyforge_project: "[none]"
136
- rubygems_version: 2.6.11
136
+ rubygems_version: 2.5.2.1
137
137
  signing_key:
138
138
  specification_version: 4
139
139
  summary: Habitat provisioner for test-kitchen