itamae 1.2.2 → 1.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/itamae.gemspec +1 -1
- data/lib/itamae/backend.rb +3 -2
- data/lib/itamae/node.rb +38 -15
- data/lib/itamae/version.txt +1 -1
- data/spec/unit/lib/itamae/node_spec.rb +1 -1
- data/spec/unit/spec_helper.rb +1 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f7fa94c40f407b231be9ce95914243185fc593d1
|
4
|
+
data.tar.gz: 9dc1fa0303e5300ebb4742ec6f0265764af39ac8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 50781d5b380946cfe7647780a245e94929ae8c0c1af8cfa6435621b900af04cf5be62fc04fd2b0249343bceb97f26f026cd424afa509743c6da388bb2bb18e11
|
7
|
+
data.tar.gz: d1c88a9ec88b590af6c40dc4681b26ec09fd26e57c64cf20edb84fa9f01064a443911f9b799d8959eeb6c8dfe287c7ec96b9b9351d7c4448e397b8e630e120aa
|
data/CHANGELOG.md
CHANGED
data/itamae.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.require_paths = ["lib"]
|
19
19
|
|
20
20
|
spec.add_runtime_dependency "thor"
|
21
|
-
spec.add_runtime_dependency "specinfra", [">= 2.24.
|
21
|
+
spec.add_runtime_dependency "specinfra", [">= 2.24.2", "< 3.0.0"]
|
22
22
|
spec.add_runtime_dependency "hashie"
|
23
23
|
spec.add_runtime_dependency "ansi"
|
24
24
|
spec.add_runtime_dependency "schash", "~> 0.1.0"
|
data/lib/itamae/backend.rb
CHANGED
@@ -2,6 +2,8 @@ require 'specinfra'
|
|
2
2
|
require 'singleton'
|
3
3
|
require 'io/console'
|
4
4
|
|
5
|
+
Specinfra.configuration.error_on_missing_backend_type = true
|
6
|
+
|
5
7
|
module Specinfra
|
6
8
|
module Configuration
|
7
9
|
def self.sudo_password
|
@@ -157,10 +159,9 @@ module Itamae
|
|
157
159
|
|
158
160
|
if @options[:vagrant]
|
159
161
|
config = Tempfile.new('', Dir.tmpdir)
|
160
|
-
hostname = opts[:
|
162
|
+
hostname = opts[:host_name] || 'default'
|
161
163
|
`vagrant ssh-config #{hostname} > #{config.path}`
|
162
164
|
opts.merge!(Net::SSH::Config.for(hostname, [config.path]))
|
163
|
-
opts[:host] = opts.delete(:host_name)
|
164
165
|
end
|
165
166
|
|
166
167
|
if @options[:ask_password]
|
data/lib/itamae/node.rb
CHANGED
@@ -4,36 +4,34 @@ require 'json'
|
|
4
4
|
require 'schash'
|
5
5
|
|
6
6
|
module Itamae
|
7
|
-
class Node
|
7
|
+
class Node
|
8
8
|
ValidationError = Class.new(StandardError)
|
9
9
|
|
10
|
-
|
11
|
-
|
10
|
+
attr_reader :mash
|
11
|
+
|
12
|
+
def initialize(hash, backend)
|
13
|
+
@mash = Hashie::Mash.new(hash)
|
12
14
|
@backend = backend
|
13
15
|
end
|
14
16
|
|
15
17
|
def reverse_merge(other_hash)
|
16
|
-
|
18
|
+
self.class.new(_reverse_merge(other_hash), @backend)
|
17
19
|
end
|
18
20
|
|
19
21
|
def reverse_merge!(other_hash)
|
20
|
-
|
22
|
+
@mash.replace(_reverse_merge(other_hash))
|
21
23
|
end
|
22
24
|
|
23
25
|
def [](key)
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
rescue NotImplementedError, NameError
|
29
|
-
val = nil
|
30
|
-
end
|
26
|
+
if @mash.has_key?(key)
|
27
|
+
@mash[key]
|
28
|
+
else
|
29
|
+
fetch_inventory_value(key)
|
31
30
|
end
|
32
|
-
val
|
33
31
|
end
|
34
32
|
|
35
33
|
def validate!(&block)
|
36
|
-
errors = Schash::Validator.new(&block).validate(
|
34
|
+
errors = Schash::Validator.new(&block).validate(@mash)
|
37
35
|
unless errors.empty?
|
38
36
|
errors.each do |error|
|
39
37
|
Logger.error "'#{error.position.join('->')}' #{error.message}"
|
@@ -41,6 +39,31 @@ module Itamae
|
|
41
39
|
raise ValidationError
|
42
40
|
end
|
43
41
|
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
def _reverse_merge(other_hash)
|
46
|
+
Hashie::Mash.new(other_hash).merge(@mash)
|
47
|
+
end
|
48
|
+
|
49
|
+
def method_missing(method, *args)
|
50
|
+
if @mash.respond_to?(method)
|
51
|
+
return @mash.public_send(method, *args)
|
52
|
+
elsif args.empty? && value = fetch_inventory_value(method)
|
53
|
+
return value
|
54
|
+
end
|
55
|
+
|
56
|
+
super
|
57
|
+
end
|
58
|
+
|
59
|
+
def respond_to?(method, priv = false)
|
60
|
+
@mash.respond_to?(method, priv) || super
|
61
|
+
end
|
62
|
+
|
63
|
+
def fetch_inventory_value(key)
|
64
|
+
@backend.host_inventory[key]
|
65
|
+
rescue NotImplementedError, NameError
|
66
|
+
nil
|
67
|
+
end
|
44
68
|
end
|
45
69
|
end
|
46
|
-
|
data/lib/itamae/version.txt
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.2.
|
1
|
+
1.2.3
|
@@ -7,7 +7,7 @@ module Itamae
|
|
7
7
|
it "merges a hash but the method receiver's value will be preferred" do
|
8
8
|
a = described_class.new({a: :b, c: :d}, backend)
|
9
9
|
expected = described_class.new({a: :b, c: :d, e: :f}, backend)
|
10
|
-
expect(a.reverse_merge(a: :c, e: :f)).to eq(expected)
|
10
|
+
expect(a.reverse_merge(a: :c, e: :f).mash).to eq(expected.mash)
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
data/spec/unit/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: itamae
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryota Arai
|
@@ -30,7 +30,7 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 2.24.
|
33
|
+
version: 2.24.2
|
34
34
|
- - "<"
|
35
35
|
- !ruby/object:Gem::Version
|
36
36
|
version: 3.0.0
|
@@ -40,7 +40,7 @@ dependencies:
|
|
40
40
|
requirements:
|
41
41
|
- - ">="
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version: 2.24.
|
43
|
+
version: 2.24.2
|
44
44
|
- - "<"
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: 3.0.0
|