specinfra 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +17 -0
- data/lib/specinfra/backend/exec.rb +3 -3
- data/lib/specinfra/backend/powershell/script_helper.rb +2 -2
- data/lib/specinfra/backend/ssh.rb +7 -7
- data/lib/specinfra/backend/winrm.rb +1 -1
- data/lib/specinfra/configuration.rb +16 -2
- data/lib/specinfra/helper/configuration.rb +6 -3
- data/lib/specinfra/helper/detect_os.rb +1 -1
- data/lib/specinfra/version.rb +1 -1
- data/lib/specinfra.rb +12 -10
- data/spec/configurtaion_spec.rb +9 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 36a703933ea44bd71de0b88b0932315f8e5ec819
|
4
|
+
data.tar.gz: 8d6c7246f7598d31516cf86e000bc968f341b5d5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 941ef8ee1a35f4395ca16b0cee9152a078b31dfd3c178cffcb93b004b2eb872888efc2f83fce78afa0cc92fb6143aefb7998dbbdea71424f2178579818234796
|
7
|
+
data.tar.gz: 89e1728fe2ce6418282f441032a557505114088597ce1353dc45fd2ee158de140683590aa649850a4abaf385a44be473604e601936a4078edc3fc322a7aa81d9
|
data/.travis.yml
ADDED
@@ -33,7 +33,7 @@ module SpecInfra
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def build_command(cmd)
|
36
|
-
path = SpecInfra.configuration.path
|
36
|
+
path = SpecInfra.configuration.path
|
37
37
|
if path
|
38
38
|
cmd = "env PATH=#{path}:$PATH #{cmd}"
|
39
39
|
cmd.gsub!(/(\&\&\s*!?\(?\s*)/, "\\1env PATH=#{path}:$PATH ")
|
@@ -43,7 +43,7 @@ module SpecInfra
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def add_pre_command(cmd)
|
46
|
-
path = SpecInfra.configuration.path
|
46
|
+
path = SpecInfra.configuration.path
|
47
47
|
if SpecInfra.configuration.pre_command
|
48
48
|
cmd = "#{SpecInfra.configuration.pre_command} && #{cmd}"
|
49
49
|
cmd = "env PATH=#{path}:$PATH #{cmd}" if path
|
@@ -178,7 +178,7 @@ module SpecInfra
|
|
178
178
|
end
|
179
179
|
|
180
180
|
def check_os
|
181
|
-
return
|
181
|
+
return SpecInfra.configuration.os if SpecInfra.configuration.os
|
182
182
|
if run_command('ls /etc/redhat-release')[:exit_status] == 0
|
183
183
|
line = run_command('cat /etc/redhat-release')[:stdout]
|
184
184
|
if line =~ /release (\d[\d.]*)/
|
@@ -5,7 +5,7 @@ module SpecInfra
|
|
5
5
|
module PowerShell
|
6
6
|
module ScriptHelper
|
7
7
|
def build_command(cmd)
|
8
|
-
path = SpecInfra.configuration.path
|
8
|
+
path = SpecInfra.configuration.path
|
9
9
|
if path
|
10
10
|
cmd.strip!
|
11
11
|
cmd =
|
@@ -18,7 +18,7 @@ EOF
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def add_pre_command(cmd)
|
21
|
-
path = SpecInfra.configuration.path
|
21
|
+
path = SpecInfra.configuration.path
|
22
22
|
if SpecInfra.configuration.pre_command
|
23
23
|
cmd.strip!
|
24
24
|
cmd =
|
@@ -20,7 +20,7 @@ module SpecInfra
|
|
20
20
|
|
21
21
|
def build_command(cmd)
|
22
22
|
cmd = super(cmd)
|
23
|
-
if
|
23
|
+
if SpecInfra.configuration.ssh.options[:user] != 'root'
|
24
24
|
cmd = "#{sudo} #{cmd}"
|
25
25
|
cmd.gsub!(/(\&\&\s*!?\(?\s*)/, "\\1#{sudo} ")
|
26
26
|
cmd.gsub!(/(\|\|\s*!?\(?\s*)/, "\\1#{sudo} ")
|
@@ -30,7 +30,7 @@ module SpecInfra
|
|
30
30
|
|
31
31
|
def add_pre_command(cmd)
|
32
32
|
cmd = super(cmd)
|
33
|
-
user =
|
33
|
+
user = SpecInfra.configuration.ssh.options[:user]
|
34
34
|
pre_command = SpecInfra.configuration.pre_command
|
35
35
|
if pre_command && user != 'root'
|
36
36
|
cmd = "#{sudo} #{cmd}"
|
@@ -44,9 +44,9 @@ module SpecInfra
|
|
44
44
|
stderr_data = ''
|
45
45
|
exit_status = nil
|
46
46
|
exit_signal = nil
|
47
|
-
pass_prompt =
|
47
|
+
pass_prompt = SpecInfra.configuration.pass_prompt || /^\[sudo\] password for/
|
48
48
|
|
49
|
-
ssh =
|
49
|
+
ssh = SpecInfra.configuration.ssh
|
50
50
|
ssh.open_channel do |channel|
|
51
51
|
channel.request_pty do |ch, success|
|
52
52
|
abort "Could not obtain pty " if !success
|
@@ -55,8 +55,8 @@ module SpecInfra
|
|
55
55
|
abort "FAILED: couldn't execute command (ssh.channel.exec)" if !success
|
56
56
|
channel.on_data do |ch, data|
|
57
57
|
if data.match pass_prompt
|
58
|
-
abort "Please set sudo password by using SUDO_PASSWORD or ASK_SUDO_PASSWORD environment variable" if
|
59
|
-
channel.send_data "#{
|
58
|
+
abort "Please set sudo password by using SUDO_PASSWORD or ASK_SUDO_PASSWORD environment variable" if SpecInfra.configuration.sudo_password.nil?
|
59
|
+
channel.send_data "#{SpecInfra.configuration.sudo_password}\n"
|
60
60
|
else
|
61
61
|
stdout_data += data
|
62
62
|
end
|
@@ -80,7 +80,7 @@ module SpecInfra
|
|
80
80
|
end
|
81
81
|
|
82
82
|
def sudo
|
83
|
-
sudo_path = SpecInfra.configuration.sudo_path
|
83
|
+
sudo_path = SpecInfra.configuration.sudo_path
|
84
84
|
if sudo_path
|
85
85
|
"#{sudo_path}/sudo"
|
86
86
|
else
|
@@ -2,11 +2,25 @@ module SpecInfra
|
|
2
2
|
module Configuration
|
3
3
|
class << self
|
4
4
|
VALID_OPTIONS_KEYS = [:path, :pre_command, :stdout, :stderr, :sudo_path, :pass_prompt].freeze
|
5
|
-
|
6
|
-
|
5
|
+
|
7
6
|
def defaults
|
8
7
|
VALID_OPTIONS_KEYS.inject({}) { |o, k| o.merge!(k => send(k)) }
|
9
8
|
end
|
9
|
+
|
10
|
+
def method_missing(meth, val=nil)
|
11
|
+
key = meth.to_s
|
12
|
+
key.gsub!(/=$/, '')
|
13
|
+
if val
|
14
|
+
instance_variable_set("@#{key}", val)
|
15
|
+
RSpec.configuration.send(:"#{key}=", val) if defined?(RSpec)
|
16
|
+
end
|
17
|
+
|
18
|
+
ret = instance_variable_get("@#{key}")
|
19
|
+
if ret.nil? && defined?(RSpec) && RSpec.configuration.respond_to?(key)
|
20
|
+
ret = RSpec.configuration.send(key)
|
21
|
+
end
|
22
|
+
ret
|
23
|
+
end
|
10
24
|
end
|
11
25
|
end
|
12
26
|
end
|
@@ -27,9 +27,12 @@ module SpecInfra
|
|
27
27
|
# end
|
28
28
|
def build_configurations
|
29
29
|
SpecInfra::Configuration.defaults.keys.each do |c|
|
30
|
-
|
31
|
-
|
32
|
-
|
30
|
+
if self.respond_to?(c.to_sym)
|
31
|
+
value = self.send(c)
|
32
|
+
else
|
33
|
+
value = RSpec.configuration.send(c) if defined?(RSpec)
|
34
|
+
end
|
35
|
+
SpecInfra::Configuration.instance_variable_set("@#{c}", value)
|
33
36
|
end
|
34
37
|
end
|
35
38
|
end
|
@@ -3,7 +3,7 @@ module SpecInfra
|
|
3
3
|
module DetectOS
|
4
4
|
def commands
|
5
5
|
property[:os_by_host] = {} if ! property[:os_by_host]
|
6
|
-
host =
|
6
|
+
host = SpecInfra.configuration.ssh ? SpecInfra.configuration.ssh.host : 'localhost'
|
7
7
|
|
8
8
|
if property[:os_by_host][host]
|
9
9
|
os = property[:os_by_host][host]
|
data/lib/specinfra/version.rb
CHANGED
data/lib/specinfra.rb
CHANGED
@@ -13,15 +13,17 @@ module SpecInfra
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
-
RSpec
|
17
|
-
c
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
16
|
+
if defined?(RSpec)
|
17
|
+
RSpec.configure do |c|
|
18
|
+
c.include(SpecInfra::Helper::Configuration)
|
19
|
+
c.add_setting :os, :default => nil
|
20
|
+
c.add_setting :host, :default => nil
|
21
|
+
c.add_setting :ssh, :default => nil
|
22
|
+
c.add_setting :sudo_password, :default => nil
|
23
|
+
c.add_setting :winrm, :default => nil
|
24
|
+
SpecInfra.configuration.defaults.each { |k, v| c.add_setting k, :default => v }
|
25
|
+
c.before :each do
|
26
|
+
backend.set_example(example) if defined?(SPEC_TYPE)
|
27
|
+
end
|
26
28
|
end
|
27
29
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: specinfra
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gosuke Miyashita
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-12-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -46,6 +46,7 @@ extensions: []
|
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
48
|
- .gitignore
|
49
|
+
- .travis.yml
|
49
50
|
- Gemfile
|
50
51
|
- LICENSE.txt
|
51
52
|
- README.md
|
@@ -77,6 +78,7 @@ files:
|
|
77
78
|
- lib/specinfra/helper/properties.rb
|
78
79
|
- lib/specinfra/properties.rb
|
79
80
|
- lib/specinfra/version.rb
|
81
|
+
- spec/configurtaion_spec.rb
|
80
82
|
- spec/helpers/properties_spec.rb
|
81
83
|
- spec/spec_helper.rb
|
82
84
|
- specinfra.gemspec
|
@@ -105,5 +107,6 @@ signing_key:
|
|
105
107
|
specification_version: 4
|
106
108
|
summary: Common layer for serverspec and configspec
|
107
109
|
test_files:
|
110
|
+
- spec/configurtaion_spec.rb
|
108
111
|
- spec/helpers/properties_spec.rb
|
109
112
|
- spec/spec_helper.rb
|