hem 1.0.1.beta5 → 1.0.1.beta6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/hem/lib/vm/command.rb +12 -14
- data/lib/hem/lib/vm/inspector.rb +1 -15
- data/lib/hem/version.rb +1 -1
- data/spec/hem/helpers/command_spec.rb +19 -10
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 464afc8e551b0a00daad552544ab7d939d0fb0f0
|
4
|
+
data.tar.gz: c36788f90cb8a124df6fd45efb8f2872ef05093d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5126f005b480789a700e71c442aca4f9443ee45bec148abb7bacd2abdb81b3dd6396381384af602127c410cce5aebdc7231932e3dfd5a100db64b86034b12d91
|
7
|
+
data.tar.gz: ad45a6aba07525e19a4d2c5a6c3de35a0eb3932e826e8d8b8ec5f04d3a87fa04a0b42b3cfd8ba21589300ff96125b72bf84b6639d50e57ac4c1648a4ce29693f
|
data/Gemfile.lock
CHANGED
data/lib/hem/lib/vm/command.rb
CHANGED
@@ -53,38 +53,36 @@ module Hem
|
|
53
53
|
# https://gist.github.com/jedi4ever/5657094
|
54
54
|
|
55
55
|
def to_s
|
56
|
-
|
56
|
+
require 'tempfile'
|
57
|
+
config = ::Tempfile.new 'hem_ssh_config'
|
58
|
+
config.write @@vm_inspector.ssh_config
|
59
|
+
config.close
|
57
60
|
|
58
|
-
psuedo_tty = opts[:psuedo_tty] ?
|
61
|
+
psuedo_tty = opts[:psuedo_tty] ? '-t' : ''
|
59
62
|
|
60
63
|
ssh_command = [
|
61
|
-
|
62
|
-
"-
|
63
|
-
"-o 'StrictHostKeyChecking no'",
|
64
|
-
"-o 'ForwardAgent yes'",
|
65
|
-
"-o 'LogLevel FATAL'",
|
66
|
-
"-p #{opts[:ssh_port]}",
|
67
|
-
"-i #{opts[:ssh_identity].shellescape}",
|
64
|
+
'ssh',
|
65
|
+
"-F #{config.path.shellescape}",
|
68
66
|
psuedo_tty,
|
69
|
-
|
70
|
-
].join(
|
67
|
+
'default'
|
68
|
+
].join(' ')
|
71
69
|
|
72
70
|
pwd_set_command = " -- \"cd #{@opts[:pwd].shellescape}; exec /bin/bash"
|
73
71
|
|
74
72
|
vm_command = [
|
75
73
|
@pipe_in_vm.nil? ? nil : @pipe_in_vm.gsub(/(\\+)/, '\\\\\1'),
|
76
74
|
@command
|
77
|
-
].compact.join(
|
75
|
+
].compact.join(' | ')
|
78
76
|
|
79
77
|
command = [
|
80
78
|
ssh_command + pwd_set_command,
|
81
79
|
vm_command.empty? ? nil : vm_command.shellescape
|
82
|
-
].compact.join(
|
80
|
+
].compact.join(' -c ') + "#{@opts[:append].shellescape}\""
|
83
81
|
|
84
82
|
[
|
85
83
|
@pipe,
|
86
84
|
command
|
87
|
-
].compact.join(
|
85
|
+
].compact.join(' | ')
|
88
86
|
end
|
89
87
|
|
90
88
|
def to_str
|
data/lib/hem/lib/vm/inspector.rb
CHANGED
@@ -51,21 +51,7 @@ module Hem
|
|
51
51
|
|
52
52
|
raise Exception.new "Could not retrieve VM ssh configuration" unless config
|
53
53
|
|
54
|
-
|
55
|
-
:ssh_user => /^\s*User (.*)$/,
|
56
|
-
:ssh_identity => /^\s*IdentityFile (.*)$/,
|
57
|
-
:ssh_host => /^\s*HostName (.*)$/,
|
58
|
-
:ssh_port => /^\s*Port (\d+)/
|
59
|
-
}
|
60
|
-
|
61
|
-
output = {}
|
62
|
-
|
63
|
-
patterns.each do |k, pattern|
|
64
|
-
match = config.match(pattern)
|
65
|
-
output[k] = match[1] if match
|
66
|
-
end
|
67
|
-
|
68
|
-
return @ssh_config = output
|
54
|
+
return config
|
69
55
|
end
|
70
56
|
end
|
71
57
|
end
|
data/lib/hem/version.rb
CHANGED
@@ -12,15 +12,24 @@ describe Hem::Helper do
|
|
12
12
|
}
|
13
13
|
})
|
14
14
|
|
15
|
+
Hem.user_config = DeepStruct.wrap({})
|
16
|
+
|
15
17
|
Hem.ui = Hem::Ui.new
|
16
18
|
|
17
19
|
vmi_double = double(Hem::Lib::Vm::Inspector).as_null_object
|
18
|
-
vmi_double.should_receive(:ssh_config).and_return
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
20
|
+
vmi_double.should_receive(:ssh_config).and_return <<-eos
|
21
|
+
Host default
|
22
|
+
HostName 127.0.0.1
|
23
|
+
User vagrant
|
24
|
+
Port 2222
|
25
|
+
UserKnownHostsFile /dev/null
|
26
|
+
StrictHostKeyChecking no
|
27
|
+
PasswordAuthentication no
|
28
|
+
IdentityFile "/path/to/project/tools/vagrant/.vagrant/machines/default/virtualbox/private_key"
|
29
|
+
IdentitiesOnly yes
|
30
|
+
LogLevel FATAL
|
31
|
+
ForwardAgent yes
|
32
|
+
eos
|
24
33
|
|
25
34
|
Hem::Lib::Vm::Command.class_eval do
|
26
35
|
class_variable_set '@@vm_inspector', vmi_double
|
@@ -36,12 +45,12 @@ describe Hem::Helper do
|
|
36
45
|
create_command("my_command", :pwd => '/').to_s.should_not match /\s-t\s/
|
37
46
|
end
|
38
47
|
|
39
|
-
it "should
|
40
|
-
create_command("my_command", :pwd => '/').to_s.should match
|
48
|
+
it "should use injected config" do
|
49
|
+
create_command("my_command", :pwd => '/').to_s.should match /-F [^-][^ ]*/
|
41
50
|
end
|
42
51
|
|
43
|
-
it "should default
|
44
|
-
create_command("my_command", :pwd => '/').to_s.should match
|
52
|
+
it "should use default host" do
|
53
|
+
create_command("my_command", :pwd => '/').to_s.should match /\ default/
|
45
54
|
end
|
46
55
|
|
47
56
|
it "should not wrap piped commands with echo by default" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hem
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.1.
|
4
|
+
version: 1.0.1.beta6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Simons
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: slop
|