itamae 1.12.6 → 1.14.0

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: e18a63f707a8c5e6553adf7548c3467e704f59a845a81292385a34c14ae4462b
4
- data.tar.gz: 8d159da6ad0674a343f521a0cbc721ccd5016e6e394489724f18381c4c04edfa
3
+ metadata.gz: debb90e8d8638159b905091113dcc1ad56712b698106eb2d203b1f0e1200a62b
4
+ data.tar.gz: 4fa5db8123957e48ed172858de9d5decb08bb05838b1eafd119d0427915d703d
5
5
  SHA512:
6
- metadata.gz: 236c31793aef48956d4d04b92ac7dd09076d7f3a33a9f7eefc943fe74beebc8914f4aa05630c104dc35f11b2b70e6504409b4469a8b436d5d2d476482439dc90
7
- data.tar.gz: fcb7322c39beba8614cdc88383a9b1ece9626f5318a717f323c9420ecc57e29f9e6dd28285df42588fe9a8abdb6899b1121eba6a2ba53269e2ba615a4affaf1b
6
+ metadata.gz: 550f1580b5fc523622247738a3e3cbbc0a61996144f3f8a088f05ea2f061154fb4e1e20ea598d4a62891bb99234b1ef45c8867c191ddf5aa5a285d2410e70192
7
+ data.tar.gz: b99054cf2c631b478bdbe18879d4db7d4e61d5d4864745c29e54d06d8f12c9f78ceae8cf484857d8e7ce7d3a9c5674985f0d536a3f26db5e2c21fa68989d98b4
@@ -93,9 +93,11 @@ jobs:
93
93
  - "2.6"
94
94
  - "2.7"
95
95
  - "3.0"
96
+ - "3.1"
96
97
  rubyopt:
97
98
  - ""
98
99
  - "--jit"
100
+ - "--yjit"
99
101
  image:
100
102
  - ubuntu:trusty
101
103
  exclude:
@@ -106,6 +108,19 @@ jobs:
106
108
  rubyopt: "--jit"
107
109
  - ruby: "2.5"
108
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"
109
124
 
110
125
  env:
111
126
  RUBYOPT: ${{ matrix.rubyopt }}
@@ -156,9 +171,11 @@ jobs:
156
171
  - "2.6"
157
172
  - "2.7"
158
173
  - "3.0"
174
+ - "3.1"
159
175
  rubyopt:
160
176
  - ""
161
177
  - "--jit"
178
+ - "--yjit"
162
179
  exclude:
163
180
  # --jit is available since MRI 2.6
164
181
  - ruby: "2.3"
@@ -167,6 +184,19 @@ jobs:
167
184
  rubyopt: "--jit"
168
185
  - ruby: "2.5"
169
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"
170
200
 
171
201
  env:
172
202
  RUBYOPT: ${{ matrix.rubyopt }}
data/CHANGELOG.md CHANGED
@@ -1,12 +1,34 @@
1
1
  ## Unreleased
