itamae 1.12.4 → 1.13.0

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: dd2755f33211c89faf48c7aaa7156c90dc8f2a6228eea1531914c24e8c23242d
4
- data.tar.gz: 38c011974e040f00ce5818f3bf490bae833dc6560146e093a0f0655495c923c8
3
+ metadata.gz: adefcb08fb8611f035cf3f70d3d76ab4c2b1d012aef3f4489f33c4fb445a88fd
4
+ data.tar.gz: d4e7126f52fb0da4906a289025d9c73a2143b90a1297c570b81e3490985cd83e
5
5
  SHA512:
6
- metadata.gz: f3faba704d1dec3f3bfc21428a4574b2c72a6e2804b8f91a8274881325c6b61f9ca30de5b0fadfa3a81726c543d7bcdbe43408022fbcae952c6ba170fa8f0f53
7
- data.tar.gz: 9f3e1aa52bc4d1cbc9b4a4c1687856746738efdec9f43b8988dee73eb43ffa1362501ae0008e1938fb367e763925e292a9930a5d634d4071c54796964549369a
6
+ metadata.gz: 2a5206774cb5c387b79030ed32e9d12c096189a78725294d9516a1abf18199d9ca5d0339b75ae5815d0778f6372b29fef38c3c65b992deea7412729873995578
7
+ data.tar.gz: a8c13d073d29418c523a95501bc42c2864c1250def6a13936f744981eba9ddc4eb9b7ae59a7d66ba367c7799331ea0577fb81815ae7fb0fdc7d1b9825f530a05
@@ -27,9 +27,11 @@ jobs:
27
27
  - "2.6"
28
28
  - "2.7"
29
29
  - "3.0"
30
+ - "3.1"
30
31
  rubyopt:
31
32
  - ""
32
33
  - "--jit"
34
+ - "--yjit"
33
35
  exclude:
34
36
  # --jit is available since MRI 2.6
35
37
  - ruby: "2.3"
@@ -38,7 +40,19 @@ jobs:
38
40
  rubyopt: "--jit"
39
41
  - ruby: "2.5"
40
42
  rubyopt: "--jit"
41
-
43
+ # --yjit is available since MRI 3.1
44
+ - ruby: "2.3"
45
+ rubyopt: "--yjit"
46
+ - ruby: "2.4"
47
+ rubyopt: "--yjit"
48
+ - ruby: "2.5"
49
+ rubyopt: "--yjit"
50
+ - ruby: "2.6"
51
+ rubyopt: "--yjit"
52
+ - ruby: "2.7"
53
+ rubyopt: "--yjit"
54
+ - ruby: "3.0"
55
+ rubyopt: "--yjit"
42
56
  env:
43
57
  RUBYOPT: ${{ matrix.rubyopt }}
44
58
 
@@ -79,9 +93,11 @@ jobs:
79
93
  - "2.6"
80
94
  - "2.7"
81
95
  - "3.0"
96
+ - "3.1"
82
97
  rubyopt:
83
98
  - ""
84
99
  - "--jit"
100
+ - "--yjit"
85
101
  image:
86
102
  - ubuntu:trusty
87
103
  exclude:
@@ -92,6 +108,19 @@ jobs:
92
108
  rubyopt: "--jit"
93
109
  - ruby: "2.5"
94
110
  rubyopt: "--jit"
111
+ # --yjit is available since MRI 3.1
112
+ - ruby: "2.3"
113
+ rubyopt: "--yjit"
114
+ - ruby: "2.4"
115
+ rubyopt: "--yjit"
116
+ - ruby: "2.5"
117
+ rubyopt: "--yjit"
118
+ - ruby: "2.6"
119
+ rubyopt: "--yjit"
120
+ - ruby: "2.7"
121
+ rubyopt: "--yjit"
122
+ - ruby: "3.0"
123
+ rubyopt: "--yjit"
95
124
 
96
125
  env:
97
126
  RUBYOPT: ${{ matrix.rubyopt }}
@@ -142,9 +171,11 @@ jobs:
142
171
  - "2.6"
143
172
  - "2.7"
144
173
  - "3.0"
174
+ - "3.1"
145
175
  rubyopt:
146
176
  - ""
147
177
  - "--jit"
178
+ - "--yjit"
148
179
  exclude:
149
180
  # --jit is available since MRI 2.6
150
181
  - ruby: "2.3"
@@ -153,6 +184,19 @@ jobs:
153
184
  rubyopt: "--jit"
154
185
  - ruby: "2.5"
155
186
  rubyopt: "--jit"
