kitchen-lxd_sling 0.4.4 → 0.4.5

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
  SHA256:
3
- metadata.gz: bea89cf9dc3306dadfda25d5501485df92a9715a9781927a6c2eb1c17e5e5516
4
- data.tar.gz: d2769558a5223ad8a5083054cadbdb0e203a8e7bc854a81e6dc2c3c14a4683f1
3
+ metadata.gz: 2092e1ad91f7772e18e432a0003511e51e2e453dbe5d29eea414d3f022a4b63e
4
+ data.tar.gz: 20194530a2e8ca27a4fee5be42db55ebb92602f301d3f7376b06a733134657f3
5
5
  SHA512:
6
- metadata.gz: 9fa05e50bbe43ba85b55be5bbdd522345a6ec362bbce6a293d8c3a81e3a0df28a9cc292e8a26ff7f48754d203b4b7800fdac5b3e4f8089b93ffc78681c6af374
7
- data.tar.gz: 8e876f78e83895efeade4ce7d2ef7cc78fdc7bffd6ceb8a6849fbd00dad037bb4562301b7867bb52fd0d80be488b1f25b0299e896582812feb4d29777f16500c
6
+ metadata.gz: fc130261a4f70af5d873eb7da7f15b7080cd73be947d5cb519db1d2d3d4c761a9aff8f771d93c6ca5e7ad185c41392e70dc5406d7f3d0e5c59b227574820e30c
7
+ data.tar.gz: 91cde3d57650a1d328b71eca65d623feb3d9ef0edf5d5a9acbc3c43d12fee35eb05b1ac938b13bab77c9ebd4a5d217933b6985a85eac2278a220dea8a126d42a
@@ -16,6 +16,8 @@ require 'kitchen'
16
16
  require 'kitchen/driver/lxd/host_locator'
17
17
  require 'tty/reader'
18
18
  require 'tty/screen'
19
+ require 'io/wait'
20
+ require 'io/console'
19
21
 
20
22
  class NxHost
21
23
  include Kitchen::Driver::Lxd::HostLocator
@@ -27,18 +29,15 @@ end
27
29
 
28
30
  driver = NxHost.new state[:config]
29
31
  transport = driver.nx_transport state
30
- tty = TTY::Reader.new
32
+ tty = TTY::Reader.new interrupt: :signal
31
33
  win_keymap = {}
32
34
  if Gem.win_platform?
33
35
  win_keymap = TTY::Reader::Keys.keys.invert
34
36
  win_keymap[:clear] = win_keymap[:delete]
35
37
  end
36
38
 
37
- # ruby bin/lxc-shell .kitchen/kitchen-lxd-cloud-ubuntu-1604.yml
39
+ # ruby bin/lxc-shell .kitchen/kitchen-lxd-native-ubuntu-1604.yml
38
40
 
39
- # TODO: (someday - if found useful) the TTY subsystem doesn't capture stdin, so you can't pipe commands to this script
40
- # we'd have to interleave the code for both input types (ignoring tty if stdin is not a tty)
41
- # TTY gems must stay due to them handling windows input for us
42
41
  term = ENV['TERM'] || 'dumb'
43
42
  user = transport.username
44
43
  if user
@@ -47,7 +46,9 @@ if user
47
46
  end
48
47
  transport.execute "env TERM=#{term} su#{user}", capture: :interactive do |active|
49
48
  active.capture_output do |stdout|
50
- print stdout
49
+ $stdout.cooked do
50
+ print stdout
51
+ end
51
52
  end
52
53
  tty.on :keypress do |event|
53
54
  active.stdin.write win_keymap[event.key.name] || event.value
@@ -59,14 +60,20 @@ transport.execute "env TERM=#{term} su#{user}", capture: :interactive do |active
59
60
  # tty-reader doesn't have its own thread - it's pumped by a 'read_xxxx' call
60
61
  # and its inner wait loop blocks VERY HARD unless you nonblock (even a main Thread.kill won't unblock it - windows issue?)
61
62
  # yes windows issue... test code can kill read_keypress when running on linux
62
- begin
63
- loop do
64
- break unless active.thread.alive?
65
- sleep 0.01 unless tty.read_keypress nonblock: true
63
+ kp_opts = { nonblock: true }
64
+ kp_opts = { echo: true, raw: false } unless Gem.win_platform? # counter-options designed to stop io/console calls
65
+ $stdin.noecho do
66
+ $stdin.raw do
67
+ begin
68
+ loop do
69
+ break unless active.thread.alive?
70
+ sleep 0.01 unless (Gem.win_platform? || $stdin.ready?) && tty.read_keypress(kp_opts)
71
+ end
72
+ rescue Interrupt
73
+ # active.thread.signal 2
74
+ active.stdin.write "\x3"
75
+ retry
76
+ end
66
77
  end
67
- rescue Interrupt
68
- # active.thread.signal 2
69
- active.stdin.write "\x3"
70
- retry
71
78
  end
72
79
  end.error!
@@ -21,7 +21,7 @@ class Kitchen::Driver::Lxd < Kitchen::Driver::Base
21
21
  end
22
22
 
23
23
  def can_rest?
24
- !config[:server].nil?
24
+ config[:server] && !config[:server].empty?
25
25
  end
26
26
 
27
27
  def host_address
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Kitchen
4
4
  module Driver
5
- LXD_VERSION = '0.4.4'.freeze
5
+ LXD_VERSION = '0.4.5'.freeze
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kitchen-lxd_sling
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.4
4
+ version: 0.4.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Zachariasen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-02-11 00:00:00.000000000 Z
11
+ date: 2018-02-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lxd-common