kitchen-habitat 0.11.2 → 0.12.1

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
  SHA256:
3
- metadata.gz: 2f0dff2a5f968980869f7997e70646b270bb317dd75fb7728826f0a71be9d94b
4
- data.tar.gz: 97695db2914a4b22dcc172323fa2d73679ac1e629d226868191f0889bf3f7642
3
+ metadata.gz: 307c3545cbd9d4738778e6d14c02e75929f52c805a7b3cea679af0a185748bb1
4
+ data.tar.gz: 6a61cb7f38f2074f25cc9b9ce429da766e27b120e1e0c2dcd19dc53e1f9db884
5
5
  SHA512:
6
- metadata.gz: 3f2aa27e5149b48e593eee823b9bc3743e463733f2a22dfd5781ee6bf98becb769dcf46aa00bc177e6ac4a119c8e120120f674cbe103ae0fb8bcb71159817a6a
7
- data.tar.gz: e226dca41ef127b60d02430b571189c845d642a747fe207a6e9fbc83b78b2c4dc1213111a6924bb0595e7f69ab72b27ed013d39385322cf477c2d3b83e598931
6
+ metadata.gz: ee379fa70d6808368dd5d63fe8a5ac0cf172e2524a876a9ab535b32cb98cee7cd59f6fd42252df02cbcf70fa48eff7c7c3ce7d06ceedcc9294f2faa60c578ec9
7
+ data.tar.gz: d856038e6443e73343fcba7fab4fee84bfffd318feb5b33285421cb7e3ac40db1e1861be1246ccfbf90683e54700c7f6a935bdee3890285ff3404d32dbc3c036
data/README.md CHANGED
@@ -1,12 +1,14 @@
1
1
  [![Gem Version](https://badge.fury.io/rb/kitchen-habitat.svg)](http://badge.fury.io/rb/kitchen-habitat)
2
+ [![Build Status](https://github.com/test-kitchen/kitchen-habitat/workflows/CI/badge.svg?branch=master)](https://github.com/test-kitchen/kitchen-habitat/actions?query=workflow%3ACI+branch%3Amaster)
2
3
 
3
4
  # kitchen-habitat
5
+
4
6
  A Test Kitchen Provisioner for [Habitat](https://habitat.sh)
5
7
 
6
8
  ## Requirements
7
9
 
8
-
9
10
  ## Installation & Setup
11
+
10
12
  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
13
 
12
14
  ## Configuration Settings
@@ -68,7 +70,7 @@ You'll need the test-kitchen & kitchen-habitat gems installed in your system, al
68
70
  * Defaults to `nil`
69
71
  * `results_directory`
70
72
  * Directory (relative to the location of the .kitchen.yml) containing package artifacts (harts) to copy to the remote system
71
- * Defaults to checking the local directory for a `results` directory, then its parent (`../results`) and grandparent (`../../results`), which should accomodate most studio layouts.
73
+ * Defaults to checking the local directory for a `results` directory, then its parent (`../results`) and grandparent (`../../results`), which should accommodate most studio layouts.
72
74
  * `package_origin`
73
75
  * Origin for the package to run.
74
76
  * Defaults to `core`, or, if `artifact_name` is supplied, the `package_origin` will be parsed from the filename of the hart file.
@@ -101,6 +103,26 @@ You'll need the test-kitchen & kitchen-habitat gems installed in your system, al
101
103
  * `package_version` and `package_release` will be ignored
102
104
  * Defaults to `false`
103
105
 
106
+ ### EAS Application Dashboard Settings
107
+
108
+ * `event_stream_application`
109
+ * The name of your application.
110
+ * Defaults to `nil`
111
+ * `event_stream_environment`
112
+ * The application environment for this supervisor.
113
+ * Defaults to `nil`
114
+ * `event_stream_site`
115
+ * Describes the physical (for example, datacenter) or cloud-specific (for example, the AWS region) location where your services are deployed.
116
+ * Defaults to `nil`
117
+ * `event_stream_url`
118
+ * The Chef Automate URL with port 4222 specified.
119
+ * Defaults to `nil`
120
+ * `event_stream_token`
121
+ * Chef Automate Token
122
+ * Defaults to `nil`
123
+
124
+ > NOTE: All 5 EAS settings are required for it to report to Automate.
125
+
104
126
  ## Examples
105
127
 
106
128
  Run the core-redis package
@@ -123,7 +145,7 @@ suites:
123
145
  - name: default
124
146
  ```
125
147
 
126
- Two node: elasticsearch and kibana
148
+ Two node: elasticsearch and kibana
127
149
 
128
150
  ```yaml
129
151
  driver:
@@ -155,5 +177,116 @@ suites:
155
177
  - elasticsearch:elasticsearch.default
156
178
  driver:
157
179
  instance_name: kibana
158
- links: elastic:elastic
180
+ links: elastic:elastic
181
+ ```
182
+
183
+ EAS Application Dashboard Example
184
+
185
+ ``` yaml
186
+ ---
187
+ driver:
188
+ name: azurerm
189
+
190
+ driver_config:
191
+ subscription_id: <%= ENV['subscription_id'] %>
192
+ location: <%= ENV['region'] %>
193
+ machine_size: "Standard_DS2_v2"
194
+
195
+ verifier:
196
+ name: inspec
197
+
198
+ provisioner:
199
+ name: habitat
200
+ hab_version: 'latest'
201
+ hab_license: accept
202
+ event_stream_application: Effortless
203
+ event_stream_environment: stable
204
+ event_stream_site: <%= ENV['region'] %>
205
+ event_stream_url: automate.example.com:4222
206
+ event_stream_token: <%= ENV['automate_token'] %>
207
+
208
+ platforms:
209
+ - name: windows
210
+ driver:
211
+ image_urn: MicrosoftWindowsServer:WindowsServer:2019-Datacenter:latest
212
+ vm_name: windows
213
+ provisioner:
214
+ package_origin: <%= ENV['package_orgin'] %>
215
+ package_name: <%= ENV['package_name'] %>
216
+
217
+ suites:
218
+ - name: default
219
+ verifier:
220
+ inspec_tests:
221
+ - tests
222
+ ```
223
+
224
+ Latest Artifact example
225
+
226
+ > This example assumes you've already done a build via hab studio.
227
+
228
+ ```yaml
229
+ driver:
230
+ name: vagrant
231
+ customize:
232
+ memory: 2048
233
+
234
+ verifier:
235
+ name: inspec
236
+
237
+ provisioner:
238
+ name: habitat
239
+ hab_version: 'latest'
240
+ hab_license: accept
241
+
242
+ platforms:
243
+ - name: wildfly-local
244
+ driver:
245
+ box: bento/ubuntu-16.04
246
+ provisioner:
247
+ package_origin: jmassardo
248
+ package_name: wildfly
249
+ results_directory: results
250
+ install_latest_artifact: true
251
+
252
+ suites:
253
+ - name: default
254
+ verifier:
255
+ inspec_tests:
256
+ - tests
257
+ ```
258
+
259
+ Apply `user.toml` Example
260
+
261
+ > This example assumes that you have a `/configs/user.toml` in your project directory.
262
+
263
+ ```yaml
264
+ driver:
265
+ name: vagrant
266
+ customize:
267
+ memory: 2048
268
+
269
+ verifier:
270
+ name: inspec
271
+
272
+ provisioner:
273
+ name: habitat
274
+ hab_version: 'latest'
275
+ hab_license: accept
276
+
277
+ platforms:
278
+ - name: wildfly
279
+ driver:
280
+ box: bento/ubuntu-16.04
281
+ provisioner:
282
+ package_origin: jmassardo
283
+ package_name: wildfly
284
+ channel: unstable
285
+ config_directory: configs
286
+
287
+ suites:
288
+ - name: default
289
+ verifier:
290
+ inspec_tests:
291
+ - tests
159
292
  ```
@@ -1,5 +1,5 @@
1
1
  module Kitchen
2
2
  module Habitat
3
- VERSION = "0.11.2".freeze
3
+ VERSION = "0.12.1".freeze
4
4
  end
5
5
  end
@@ -19,6 +19,7 @@ module Kitchen
19
19
  default_config :depot_url, nil
20
20
  default_config :hab_license, nil
21
21
  default_config :hab_version, "latest"
22
+ default_config :hab_channel, "stable"
22
23
  default_config :hab_sup_origin, "core"
23
24
  default_config :hab_sup_name, "hab-sup"
24
25
  default_config :hab_sup_version, nil
@@ -44,6 +45,7 @@ module Kitchen
44
45
  default_config :service_topology, nil
45
46
  default_config :service_update_strategy, nil
46
47
  default_config :channel, "stable"
48
+ default_config :service_load_timeout, 300
47
49
 
48
50
  # local stuffs to copy
49
51
  default_config :results_directory, nil
@@ -51,8 +53,12 @@ module Kitchen
51
53
  default_config :user_toml_name, "user.toml"
52
54
  default_config :override_package_config, false
53
55
 
54
- # experimental
55
- default_config :use_screen, false
56
+ # event stream options
57
+ default_config :event_stream_application, nil
58
+ default_config :event_stream_environment, nil
59
+ default_config :event_stream_site, nil
60
+ default_config :event_stream_url, nil
61
+ default_config :event_stream_token, nil
56
62
 
57
63
  def finalize_config!(instance)
58
64
  # Check to see if a package ident was specified for package name and be helpful
@@ -79,30 +85,19 @@ module Kitchen
79
85
  end
80
86
 
81
87
  def install_command
82
- raise "Need to fill in some implementation here." if instance.platform == "windows"
83
-
84
- version = " -v #{config[:hab_version]}" unless config[:hab_version].eql?("latest")
85
-
86
- wrap_shell_code <<-BASH
87
- #{export_hab_bldr_url}
88
- #{export_hab_license}
89
- if command -v hab >/dev/null 2>&1
90
- then
91
- echo "Habitat CLI already installed."
88
+ if windows_os?
89
+ wrap_shell_code(windows_install_cmd)
92
90
  else
93
- curl -o /tmp/install.sh 'https://raw.githubusercontent.com/habitat-sh/habitat/master/components/hab/install.sh'
94
- sudo -E bash /tmp/install.sh#{version}
95
- fi
96
- BASH
91
+ wrap_shell_code(linux_install_cmd)
92
+ end
97
93
  end
98
94
 
99
95
  def init_command
100
- wrap_shell_code <<-EOH
101
- id -u hab >/dev/null 2>&1 || sudo -E useradd hab >/dev/null 2>&1
102
- rm -rf /tmp/kitchen
103
- mkdir -p /tmp/kitchen/results
104
- #{"mkdir -p /tmp/kitchen/config" unless config[:override_package_config]}
105
- EOH
96
+ if windows_os?
97
+ wrap_shell_code(windows_install_service)
98
+ else
99
+ wrap_shell_code(linux_install_service)
100
+ end
106
101
  end
107
102
 
108
103
  def create_sandbox
@@ -113,104 +108,152 @@ module Kitchen
113
108
  end
114
109
 
115
110
  def prepare_command
116
- wrap_shell_code <<-EOH
117
- #{export_hab_bldr_url}
118
- #{export_hab_license}
119
- #{install_supervisor_command}
120
- #{binlink_supervisor_command}
121
- #{install_service_package}
111
+ debug("Prepare command is running")
112
+ wrap_shell_code <<~PREPARE
122
113
  #{remove_previous_user_toml}
123
114
  #{copy_user_toml_to_service_directory}
124
- EOH
115
+ PREPARE
125
116
  end
126
117
 
127
118
  def run_command
128
- run = <<-RUN
129
- #{export_hab_bldr_url}
130
- #{export_hab_license}
131
- #{clean_up_screen_sessions}
132
- #{clean_up_previous_supervisor}
133
- echo "Running #{package_ident}."
134
- #{run_package_in_background}
135
- RUN
136
-
137
- wrap_shell_code run
119
+ # This little bit figures out what package should be loaded
120
+ if config[:install_latest_artifact] || !config[:artifact_name].nil?
121
+ # TODO: throw error and bail if there's no artifacts in the results directory
122
+ target_pkg = get_artifact_name
123
+ target_ident = "#{config[:package_origin]}/#{config[:package_name]}"
124
+ # TODO: This is a workaround for windows. The hart file sometimes gets copied to the
125
+ # %TEMP%\kitchen instead of %TEMP%\kitchen\results.
126
+ if windows_os?
127
+ target_pkg = target_pkg.gsub("results/", "") unless File.exist?(target_pkg)
128
+ end
129
+ else
130
+ target_pkg = package_ident
131
+ target_ident = package_ident
132
+ end
133
+
134
+ if windows_os?
135
+ wrap_shell_code <<~PWSH
136
+ if (!($env:Path | Select-String "Habitat")) {
137
+ $env:Path += ";C:\\ProgramData\\Habitat"
138
+ }
139
+ hab pkg install #{target_pkg} --channel #{config[:channel]} --force
140
+ if (Test-Path -Path "$(hab pkg path #{target_ident})\\hooks\\run") {
141
+ hab svc load #{target_ident} #{service_options} --force
142
+ $timer = 0
143
+ Do {
144
+ if ($timer -gt #{config[:service_load_timeout]}){exit 1}
145
+ Start-Sleep -Seconds 1
146
+ $timer++
147
+ } until( hab svc status | out-string -stream | select-string #{target_ident})
148
+ }
149
+ PWSH
150
+ else
151
+ wrap_shell_code <<~BASH
152
+ until sudo -E hab svc status > /dev/null
153
+ do
154
+ echo "Waiting 5 seconds for supervisor to finish loading"
155
+ sleep 5
156
+ done
157
+ sudo hab pkg install #{target_pkg} --channel #{config[:channel]} --force
158
+ if [ -f $(sudo hab pkg path #{target_ident})/hooks/run ]
159
+ then
160
+ sudo -E hab svc load #{target_ident} #{service_options} --force
161
+ timer=0
162
+ until sudo -E hab svc status | grep #{target_ident}
163
+ do
164
+ if [$timer -gt #{config[:service_load_timeout]}]; then exit 1; fi
165
+ sleep 1
166
+ $timer++
167
+ done
168
+ fi
169
+ BASH
170
+ end
138
171
  end
139
172
 
140
173
  private
141
174
 
142
- def clean_up_screen_sessions
143
- return unless config[:use_screen]
175
+ def windows_install_cmd
176
+ <<~PWSH
177
+ if ((Get-Command hab -ErrorAction Ignore).Path) {
178
+ Write-Output "Habitat CLI already installed."
179
+ } else {
180
+ Set-ExecutionPolicy Bypass -Scope Process -Force
181
+ $InstallScript = ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/habitat-sh/habitat/master/components/hab/install.ps1'))
182
+ Invoke-Command -ScriptBlock ([scriptblock]::Create($InstallScript)) -ArgumentList #{config[:hab_channel]}, #{config[:hab_version]}
183
+ }
184
+ PWSH
185
+ end
144
186
 
145
- <<-CLEAN
146
- if sudo -E screen -ls | grep -q #{clean_package_name}
187
+ def linux_install_cmd
188
+ version = " -v #{config[:hab_version]}" unless config[:hab_version].eql?("latest")
189
+ <<~BASH
190
+ if command -v hab >/dev/null 2>&1
147
191
  then
148
- echo "Killing previous supervisor session."
149
- sudo -E screen -S \"#{clean_package_name}\" -X quit > /dev/null
150
- echo "Removing dead session."
151
- sudo -E screen -wipe > /dev/null
152
- fi
153
- CLEAN
192
+ echo "Habitat CLI already installed."
193
+ else
194
+ curl -o /tmp/install.sh 'https://raw.githubusercontent.com/habitat-sh/habitat/master/components/hab/install.sh'
195
+ sudo -E bash /tmp/install.sh#{version}
196
+ fi
197
+ BASH
154
198
  end
155
199
 
156
- def clean_up_previous_supervisor
157
- return if config[:use_screen]
158
-
159
- <<-EOH
160
- [ -f ./run.pid ] && echo "Removing previous supervisor and unloading package. "
161
- [ -f ./run.pid ] && sudo -E hab svc unload #{package_ident}
162
- [ -f ./run.pid ] && sleep 5
163
- [ -f ./run.pid ] && sudo -E kill $(cat run.pid)
164
- [ -f ./run.pid ] && sleep 5
165
- EOH
200
+ def windows_install_service
201
+ <<~WINDOWS_SERVICE_SETUP
202
+ New-Item -Path C:\\Windows\\Temp\\kitchen -ItemType Directory -Force | Out-Null
203
+ #{"New-Item -Path C:\\Windows\\Temp\\kitchen\\config -ItemType Directory -Force | Out-Null" unless config[:override_package_config]}
204
+ if (!($env:Path | Select-String "Habitat")) {
205
+ $env:Path += ";C:\\ProgramData\\Habitat"
206
+ }
207
+ if (!(Get-Service -Name Habitat -ErrorAction Ignore)) {
208
+ hab license accept
209
+ Write-Output "Installing Habitat Windows Service"
210
+ hab pkg install core/windows-service
211
+ if ($(Get-Service -Name Habitat).Status -ne "Stopped") {
212
+ Stop-Service -Name Habitat
213
+ }
214
+ $HabSvcConfig = "c:\\hab\\svc\\windows-service\\HabService.dll.config"
215
+ [xml]$xmlDoc = Get-Content $HabSvcConfig
216
+ $obj = $xmlDoc.configuration.appSettings.add | where {$_.Key -eq "launcherArgs" }
217
+ $obj.value = "--no-color#{supervisor_options}"
218
+ $xmlDoc.Save($HabSvcConfig)
219
+ Start-Service -Name Habitat
220
+ }
221
+ WINDOWS_SERVICE_SETUP
166
222
  end
167
223
 
168
- def sup_run_script
169
- <<~SCRIPT
170
- cat > /tmp/sup-run.sh <<"END"
171
- #!/bin/bash
172
-
173
- while true
174
- do
175
- COUNT=$(ps aux | grep hab | wc -l)
176
- if [[ ${COUNT} -lt 2 ]]
177
- then
178
- sudo -E hab sup run #{supervisor_options} > ~/nohup.out & echo $! > /tmp/run.pid
224
+ def linux_install_service
225
+ <<~LINUX_SERVICE_SETUP
226
+ id -u hab >/dev/null 2>&1 || sudo -E useradd hab >/dev/null 2>&1
227
+ rm -rf /tmp/kitchen
228
+ mkdir -p /tmp/kitchen/results
229
+ #{"mkdir -p /tmp/kitchen/config" unless config[:override_package_config]}
230
+ if [ -f /etc/systemd/system/hab-sup.service ]
231
+ then
232
+ echo "Hab-sup service already exists"
233
+ else
234
+ echo "Starting hab-sup service install"
235
+ hab license accept
236
+ if ! id -u hab > /dev/null 2>&1; then
237
+ echo "Adding hab user"
238
+ sudo -E groupadd hab
179
239
  fi
180
- done
181
- END
182
- SCRIPT
183
- end
184
-
185
- def run_package_in_background
186
- if config[:use_screen]
187
- "sudo -E screen -mdS \"#{clean_package_name}\" hab start #{package_ident} #{supervisor_options}"
188
- else
189
- <<-RUN
190
- [ -f ./run.pid ] && rm -f run.pid
191
- [ -f ./nohup.out ] && rm -f nohup.out
192
-
193
- #{sup_run_script}
194
-
195
- sudo -E chmod +x /tmp/sup-run.sh
196
-
197
- nohup /tmp/sup-run.sh & > sup-run.out
198
-
199
- until sudo -E hab svc status
200
- do
201
- sleep 1
202
- done
203
-
204
- sudo -E hab svc load #{package_ident} #{service_options}
205
-
206
- until sudo -E hab svc status | grep #{package_ident}
207
- do
208
- sleep 1
209
- done
210
-
211
- [ -f ./nohup.out ] && cat nohup.out || (echo "Failed to start the supervisor." && exit 1)
212
- RUN
213
- end
240
+ if ! id -g hab > /dev/null 2>&1; then
241
+ echo "Adding hab group"
242
+ sudo -E useradd -g hab hab
243
+ fi
244
+ echo [Unit] | sudo tee /etc/systemd/system/hab-sup.service
245
+ echo Description=The Chef Habitat Supervisor | sudo tee -a /etc/systemd/system/hab-sup.service
246
+ echo [Service] | sudo tee -a /etc/systemd/system/hab-sup.service
247
+ echo Environment="HAB_BLDR_URL=#{config[:depot_url]}" | sudo tee -a /etc/systemd/system/hab-sup.service
248
+ echo Environment="HAB_LICENSE=#{config[:hab_license]}" | sudo tee -a /etc/systemd/system/hab-sup.service
249
+ echo "ExecStart=/bin/hab sup run #{supervisor_options}" | sudo tee -a /etc/systemd/system/hab-sup.service
250
+ echo [Install] | sudo tee -a /etc/systemd/system/hab-sup.service
251
+ echo WantedBy=default.target | sudo tee -a /etc/systemd/system/hab-sup.service
252
+ sudo -E systemctl daemon-reload
253
+ sudo -E systemctl start hab-sup
254
+ sudo -E systemctl enable hab-sup
255
+ fi
256
+ LINUX_SERVICE_SETUP
214
257
  end
215
258
 
216
259
  def resolve_results_directory
@@ -271,85 +314,57 @@ module Kitchen
271
314
  FileUtils.cp(full_user_toml_path, sandbox_user_toml_path)
272
315
  end
273
316
 
274
- def install_service_package
275
- return unless config[:install_latest_artifact] || !config[:artifact_name].nil?
276
-
277
- artifact_name = ""
278
- if config[:install_latest_artifact]
279
- artifact_name = latest_artifact_name
280
- elsif !config[:install_latest_artifact] && !config[:artifact_name].nil?
281
- artifact_name = config[:artifact_name]
282
- else
283
- return
284
- end
285
- ident = artifact_name_to_package_ident_regex.match(artifact_name)
286
- config[:package_origin] = ident["origin"]
287
- config[:package_name] = ident["name"]
288
- config[:package_version] = ident["version"]
289
- config[:package_release] = ident["release"]
290
-
291
- artifact_path = File.join(File.join(config[:root_path], "results"), artifact_name)
292
- "sudo -E hab pkg install #{artifact_path}"
293
- end
294
-
295
317
  def latest_artifact_name
296
318
  results_dir = resolve_results_directory
297
319
  return if results_dir.nil?
298
320
 
299
- artifact_path = Dir.glob(File.join(results_dir, "#{config[:package_origin]}-#{config[:package_name]}-*.hart")).max_by { |f| File.mtime(f) }
321
+ if config[:install_latest_artifact]
322
+ if config[:package_origin].nil? || config[:package_name].nil?
323
+ raise UserError,
324
+ "You must specify a 'package_origin' and 'package_name' to use the 'install_latest_artifact' option"
325
+ end
326
+ end
300
327
 
328
+ artifact_path = Dir.glob(File.join(results_dir, "#{config[:package_origin]}-#{config[:package_name]}-*.hart")).max_by { |f| File.mtime(f) }
301
329
  File.basename(artifact_path)
302
330
  end
303
331
 
304
332
  def copy_user_toml_to_service_directory
305
333
  return unless !config[:config_directory].nil? && File.exist?(full_user_toml_path)
306
334
 
307
- <<-EOH
308
- sudo -E mkdir -p /hab/svc/#{config[:package_name]}
309
- sudo -E cp #{File.join(File.join(config[:root_path], "config"), "user.toml")} /hab/svc/#{config[:package_name]}/user.toml
310
- EOH
335
+ if windows_os?
336
+ <<~PWSH
337
+ New-Item -Path c:\\hab\\user\\#{config[:package_name]}\\config -ItemType Directory -Force | Out-Null
338
+ Copy-Item -Path #{File.join(File.join(config[:root_path], "config"), "user.toml")} -Destination c:\\hab\\user\\#{config[:package_name]}\\config\\user.toml -Force
339
+ PWSH
340
+ else
341
+ <<~BASH
342
+ sudo -E mkdir -p /hab/user/#{config[:package_name]}/config
343
+ sudo -E cp #{File.join(File.join(config[:root_path], "config"), "user.toml")} /hab/user/#{config[:package_name]}/config/user.toml
344
+ BASH
345
+ end
311
346
  end
312
347
 
313
348
  def remove_previous_user_toml
314
- <<-REMOVE
315
- if [ -d "/hab/svc/#{config[:package_name]}" ]; then
316
- sudo -E find /hab/svc/#{config[:package_name]} -name user.toml -delete
317
- fi
318
- REMOVE
319
- end
320
-
321
- def export_hab_bldr_url
322
- return if config[:depot_url].nil?
323
-
324
- "export HAB_BLDR_URL=#{config[:depot_url]}"
325
- end
326
-
327
- def export_hab_license
328
- return if config[:hab_license].nil?
329
-
330
- "export HAB_LICENSE=#{config[:hab_license]}"
331
- end
332
-
333
- def install_supervisor_command
334
- "sudo -E hab pkg install #{hab_sup_ident}"
335
- end
336
-
337
- def binlink_supervisor_command
338
- "sudo -E hab pkg binlink #{hab_sup_ident} hab-sup"
349
+ if windows_os?
350
+ <<~REMOVE
351
+ if (Test-Path c:\\hab\\user\\#{config[:package_name]}\\config\\user.toml) {
352
+ Remove-Item -Path c:\\hab\\user\\#{config[:package_name]}\\config\\user.toml -Force
353
+ }
354
+ REMOVE
355
+ else
356
+ <<~REMOVE
357
+ if [ -d "/hab/user/#{config[:package_name]}/config" ]; then
358
+ sudo -E find /hab/user/#{config[:package_name]}/config -name user.toml -delete
359
+ fi
360
+ REMOVE
361
+ end
339
362
  end
340
363
 
341
364
  def artifact_name_to_package_ident_regex
342
365
  /(?<origin>\w+)-(?<name>.*)-(?<version>(\d+)?(\.\d+)?(\.\d+)?(\.\d+)?)-(?<release>\d+)-(?<target>.*)\.hart$/
343
366
  end
344
367
 
345
- def hab_sup_ident
346
- ident = "#{config[:hab_sup_origin]}/" \
347
- "#{config[:hab_sup_name]}/" \
348
- "#{config[:hab_sup_version]}/" \
349
- "#{config[:hab_sup_release]}".chomp("/").chomp("/")
350
- @sup_ident ||= ident
351
- end
352
-
353
368
  def package_ident
354
369
  ident = "#{config[:package_origin]}/" \
355
370
  "#{config[:package_name]}/" \
@@ -358,8 +373,21 @@ module Kitchen
358
373
  @pkg_ident = ident
359
374
  end
360
375
 
361
- def clean_package_name
362
- @clean_name ||= "#{config[:package_origin]}-#{config[:package_name]}"
376
+ def get_artifact_name
377
+ artifact_name = ""
378
+ if config[:install_latest_artifact]
379
+ artifact_name = latest_artifact_name
380
+ elsif !config[:install_latest_artifact] && !config[:artifact_name].nil?
381
+ artifact_name = config[:artifact_name]
382
+ else
383
+ return
384
+ end
385
+ ident = artifact_name_to_package_ident_regex.match(artifact_name)
386
+ config[:package_origin] = ident["origin"]
387
+ config[:package_name] = ident["name"]
388
+ config[:package_version] = ident["version"]
389
+ config[:package_release] = ident["release"]
390
+ File.join(File.join(config[:root_path], "results"), artifact_name)
363
391
  end
364
392
 
365
393
  def supervisor_options
@@ -374,6 +402,11 @@ module Kitchen
374
402
  options += " --topology #{config[:service_topology]}" unless config[:service_topology].nil?
375
403
  options += " --strategy #{config[:service_update_strategy]}" unless config[:service_update_strategy].nil?
376
404
  options += " --channel #{config[:channel]}" unless config[:channel].nil?
405
+ options += " --event-stream-application #{config[:event_stream_application]}" unless config[:event_stream_application].nil?
406
+ options += " --event-stream-environment #{config[:event_stream_environment]}" unless config[:event_stream_environment].nil?
407
+ options += " --event-stream-site #{config[:event_stream_site]}" unless config[:event_stream_site].nil?
408
+ options += " --event-stream-url #{config[:event_stream_url]}" unless config[:event_stream_url].nil?
409
+ options += " --event-stream-token #{config[:event_stream_token]}" unless config[:event_stream_token].nil?
377
410
 
378
411
  options
379
412
  end
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kitchen-habitat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.2
4
+ version: 0.12.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steven Murawski
8
- autorequire:
8
+ - Robb Kidd
9
+ autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2019-12-02 00:00:00.000000000 Z
12
+ date: 2020-07-29 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: test-kitchen
@@ -110,7 +111,8 @@ description: |+
110
111
  TBD
111
112
 
112
113
  email:
113
- - smurawski@chef.io
114
+ - steven.murawski@gmail.com
115
+ - robb@thekidds.org
114
116
  executables: []
115
117
  extensions: []
116
118
  extra_rdoc_files: []
@@ -122,7 +124,7 @@ homepage: https://github.com/test-kitchen/kitchen-habitat
122
124
  licenses:
123
125
  - Apache-2.0
124
126
  metadata: {}
125
- post_install_message:
127
+ post_install_message:
126
128
  rdoc_options: []
127
129
  require_paths:
128
130
  - lib
@@ -137,8 +139,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
137
139
  - !ruby/object:Gem::Version
138
140
  version: '0'
139
141
  requirements: []
140
- rubygems_version: 3.0.3
141
- signing_key:
142
+ rubygems_version: 3.1.2
143
+ signing_key:
142
144
  specification_version: 4
143
145
  summary: Habitat provisioner for test-kitchen
144
146
  test_files: []
147
+ ...