187
+ # --yjit is available since MRI 3.1
188
+ - ruby: "2.3"
189
+ rubyopt: "--yjit"
190
+ - ruby: "2.4"
191
+ rubyopt: "--yjit"
192
+ - ruby: "2.5"
193
+ rubyopt: "--yjit"
194
+ - ruby: "2.6"
195
+ rubyopt: "--yjit"
196
+ - ruby: "2.7"
197
+ rubyopt: "--yjit"
198
+ - ruby: "3.0"
199
+ rubyopt: "--yjit"
156
200
 
157
201
  env:
158
202
  RUBYOPT: ${{ matrix.rubyopt }}
data/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  ## Unreleased
2
- [full changelog](https://github.com/itamae-kitchen/itamae/compare/v1.12.4...master)
2
+ [full changelog](https://github.com/itamae-kitchen/itamae/compare/v1.13.0...master)
3
+
4
+ ## v1.13.0
5
+ [full changelog](https://github.com/itamae-kitchen/itamae/compare/v1.12.6...v1.13.0)
6
+
7
+ Improvements
8
+
9
+ - [Support repeatable "node_json" and "node_yaml" options](https://github.com/itamae-kitchen/itamae/pull/351)
10
+
11
+ ## v1.12.6
12
+ [full changelog](https://github.com/itamae-kitchen/itamae/compare/v1.12.5...v1.12.6)
13
+
14
+ Bugfixes
15
+
16
+ - [Support Psych4.x](https://github.com/itamae-kitchen/itamae/pull/347)
17
+
18
+ ## v1.12.5
19
+ [full changelog](https://github.com/itamae-kitchen/itamae/compare/v1.12.4...v1.12.5)
20
+
21
+ Bugfixes
22
+
23
+ - [Define exit_on_failure? to suppress thor's warning](https://github.com/itamae-kitchen/itamae/pull/344)
3
24
 
4
25
  ## v1.12.4
5
26
  [full changelog](https://github.com/itamae-kitchen/itamae/compare/v1.12.3...v1.12.4)
data/Rakefile CHANGED
@@ -21,7 +21,7 @@ namespace :spec do
21
21
  namespace :integration do
22
22
  container_name = 'itamae'
23
23
 
24
- task :all => ['spec:integration:docker' 'spec:integration:local']
24
+ task :all => ['spec:integration:docker', 'spec:integration:local']
25
25
 
26
26
  desc "Run provision and specs"
27
27
  task :docker => ["docker:boot", "docker:provision", "docker:serverspec", 'docker:clean_docker_container']
data/bin/itamae CHANGED
@@ -2,4 +2,3 @@
2
2
 
3
3
  require 'itamae/cli'
4
4
  Itamae::CLI.start
5
-
data/itamae.gemspec CHANGED
@@ -26,7 +26,7 @@ Gem::Specification.new do |spec|
26
26
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
27
27
  spec.require_paths = ["lib"]
28
28
 
29
- spec.add_runtime_dependency "thor"
29
+ spec.add_runtime_dependency "thor", ">= 1.0.0"
30
30
  spec.add_runtime_dependency "specinfra", [">= 2.64.0", "< 3.0.0"]
31
31
  spec.add_runtime_dependency "hashie"
32
32
  spec.add_runtime_dependency "ansi"
data/lib/itamae/cli.rb CHANGED
@@ -14,8 +14,8 @@ module Itamae
14
14
 
15
15
  def self.define_exec_options
16
16
  option :recipe_graph, type: :string, desc: "[EXPERIMENTAL] Write recipe dependency graph in DOT", banner: "PATH"
17
- option :node_json, type: :string, aliases: ['-j']
18
- option :node_yaml, type: :string, aliases: ['-y']
17
+ option :node_json, type: :string, aliases: ['-j'], repeatable: true
18
+ option :node_yaml, type: :string, aliases: ['-y'], repeatable: true
19
19
  option :dry_run, type: :boolean, aliases: ['-n']
20
20
  option :shell, type: :string, default: "/bin/sh"
21
21
  option :login_shell, type: :boolean, default: false
@@ -31,11 +31,15 @@ module Itamae
31
31
  def self.options
32
32
  @itamae_options ||= super.dup.tap do |options|
33
33
  if config = options[:config]
34
- options.merge!(YAML.load_file(config))
34
+ options.merge!(YAML.respond_to?(:unsafe_load) ? YAML.unsafe_load(config) : YAML.load(config))
35
35
  end
36
36
  end
37
37
  end
38
38
 
39
+ def self.exit_on_failure?
40
+ true
41
+ end
42
+
39
43
  desc "local RECIPE [RECIPE...]", "Run Itamae locally"
40
44
  define_exec_options
41
45
  def local(*recipe_files)
data/lib/itamae/runner.rb CHANGED
@@ -91,8 +91,10 @@ module Itamae
91
91
  end
92
92
 
93
93
  private
94
+
94
95
  def create_node
95
96
  hash = {}
97
+ hash.extend(Hashie::Extensions::DeepMerge)
96
98
 
97
99
  if @options[:ohai]
98
100
  unless @backend.run_command("which ohai", error: false).exit_status == 0
@@ -105,19 +107,23 @@ module Itamae
105
107
  hash.merge!(JSON.parse(@backend.run_command("ohai 2>/dev/null").stdout))
106
108
  end
107
109
 
108
- if @options[:node_json]
109
- path = File.expand_path(@options[:node_json])
110
+ @options.fetch(:node_json, []).each do |name|
111
+ path = File.expand_path(name)
110
112
  Itamae.logger.info "Loading node data from #{path}..."
111
- hash.merge!(JSON.load(open(path)))
113
+
114
+ hash.deep_merge!(JSON.parse(File.read(path)))
112
115
  end
113
116
 
114
- if @options[:node_yaml]
115
- path = File.expand_path(@options[:node_yaml])
117
+ @options.fetch(:node_yaml, []).each do |name|
118
+ path = File.expand_path(name)
116
119
  Itamae.logger.info "Loading node data from #{path}..."
117
- hash.merge!(YAML.load(open(path)) || {})
120
+
121
+ yaml = YAML.respond_to?(:unsafe_load) ? YAML.unsafe_load(File.read(path)) : YAML.load(File.read(path))
122
+ hash.deep_merge!(yaml || {})
118
123
  end
119
124
 
120
- Node.new(hash, @backend)
125
+ # 'hash.dup' ensures that we pass a pristine Hash object without Hashie extensions
126
+ Node.new(hash.dup, @backend)
121
127
  end
122
128
 
123
129
  def prepare_handler
@@ -1,3 +1,3 @@
1
1
  module Itamae
2
- VERSION = "1.12.4"
2
+ VERSION = "1.13.0"
3
3
  end
@@ -28,5 +28,49 @@ module Itamae
28
28
  described_class.run(recipes, :local, {})
29
29
  end
30
30
  end
31
+
32
+ describe "#initialize" do
33
+ context "with multiple node_json and node_yaml files" do
34
+ def build_temp_file(data)
35
+ file = Tempfile.new
36
+ file.write data
37
+ file.close
38
+ file
39
+ end
40
+
41
+ it "merges hashes and overwrites arrays" do
42
+ json_one = build_temp_file %({ "vars_from_json": { "one": 1 }, "shared": { "foo": true } })
43
+ json_two = build_temp_file %({ "vars_from_json": { "two": 2 } })
44
+ yaml_one = build_temp_file %(
45
+ vars_from_yaml:
46
+ three: 3
47
+ array:
48
+ - 123
49
+ shared:
50
+ bar: false
51
+ )
52
+ yaml_two = build_temp_file %(
53
+ vars_from_yaml:
54
+ four: 4
55
+ array:
56
+ - 456
57
+ )
58
+
59
+ runner = described_class.new(
60
+ spy,
61
+ node_json: [json_one.path, json_two.path],
62
+ node_yaml: [yaml_one.path, yaml_two.path]
63
+ )
64
+
65
+ expect(runner.node[:vars_from_json][:one]).to eq 1
66
+ expect(runner.node[:vars_from_json][:two]).to eq 2
67
+ expect(runner.node[:vars_from_yaml][:three]).to eq 3
68
+ expect(runner.node[:vars_from_yaml][:four]).to eq 4
69
+ expect(runner.node[:array]).to eq [456]
70
+ expect(runner.node[:shared][:foo]).to eq true
71
+ expect(runner.node[:shared][:bar]).to eq false
72
+ end
73
+ end
74
+ end
31
75
  end
32
76
  end
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.12.4
4
+ version: 1.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryota Arai
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2021-12-14 00:00:00.000000000 Z
13
+ date: 2022-05-24 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: thor
@@ -18,14 +18,14 @@ dependencies:
18
18
  requirements:
19
19
  - - ">="
20
20
  - !ruby/object:Gem::Version
21
- version: '0'
21
+ version: 1.0.0
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
26
  - - ">="
27
27
  - !ruby/object:Gem::Version
28
- version: '0'
28
+ version: 1.0.0
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: specinfra
31
31
  requirement: !ruby/object:Gem::Requirement
@@ -331,7 +331,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
331
331
  - !ruby/object:Gem::Version
332
332
  version: '0'
333
333
  requirements: []
334
- rubygems_version: 3.2.32
334
+ rubygems_version: 3.2.22
335
335
  signing_key:
336
336
  specification_version: 4
337
337
  summary: Simple Configuration Management Tool