itamae 1.10.4 → 1.10.9
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 +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +6 -4
- data/CHANGELOG.md +38 -1
- data/README.md +1 -1
- data/Rakefile +1 -0
- data/lib/itamae/backend.rb +6 -1
- data/lib/itamae/resource/base.rb +1 -0
- data/lib/itamae/resource/file.rb +34 -1
- data/lib/itamae/resource/git.rb +5 -5
- data/lib/itamae/resource/http_request.rb +12 -2
- data/lib/itamae/resource/package.rb +3 -1
- data/lib/itamae/version.rb +1 -1
- data/spec/integration/recipes/local.rb +1 -3
- data/spec/unit/lib/itamae/backend_spec.rb +10 -10
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b1e0ffadc899b7ad59eeb372ad485595d898fdf11e5f279de47444288979ebc
|
4
|
+
data.tar.gz: d2828953d4691b589fd18764b29f3e8c70b8acf0cfc228b661e2b219784b6216
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 14cb2f5ad0ae3a821da90bd47269fb8eec3310f1d0b51cde4157db7de48bec0103e02e8d88e05c0a86e760b79c20bbe52abe8aa2180b7486db8bcc6c9f429134
|
7
|
+
data.tar.gz: 453a4f3d089ec55b0241c228873c5afed2bfe2b5a6ac63e9d0dae7a159ce9853cfea83e7153298385e91c4740ce32199ceb49ae2f99008cefe2f2e5b9253ed5f
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -8,17 +8,17 @@ 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:
|
21
|
-
- bundle exec rake spec
|
21
|
+
- RUBYOPT=$SPEC_RUBYOPT bundle exec rake spec
|
22
22
|
notifications:
|
23
23
|
email: false
|
24
24
|
slack:
|
@@ -28,9 +28,11 @@ matrix:
|
|
28
28
|
- rvm: ruby-head
|
29
29
|
include:
|
30
30
|
- rvm: 2.6
|
31
|
-
env:
|
31
|
+
env: SPEC_RUBYOPT="--jit"
|
32
|
+
- rvm: 2.7
|
33
|
+
env: SPEC_RUBYOPT="--jit"
|
32
34
|
- rvm: ruby-head
|
33
|
-
env:
|
35
|
+
env: SPEC_RUBYOPT="--jit"
|
34
36
|
branches:
|
35
37
|
only:
|
36
38
|
- master
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,42 @@
|
|
1
1
|
## Unreleased
|
2
|
-
[full changelog](https://github.com/itamae-kitchen/itamae/compare/v1.10.
|
2
|
+
[full changelog](https://github.com/itamae-kitchen/itamae/compare/v1.10.9...master)
|
3
|
+
|
4
|
+
## v1.10.9
|
5
|
+
[full changelog](https://github.com/itamae-kitchen/itamae/compare/v1.10.8...v1.10.9)
|
6
|
+
|
7
|
+
Improvements
|
8
|
+
|
9
|
+
- [Fix CRLF problem in windows](https://github.com/itamae-kitchen/itamae/pull/316)
|
10
|
+
|
11
|
+
## v1.10.8
|
12
|
+
[full changelog](https://github.com/itamae-kitchen/itamae/compare/v1.10.7...v1.10.8)
|
13
|
+
|
14
|
+
Improvements
|
15
|
+
|
16
|
+
- [Print "(in action_XXX)" as a debug log](https://github.com/itamae-kitchen/itamae/pull/315)
|
17
|
+
- [Reduce `check_package_is_installed` calling when package version is not specified](https://github.com/itamae-kitchen/itamae/pull/314)
|
18
|
+
- [Simplify Git resource's get_revision method](https://github.com/itamae-kitchen/itamae/pull/313)
|
19
|
+
|
20
|
+
## v1.10.7
|
21
|
+
[full changelog](https://github.com/itamae-kitchen/itamae/compare/v1.10.6...v1.10.7)
|
22
|
+
|
23
|
+
Improvements
|
24
|
+
|
25
|
+
- [Improve `file` resource performance](https://github.com/itamae-kitchen/itamae/pull/310)
|
26
|
+
|
27
|
+
## v1.10.6
|
28
|
+
[full changelog](https://github.com/itamae-kitchen/itamae/compare/v1.10.5...v1.10.6)
|
29
|
+
|
30
|
+
Improvements
|
31
|
+
|
32
|
+
- [Don't use `sudo` when `--no-sudo` is passed](https://github.com/itamae-kitchen/itamae/pull/302)
|
33
|
+
|
34
|
+
## v1.10.5
|
35
|
+
[full changelog](https://github.com/itamae-kitchen/itamae/compare/v1.10.4...v1.10.5)
|
36
|
+
|
37
|
+
Improvements
|
38
|
+
|
39
|
+
- [Check http status code in `http_request` resource (by @takumin)](https://github.com/itamae-kitchen/itamae/pull/296)
|
3
40
|
|
4
41
|
## v1.10.4
|
5
42
|
[full changelog](https://github.com/itamae-kitchen/itamae/compare/v1.10.3...v1.10.4)
|
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://
|
80
|
+
- [Join Slack team](https://itamae-slackin.herokuapp.com)
|
81
81
|
|
82
82
|
## Presentations / Articles
|
83
83
|
|
data/Rakefile
CHANGED
data/lib/itamae/backend.rb
CHANGED
@@ -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
|
data/lib/itamae/resource/base.rb
CHANGED
data/lib/itamae/resource/file.rb
CHANGED
@@ -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 =
|
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
|
data/lib/itamae/resource/git.rb
CHANGED
@@ -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-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
run_command_in_repo("git rev-
|
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!
|
@@ -5,6 +5,9 @@ module Itamae
|
|
5
5
|
module Resource
|
6
6
|
class HttpRequest < File
|
7
7
|
RedirectLimitExceeded = Class.new(StandardError)
|
8
|
+
HTTPClientError = Class.new(StandardError)
|
9
|
+
HTTPServerError = Class.new(StandardError)
|
10
|
+
HTTPUnknownError = Class.new(StandardError)
|
8
11
|
|
9
12
|
alias_method :_action_create, :action_create
|
10
13
|
undef_method :action_create, :action_delete, :action_edit
|
@@ -48,7 +51,10 @@ module Itamae
|
|
48
51
|
response = http.method(attributes.action).call(uri.request_uri, attributes.message, attributes.headers)
|
49
52
|
end
|
50
53
|
|
51
|
-
|
54
|
+
case response
|
55
|
+
when Net::HTTPSuccess
|
56
|
+
break
|
57
|
+
when Net::HTTPRedirection
|
52
58
|
if redirects_followed < attributes.redirect_limit
|
53
59
|
uri = URI.parse(response["location"])
|
54
60
|
redirects_followed += 1
|
@@ -56,8 +62,12 @@ module Itamae
|
|
56
62
|
else
|
57
63
|
raise RedirectLimitExceeded
|
58
64
|
end
|
65
|
+
when Net::HTTPClientError
|
66
|
+
raise HTTPClientError
|
67
|
+
when Net::HTTPServerError
|
68
|
+
raise HTTPServerError
|
59
69
|
else
|
60
|
-
|
70
|
+
raise HTTPUnknownError
|
61
71
|
end
|
62
72
|
end
|
63
73
|
|
@@ -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
|
36
|
+
if current.installed
|
35
37
|
run_specinfra(:remove_package, attributes.name, attributes.options)
|
36
38
|
updated!
|
37
39
|
end
|
data/lib/itamae/version.rb
CHANGED
@@ -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 {
|
21
|
-
it { expect
|
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 {
|
27
|
-
it { expect
|
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 {
|
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 {
|
40
|
-
it { expect
|
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 {
|
46
|
-
it { expect
|
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 {
|
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.
|
4
|
+
version: 1.10.9
|
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:
|
13
|
+
date: 2020-06-04 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.
|
332
|
+
rubygems_version: 3.1.2
|
333
333
|
signing_key:
|
334
334
|
specification_version: 4
|
335
335
|
summary: Simple Configuration Management Tool
|