itamae 1.10.5 → 1.10.10

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: 93fef6667e949b9833a0d5f44b09982bbb0c6415ec44c57baa8e0f27eab322e8
4
- data.tar.gz: b772ed894784fdbb1c739f4b75a6af0bc0adb5a88b009fd87d0dbca8d39e8077
3
+ metadata.gz: a27b553f519a4e36fdc40534d8033528f3dfbbca42133fed38c8af9bafc0234c
4
+ data.tar.gz: d3b9da92d9ebaa0c4f3ceff9f483944e1fa02d2a28741c921c3b16f283b083cf
5
5
  SHA512:
6
- metadata.gz: 38cb17e76859562485e7f2520fb6eacafd442b3e73cd30c4b8b1c0bf883f9c838c5d57c9978314a08fde591bfdac6b1ee5d52ad26c40b4374744e8cc22d5d716
7
- data.tar.gz: 16d2e0043cbc92b65882c4d5d3684cd82e60fe09d59f7c30f7e995942475b4bbd74383cde73c4188fc387966a654578d3a540865d65e04e5210d6772c1770a43
6
+ metadata.gz: 5cf3758a3778d8a22128d08263f03bbf10c2ea53246128013786bda0c44549a14b89792798db43e5de573264fe06a5c3e8049cf52837db46d086e84f528c10c6
7
+ data.tar.gz: 86f33c85a7deed7cb93993abe8e811e0dd6e84861350ac48f7fae462a6fdca9e3c9b9a1c6ccf8438af326fc77829a5f0eb1d4e848aed6efe36d29739393467f3
@@ -8,13 +8,13 @@ rvm:
8
8
  - 2.4
9
9
  - 2.5
10
10
  - 2.6
11
+ - 2.7
11
12
  - ruby-head
12
13
  bundler_args: "--jobs=4 --retry=3"
13
14
  cache:
14
15
  bundler: true
15
16
 
16
17
  before_install:
17
- - travis_retry gem update --system || travis_retry gem update --system 2.7.8
18
18
  - travis_retry gem install bundler --no-document || travis_retry gem install bundler --no-document -v 1.17.3
19
19
 
20
20
  script:
@@ -29,6 +29,8 @@ matrix:
29
29
  include:
30
30
  - rvm: 2.6
31
31
  env: SPEC_RUBYOPT="--jit"
32
+ - rvm: 2.7
33
+ env: SPEC_RUBYOPT="--jit"
32
34
  - rvm: ruby-head
33
35
  env: SPEC_RUBYOPT="--jit"
34
36
  branches:
@@ -1,5 +1,42 @@
1
1
  ## Unreleased
2
- [full changelog](https://github.com/itamae-kitchen/itamae/compare/v1.10.5...master)
2
+ [full changelog](https://github.com/itamae-kitchen/itamae/compare/v1.10.10...master)
3
+
4
+ ## v1.10.10
5
+ [full changelog](https://github.com/itamae-kitchen/itamae/compare/v1.10.9...v1.10.10)
6
+
7
+ Improvements
8
+
9
+ - [Make output unbuffered](https://github.com/itamae-kitchen/itamae/pull/317)
10
+
11
+ ## v1.10.9
12
+ [full changelog](https://github.com/itamae-kitchen/itamae/compare/v1.10.8...v1.10.9)
13
+
14
+ Improvements
15
+
16
+ - [Fix CRLF problem in windows](https://github.com/itamae-kitchen/itamae/pull/316)
17
+
18
+ ## v1.10.8
19
+ [full changelog](https://github.com/itamae-kitchen/itamae/compare/v1.10.7...v1.10.8)
20
+
21
+ Improvements
22
+
23
+ - [Print "(in action_XXX)" as a debug log](https://github.com/itamae-kitchen/itamae/pull/315)
24
+ - [Reduce `check_package_is_installed` calling when package version is not specified](https://github.com/itamae-kitchen/itamae/pull/314)
25
+ - [Simplify Git resource's get_revision method](https://github.com/itamae-kitchen/itamae/pull/313)
26
+
27
+ ## v1.10.7
28
+ [full changelog](https://github.com/itamae-kitchen/itamae/compare/v1.10.6...v1.10.7)
29
+
30
+ Improvements
31
+
32
+ - [Improve `file` resource performance](https://github.com/itamae-kitchen/itamae/pull/310)
33
+
34
+ ## v1.10.6
35
+ [full changelog](https://github.com/itamae-kitchen/itamae/compare/v1.10.5...v1.10.6)
36
+
37
+ Improvements
38
+
39
+ - [Don't use `sudo` when `--no-sudo` is passed](https://github.com/itamae-kitchen/itamae/pull/302)
3
40
 
4
41
  ## v1.10.5
5
42
  [full changelog](https://github.com/itamae-kitchen/itamae/compare/v1.10.4...v1.10.5)
data/README.md CHANGED
@@ -77,7 +77,7 @@ $ bundle exec rake spec
77
77
 
78
78
  ## Get Involved
79
79
 
80
- - [Join Slack team](https://join.slack.com/t/itamae/shared_invite/enQtNTExNTI3ODM1NTY5LTM5MWJlZTgwODE0YTUwMThiNzZjN2I1MGNlZjE2NjlmNzg5NTNlOTliMDhkNDNmNTQ2ZTgwMzZjNjI5NDJiZGI)
80
+ - [Join Slack team](https://itamae-slackin.herokuapp.com)
81
81
 
82
82
  ## Presentations / Articles
83
83
 
data/Rakefile CHANGED
@@ -81,3 +81,4 @@ namespace :spec do
81
81
  end
82
82
  end
83
83
 
84
+ task :default => :spec
@@ -188,7 +188,7 @@ module Itamae
188
188
  end
189
189
 
190
190
  user = options[:user]
191
- if user
191
+ if user && use_sudo?
192
192
  command = "cd ~#{user.shellescape} ; #{command}"
193
193
  command = "sudo -H -u #{user.shellescape} -- #{shell.shellescape} -c #{command.shellescape}"
194
194
  end
@@ -196,6 +196,11 @@ module Itamae
196
196
  command
197
197
  end
198
198
 
199
+ def use_sudo?
200
+ return true unless @options.key?(:sudo)
201
+ !!@options[:sudo]
202
+ end
203
+
199
204
  def shell
200
205
  @options[:shell] || '/bin/sh'
201
206
  end
@@ -126,6 +126,7 @@ module Itamae
126
126
  @logger = ::Logger.new($stdout).tap do |l|
127
127
  l.formatter = Itamae::Logger::Formatter.new
128
128
  end.extend(Itamae::Logger::Helper)
129
+ $stdout.sync = true
129
130
 
130
131
  class << self
131
132
  def logger
@@ -195,6 +195,7 @@ module Itamae
195
195
  show_differences
196
196
 
197
197
  method_name = "action_#{action}"
198
+ Itamae.logger.debug "(in #{method_name})"
198
199
  if runner.dry_run?
199
200
  unless respond_to?(method_name)
200
201
  Itamae.logger.error "action #{action.inspect} is unavailable"
@@ -9,6 +9,10 @@ module Itamae
9
9
  define_attribute :group, type: String
10
10
  define_attribute :block, type: Proc, default: proc {}
11
11
 
12
+ class << self
13
+ attr_accessor :sha256sum_available
14
+ end
15
+
12
16
  def pre_action
13
17
  current.exist = run_specinfra(:check_file_is_file, attributes.path)
14
18
 
@@ -27,6 +31,11 @@ module Itamae
27
31
  end
28
32
  end
29
33
 
34
+ if exists_and_not_modified?
35
+ attributes.modified = false
36
+ return
37
+ end
38
+
30
39
  send_tempfile
31
40
  compare_file
32
41
  end
@@ -133,6 +142,19 @@ module Itamae
133
142
  end
134
143
  end
135
144
 
145
+ def exists_and_not_modified?
146
+ return false unless current.exist && sha256sum_available?
147
+
148
+ current_digest = run_command(["sha256sum", attributes.path]).stdout.split(/\s/, 2).first
149
+ digest = if content_file
150
+ Digest::SHA256.file(content_file).hexdigest
151
+ else
152
+ Digest::SHA256.hexdigest(attributes.content.to_s)
153
+ end
154
+
155
+ current_digest == digest
156
+ end
157
+
136
158
  def show_content_diff
137
159
  if attributes.modified
138
160
  Itamae.logger.info "diff:"
@@ -171,7 +193,12 @@ module Itamae
171
193
  src = if content_file
172
194
  content_file
173
195
  else
174
- f = Tempfile.open('itamae')
196
+ f =
197
+ if Gem.win_platform?
198
+ Tempfile.open('itamae', :mode=>IO::BINARY)
199
+ else
200
+ Tempfile.open('itamae')
201
+ end
175
202
  f.write(attributes.content)
176
203
  f.close
177
204
  f.path
@@ -194,6 +221,12 @@ module Itamae
194
221
  f.unlink if f
195
222
  end
196
223
  end
224
+
225
+ def sha256sum_available?
226
+ return self.class.sha256sum_available unless self.class.sha256sum_available.nil?
227
+
228
+ self.class.sha256sum_available = run_command(["sha256sum", "--version"], error: false).exit_status == 0
229
+ end
197
230
  end
198
231
  end
199
232
  end
@@ -84,11 +84,11 @@ module Itamae
84
84
  end
85
85
 
86
86
  def get_revision(branch)
87
- result = run_command_in_repo("git rev-list #{shell_escape(branch)}", error: false)
88
- unless result.exit_status == 0
89
- fetch_origin!
90
- end
91
- run_command_in_repo("git rev-list #{shell_escape(branch)}").stdout.lines.first.strip
87
+ result = run_command_in_repo("git rev-parse #{shell_escape(branch)}", error: false)
88
+ return result.stdout.strip if result.exit_status == 0
89
+
90
+ fetch_origin!
91
+ run_command_in_repo("git rev-parse #{shell_escape(branch)}").stdout.strip
92
92
  end
93
93
 
94
94
  def fetch_origin!
@@ -24,6 +24,8 @@ module Itamae
24
24
  end
25
25
 
26
26
  def action_install(action_options)
27
+ return if !attributes.version && current.installed
28
+
27
29
  unless run_specinfra(:check_package_is_installed, attributes.name, attributes.version)
28
30
  run_specinfra(:install_package, attributes.name, attributes.version, attributes.options)
29
31
  updated!
@@ -31,7 +33,7 @@ module Itamae
31
33
  end
32
34
 
33
35
  def action_remove(action_options)
34
- if run_specinfra(:check_package_is_installed, attributes.name, nil)
36
+ if current.installed
35
37
  run_specinfra(:remove_package, attributes.name, attributes.options)
36
38
  updated!
37
39
  end
@@ -1,3 +1,3 @@
1
1
  module Itamae
2
- VERSION = "1.10.5"
2
+ VERSION = "1.10.10"
3
3
  end
@@ -104,7 +104,7 @@ describe file('/tmp/http_request_headers.html') do
104
104
  its(:content) { should match(/"User-Agent":\s*"Itamae"/) }
105
105
  end
106
106
 
107
- describe file('/tmp/http_request_redirect.html') do
107
+ xdescribe file('/tmp/http_request_redirect.html') do
108
108
  it { should be_file }
109
109
  its(:content) { should match(/"from":\s*"itamae"/) }
110
110
  end
@@ -210,10 +210,10 @@ http_request "/tmp/http_request_headers.html" do
210
210
  url "https://httpbin.org/get"
211
211
  end
212
212
 
213
- http_request "/tmp/http_request_redirect.html" do
214
- redirect_limit 1
215
- url "https://httpbin.org/redirect-to?url=https%3A%2F%2Fhttpbin.org%2Fget%3Ffrom%3Ditamae"
216
- end
213
+ # http_request "/tmp/http_request_redirect.html" do
214
+ # redirect_limit 1
215
+ # url "https://httpbin.org/redirect-to?url=https%3A%2F%2Fhttpbin.org%2Fget%3Ffrom%3Ditamae"
216
+ # end
217
217
 
218
218
  link "/tmp-link" do
219
219
  to "/tmp"
@@ -17,38 +17,38 @@ module Itamae
17
17
 
18
18
  describe ".send_file" do
19
19
  context "the source file doesn't exist" do
20
- subject { -> { itamae_backend.send_file("src", "dst") } }
21
- it { expect(subject).to raise_error(Itamae::Backend::SourceNotExistError, "The file 'src' doesn't exist.") }
20
+ subject { itamae_backend.send_file("src", "dst") }
21
+ it { expect{ subject }.to raise_error(Itamae::Backend::SourceNotExistError, "The file 'src' doesn't exist.") }
22
22
  end
23
23
 
24
24
  context "the source file exist, but it is not a regular file" do
25
25
  before { Dir.mkdir("src") }
26
- subject { -> { itamae_backend.send_file("src", "dst") } }
27
- it { expect(subject).to raise_error(Itamae::Backend::SourceNotExistError, "'src' is not a file.") }
26
+ subject { itamae_backend.send_file("src", "dst") }
27
+ it { expect{ subject }.to raise_error(Itamae::Backend::SourceNotExistError, "'src' is not a file.") }
28
28
  end
29
29
 
30
30
  context "the source file is a regular file" do
31
31
  before { FileUtils.touch("src") }
32
- subject { -> { itamae_backend.send_file("src", "dst") } }
32
+ subject { itamae_backend.send_file("src", "dst") }
33
33
  it { expect { subject }.not_to raise_error }
34
34
  end
35
35
  end
36
36
 
37
37
  describe ".send_directory" do
38
38
  context "the source directory doesn't exist" do
39
- subject { -> { itamae_backend.send_directory("src", "dst") } }
40
- it { expect(subject).to raise_error(Itamae::Backend::SourceNotExistError, "The directory 'src' doesn't exist.") }
39
+ subject { itamae_backend.send_directory("src", "dst") }
40
+ it { expect{ subject }.to raise_error(Itamae::Backend::SourceNotExistError, "The directory 'src' doesn't exist.") }
41
41
  end
42
42
 
43
43
  context "the source directory exist, but it is not a directory" do
44
44
  before { FileUtils.touch("src") }
45
- subject { -> { itamae_backend.send_directory("src", "dst") } }
46
- it { expect(subject).to raise_error(Itamae::Backend::SourceNotExistError, "'src' is not a directory.") }
45
+ subject { itamae_backend.send_directory("src", "dst") }
46
+ it { expect{ subject }.to raise_error(Itamae::Backend::SourceNotExistError, "'src' is not a directory.") }
47
47
  end
48
48
 
49
49
  context "the source directory is a directory" do
50
50
  before { Dir.mkdir("src") }
51
- subject { -> { itamae_backend.send_directory("src", "dst") } }
51
+ subject { itamae_backend.send_directory("src", "dst") }
52
52
  it { expect { subject }.not_to raise_error }
53
53
  end
54
54
  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.10.5
4
+ version: 1.10.10
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: 2019-07-27 00:00:00.000000000 Z
13
+ date: 2020-07-07 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: thor
@@ -329,7 +329,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
329
329
  - !ruby/object:Gem::Version
330
330
  version: '0'
331
331
  requirements: []
332
- rubygems_version: 3.0.1
332
+ rubygems_version: 3.0.3
333
333
  signing_key:
334
334
  specification_version: 4
335
335
  summary: Simple Configuration Management Tool