kitchen-habitat 0.5.3 → 0.6.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: a0b84dae0b861602744e7e767c3c91d9dd4a02b9
4
- data.tar.gz: c0eb37401e35966c040617ea2e3e02bfaf31a61b
3
+ metadata.gz: 2bae74a60049f0b9a93da4a8a4a94a0b22d96204
4
+ data.tar.gz: f03ca264521bdbddb44d70c221790830c562c535
5
5
  SHA512:
6
- metadata.gz: 7d34284386219c9864287f75698e808c0c748497261172d53f69eec9e16a895e8e24fedd4f8a3b5a2d2e04b9af51349346e671a14d27d1f173071516dfefc1de
7
- data.tar.gz: cc66535efabfe305037359c82ba304600934768a41d0ef0430a360105843faf5fbaed57ac4904ca4a969fec57077003dd6b0b671d5cf279a2f351be7ce8024cb
6
+ metadata.gz: 8ca4742c8f967de7dd00b184b2aba4bd23e50149049151e4952ca5a9dc2e6cbd70b0ae49def3c1e5e62e166c6ff08a3cdfa827ff78641b3d5a60d5a43259ecb1
7
+ data.tar.gz: 66bee9a35a38cb0d6465ca94c367be281700f408af40be5e2a7591b578d8caf25c0686d8a10cb213ee77bc30519c17b3b6dba8f7bd819170a4647063116d67a3
data/README.md CHANGED
@@ -7,7 +7,7 @@ A Test Kitchen Provisioner for [Habitat](https://habitat.sh)
7
7
 
8
8
 
9
9
  ## Installation & Setup
10
- You'll need the test-kitchen & kitchen-habitat gems installed in your system, along with kitchen-vagrant or some other suitable driver for test-kitchen.
10
+ You'll need the test-kitchen & kitchen-habitat gems installed in your system, along with kitchen-vagrant or some other suitable driver for test-kitchen.
11
11
 
12
12
  ## Configuration Settings
13
13
 
@@ -34,7 +34,7 @@ You'll need the test-kitchen & kitchen-habitat gems installed in your system, al
34
34
  * `hab_sup_artifact_name`
35
35
  * Artifact package name for a custom supervisor to run
36
36
  * Used to upload and test a local supervisor.
37
- * Package should be located in the `results_directory`
37
+ * Package should be located in the `results_directory`
38
38
  * Defaults to `nil
39
39
  * `hab_sup_listen_http`
40
40
  * Port for the supervisor's sidecar to listen on.
@@ -83,9 +83,13 @@ You'll need the test-kitchen & kitchen-habitat gems installed in your system, al
83
83
  * `user_toml_name`
84
84
  * Name of the file to be used as the user.toml for the service under test.
85
85
  * Defaults to `user.toml`
86
+ * `install_latest_artifact`
87
+ * Choose to install latest artifact.
88
+ * Must specify `artifact_name` or `package_origin` and `package_name`
89
+ * `package_version` and `package_release` will be ignored
90
+ * Defaults to `false`
86
91
 
87
-
88
- ## Example
92
+ ## Example
89
93
 
90
94
  ```yaml
91
95
  driver:
@@ -1,5 +1,5 @@
1
1
  module Kitchen
2
2
  module Habitat
3
- VERSION = "0.5.3".freeze
3
+ VERSION = "0.6.0".freeze
4
4
  end
5
5
  end
@@ -31,11 +31,10 @@ module Kitchen
31
31
  default_config :hab_sup_group, nil
32
32
 
33
33
  # hab-sup service options
34
+ default_config :install_latest_artifact, false
34
35
  default_config :artifact_name, nil
35
36
  default_config :package_origin, "core"
36
- default_config :package_name do |provisioner|
37
- provisioner.instance.suite.name
38
- end
37
+ default_config :package_name
39
38
  default_config :package_version, nil
40
39
  default_config :package_release, nil
41
40
  default_config :service_topology, nil
@@ -51,10 +50,9 @@ module Kitchen
51
50
  default_config :use_screen, false
52
51
 
53
52
  def finalize_config!(instance)
54
-
55
53
  # Check to see if a package ident was specified for package name and be helpful
56
- unless (config[:package_name] =~ /\//).nil?
57
- config[:package_origin], config[:package_name], config[:package_version], config[:package_release] = config[:package_name].split('/')
54
+ unless config[:package_name].nil? || (config[:package_name] =~ /\//).nil?
55
+ config[:package_origin], config[:package_name], config[:package_version], config[:package_release] = config[:package_name].split("/")
58
56
  end
59
57
 
60
58
  unless config[:hab_sup_artifact_name].nil?
@@ -76,7 +74,7 @@ module Kitchen
76
74
  end
77
75
 
78
76
  def install_command
79
- raise 'Need to fill in some implementation here.' if instance.platform == 'windows'
77
+ raise "Need to fill in some implementation here." if instance.platform == "windows"
80
78
  wrap_shell_code <<-BASH
81
79
  #{export_hab_origin}
82
80
  if command -v hab >/dev/null 2>&1
@@ -91,8 +89,9 @@ module Kitchen
91
89
  def init_command
92
90
  wrap_shell_code <<-EOH
93
91
  id -u hab >/dev/null 2>&1 || sudo useradd hab >/dev/null 2>&1
92
+ rm -rf /tmp/kitchen
94
93
  mkdir -p /tmp/kitchen/results
95
- mkdir -p /tmp/kitchen/config
94
+ #{'mkdir -p /tmp/kitchen/config' unless config[:override_package_config]}
96
95
  EOH
97
96
  end
98
97
 
@@ -100,6 +99,7 @@ module Kitchen
100
99
  super
101
100
  copy_results_to_sandbox
102
101
  copy_user_toml_to_sandbox
102
+ copy_package_config_from_override_to_sandbox
103
103
  end
104
104
 
105
105
  def prepare_command
@@ -179,12 +179,22 @@ module Kitchen
179
179
  end
180
180
  end
181
181
 
182
+ def copy_package_config_from_override_to_sandbox
183
+ return if config[:config_directory].nil?
184
+ return unless config[:override_package_config]
185
+ local_config_dir = File.join(config[:kitchen_root], config[:config_directory])
186
+ return unless Dir.exist?(local_config_dir)
187
+
188
+ sandbox_config_dir = File.join(sandbox_path, "config")
189
+ FileUtils.copy_entry(local_config_dir, sandbox_config_dir)
190
+ end
191
+
182
192
  def copy_results_to_sandbox
183
193
  results_dir = resolve_results_directory
184
194
  return if results_dir.nil?
185
195
  FileUtils.mkdir_p(File.join(sandbox_path, "results"))
186
- FileUtils.cp_r(
187
- results_dir,
196
+ FileUtils.cp(
197
+ File.join(results_dir, config[:install_latest_artifact] ? latest_artifact_name : config[:artifact_name]),
188
198
  File.join(sandbox_path, "results"),
189
199
  preserve: true
190
200
  )
@@ -207,8 +217,28 @@ module Kitchen
207
217
  end
208
218
 
209
219
  def install_service_package
210
- return if config[:artifact_name].nil?
211
- "sudo hab pkg install #{File.join(File.join(config[:root_path], 'results'), config[:artifact_name])}"
220
+ return unless config[:install_latest_artifact] || !config[:artifact_name].nil?
221
+
222
+ artifact_name = ""
223
+ if config[:install_latest_artifact]
224
+ artifact_name = latest_artifact_name
225
+ elsif !config[:install_latest_artifact] && !config[:artifact_name].nil?
226
+ artifact_name = config[:artifact_name]
227
+ else
228
+ return
229
+ end
230
+
231
+ artifact_path = File.join(File.join(config[:root_path], "results"), artifact_name)
232
+ "sudo hab pkg install #{artifact_path}"
233
+ end
234
+
235
+ def latest_artifact_name
236
+ results_dir = resolve_results_directory
237
+ return if results_dir.nil?
238
+
239
+ artifact_path = Dir.glob(File.join(results_dir, "#{config[:package_origin]}-#{config[:package_name]}-*.hart")).max_by { |f| File.mtime(f) }
240
+
241
+ File.basename(artifact_path)
212
242
  end
213
243
 
214
244
  def copy_user_toml_to_service_directory
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.5.3
4
+ version: 0.6.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-03-23 00:00:00.000000000 Z
11
+ date: 2017-03-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: test-kitchen