2
- [full changelog](https://github.com/itamae-kitchen/itamae/compare/v1.12.6...master)
2
+ [full changelog](https://github.com/itamae-kitchen/itamae/compare/v1.14.0...master)
3
+
4
+ # v1.14.0
5
+ [full changelog](https://github.com/itamae-kitchen/itamae/compare/v1.13.1...v1.14.0)
6
+
7
+ Bugfixes
8
+
9
+ - [Execute local_ruby_block code inside of chdir-ed block if cwd presented](https://github.com/itamae-kitchen/itamae/pull/355)
10
+
11
+
12
+ ## v1.13.1
13
+ [full changelog](https://github.com/itamae-kitchen/itamae/compare/v1.13.0...v1.13.1)
14
+
15
+ Improvements
16
+
17
+ - [Made MFA mandatory for gem releases](https://github.com/itamae-kitchen/itamae/pull/354)
18
+
19
+ ## v1.13.0
20
+ [full changelog](https://github.com/itamae-kitchen/itamae/compare/v1.12.6...v1.13.0)
21
+
22
+ Improvements
23
+
24
+ - [Support repeatable "node_json" and "node_yaml" options](https://github.com/itamae-kitchen/itamae/pull/351)
3
25
 
4
26
  ## v1.12.6
5
27
  [full changelog](https://github.com/itamae-kitchen/itamae/compare/v1.12.5...v1.12.6)
6
28
 
7
29
  Bugfixes
8
30
 
9
- - [Support Psych4.x](https://github.com/itamae-kitchen/itamae/pull/348)
31
+ - [Support Psych4.x](https://github.com/itamae-kitchen/itamae/pull/347)
10
32
 
11
33
  ## v1.12.5
12
34
  [full changelog](https://github.com/itamae-kitchen/itamae/compare/v1.12.4...v1.12.5)
data/README.md CHANGED
@@ -33,7 +33,7 @@ service 'nginx' do
33
33
  end
34
34
  ```
35
35
 
36
- And then excute `itamae` command to apply a recipe to a local machine.
36
+ And then execute `itamae` command to apply a recipe to a local machine.
37
37
 
38
38
  ```
39
39
  $ itamae local recipe.rb
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/itamae.gemspec CHANGED
@@ -16,6 +16,7 @@ Gem::Specification.new do |spec|
16
16
  spec.metadata["homepage_uri"] = spec.homepage
17
17
  spec.metadata["source_code_uri"] = "https://github.com/itamae-kitchen/itamae"
18
18
  spec.metadata["changelog_uri"] = "https://github.com/itamae-kitchen/itamae/blob/master/CHANGELOG.md"
19
+ spec.metadata["rubygems_mfa_required"] = "true"
19
20
  else
20
21
  raise "RubyGems 2.0 or newer is required to protect against " \
21
22
  "public gem pushes."
@@ -26,7 +27,7 @@ Gem::Specification.new do |spec|
26
27
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
27
28
  spec.require_paths = ["lib"]
28
29
 
29
- spec.add_runtime_dependency "thor"
30
+ spec.add_runtime_dependency "thor", ">= 1.0.0"
30
31
  spec.add_runtime_dependency "specinfra", [">= 2.64.0", "< 3.0.0"]
31
32
  spec.add_runtime_dependency "hashie"
32
33
  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
@@ -5,7 +5,13 @@ module Itamae
5
5
  define_attribute :block, type: Proc
6
6
 
7
7
  def action_run(options)
8
- attributes.block.call
8
+ if attributes[:cwd]
9
+ Dir.chdir(attributes[:cwd]) do
10
+ attributes.block.call
11
+ end
12
+ else
13
+ attributes.block.call
14
+ end
9
15
  end
10
16
  end
11
17
  end
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,20 +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
- yaml = YAML.respond_to?(:unsafe_load) ? YAML.unsafe_load(open(path)) : YAML.load(open(path))
118
- hash.merge!(yaml || {})
120
+
121
+ yaml = YAML.respond_to?(:unsafe_load) ? YAML.unsafe_load(File.read(path)) : YAML.load(File.read(path))
122
+ hash.deep_merge!(yaml || {})
119
123
  end
120
124
 
121
- Node.new(hash, @backend)
125
+ # 'hash.dup' ensures that we pass a pristine Hash object without Hashie extensions
126
+ Node.new(hash.dup, @backend)
122
127
  end
123
128
 
124
129
  def prepare_handler
@@ -1,3 +1,3 @@
1
1
  module Itamae
2
- VERSION = "1.12.6"
2
+ VERSION = "1.14.0"
3
3
  end
@@ -527,6 +527,15 @@ local_ruby_block 'execute run_command' do
527
527
  end
528
528
  end
529
529
 
530
+ local_ruby_block "pwd with cwd attribute" do
531
+ cwd "/tmp"
532
+ block do
533
+ unless `pwd`.chomp == "/tmp"
534
+ raise "working directory mismatched"
535
+ end
536
+ end
537
+ end
538
+
530
539
  execute "touch /tmp/subscribed_from_parent" do
531
540
  action :nothing
532
541
  subscribes :run, 'execute[subscribed from parent]'
@@ -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.6
4
+ version: 1.14.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: 2022-04-18 00:00:00.000000000 Z
13
+ date: 2022-07-06 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
@@ -316,6 +316,7 @@ metadata:
316
316
  homepage_uri: https://itamae.kitchen/
317
317
  source_code_uri: https://github.com/itamae-kitchen/itamae
318
318
  changelog_uri: https://github.com/itamae-kitchen/itamae/blob/master/CHANGELOG.md
319
+ rubygems_mfa_required: 'true'
319
320
  post_install_message:
320
321
  rdoc_options: []
321
322
  require_paths: