itamae 1.9.2 → 1.9.3
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/CHANGELOG.md +8 -0
- data/lib/itamae/backend.rb +2 -2
- data/lib/itamae/resource/file.rb +3 -1
- data/lib/itamae/resource/http_request.rb +28 -10
- data/lib/itamae/version.txt +1 -1
- data/spec/integration/default_spec.rb +5 -0
- data/spec/integration/recipes/default.rb +5 -0
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 154b1597ae0505eec08966ce87e4481cebc99291
|
|
4
|
+
data.tar.gz: eaed49c1a0352814e22227999385e0668dc99320
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 749602fb374334e832b70aeadbae91dade0aaa0426747dc11394771c1cb4d4f00d78af4f290907659c15307e773c977e0fd7b4d6eaa72536248a9eca757b005d
|
|
7
|
+
data.tar.gz: 97c15caa14ea44d38898a2ec44c629a25a499855b5d16553e04fa431cc72dff470b7f8844e0b0fc31aff9d9abae51a8509a3263ec8c243b36b86c95baded7bc6
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
## v1.9.3
|
|
2
|
+
|
|
3
|
+
Improvements
|
|
4
|
+
|
|
5
|
+
- [Support redirect on http_request resource (by @hico-horiuchi)](https://github.com/itamae-kitchen/itamae/pull/190)
|
|
6
|
+
- [Use /bin/bash as default shell if shell is not set (by @hico-horiuchi)](https://github.com/itamae-kitchen/itamae/pull/192)
|
|
7
|
+
- [Stop replacing files which are not updated (by @KitaitiMakoto)](https://github.com/itamae-kitchen/itamae/pull/194)
|
|
8
|
+
|
|
1
9
|
## v1.9.2
|
|
2
10
|
|
|
3
11
|
Features
|
data/lib/itamae/backend.rb
CHANGED
|
@@ -36,7 +36,7 @@ module Itamae
|
|
|
36
36
|
|
|
37
37
|
class Base
|
|
38
38
|
attr_reader :executed_commands
|
|
39
|
-
|
|
39
|
+
|
|
40
40
|
def initialize(options)
|
|
41
41
|
@options = options
|
|
42
42
|
@backend = create_specinfra_backend
|
|
@@ -189,7 +189,7 @@ module Itamae
|
|
|
189
189
|
end
|
|
190
190
|
|
|
191
191
|
def shell
|
|
192
|
-
@options[:shell]
|
|
192
|
+
@options[:shell] || '/bin/sh'
|
|
193
193
|
end
|
|
194
194
|
|
|
195
195
|
def run_command_with_profiling(command)
|
data/lib/itamae/resource/file.rb
CHANGED
|
@@ -1,27 +1,45 @@
|
|
|
1
1
|
require 'itamae'
|
|
2
2
|
require 'uri'
|
|
3
|
-
require 'net/
|
|
3
|
+
require 'net/https'
|
|
4
4
|
|
|
5
5
|
module Itamae
|
|
6
6
|
module Resource
|
|
7
7
|
class HttpRequest < File
|
|
8
|
-
|
|
8
|
+
RedirectLimitExceeded = Class.new(StandardError)
|
|
9
9
|
|
|
10
10
|
define_attribute :action, default: :get
|
|
11
11
|
define_attribute :headers, type: Hash, default: {}
|
|
12
12
|
define_attribute :message, type: String, default: ""
|
|
13
|
+
define_attribute :redirect_limit, type: Integer, default: 10
|
|
13
14
|
define_attribute :url, type: String, required: true
|
|
14
15
|
|
|
15
16
|
def pre_action
|
|
16
17
|
uri = URI.parse(attributes.url)
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
18
|
+
response = nil
|
|
19
|
+
redirects_followed = 0
|
|
20
|
+
|
|
21
|
+
loop do
|
|
22
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
|
23
|
+
http.use_ssl = true if uri.scheme == "https"
|
|
24
|
+
|
|
25
|
+
case attributes.action
|
|
26
|
+
when :delete, :get, :options
|
|
27
|
+
response = http.method(attributes.action).call(uri.request_uri, attributes.headers)
|
|
28
|
+
when :post, :put
|
|
29
|
+
response = http.method(attributes.action).call(uri.request_uri, attributes.message, attributes.headers)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
if response.kind_of?(Net::HTTPRedirection)
|
|
33
|
+
if redirects_followed < attributes.redirect_limit
|
|
34
|
+
uri = URI.parse(response["location"])
|
|
35
|
+
redirects_followed += 1
|
|
36
|
+
Itamae.logger.debug "Following redirect #{redirects_followed}/#{attributes.redirect_limit}"
|
|
37
|
+
else
|
|
38
|
+
raise RedirectLimitExceeded
|
|
39
|
+
end
|
|
40
|
+
else
|
|
41
|
+
break
|
|
42
|
+
end
|
|
25
43
|
end
|
|
26
44
|
|
|
27
45
|
attributes.content = response.body
|
data/lib/itamae/version.txt
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.9.
|
|
1
|
+
1.9.3
|
|
@@ -101,6 +101,11 @@ describe file('/tmp/http_request_headers.html') do
|
|
|
101
101
|
its(:content) { should match(/"User-Agent": "Itamae"/) }
|
|
102
102
|
end
|
|
103
103
|
|
|
104
|
+
describe file('/tmp/http_request_redirect.html') do
|
|
105
|
+
it { should be_file }
|
|
106
|
+
its(:content) { should match(/"from": "itamae"/) }
|
|
107
|
+
end
|
|
108
|
+
|
|
104
109
|
describe file('/tmp/notifies') do
|
|
105
110
|
it { should be_file }
|
|
106
111
|
its(:content) { should eq("2431") }
|
|
@@ -186,6 +186,11 @@ http_request "/tmp/http_request_headers.html" do
|
|
|
186
186
|
url "https://httpbin.org/get"
|
|
187
187
|
end
|
|
188
188
|
|
|
189
|
+
http_request "/tmp/http_request_redirect.html" do
|
|
190
|
+
redirect_limit 1
|
|
191
|
+
url "https://httpbin.org/redirect-to?url=https%3A%2F%2Fhttpbin.org%2Fget%3Ffrom%3Ditamae"
|
|
192
|
+
end
|
|
193
|
+
|
|
189
194
|
######
|
|
190
195
|
|
|
191
196
|
service "cron" do
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: itamae
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.9.
|
|
4
|
+
version: 1.9.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ryota Arai
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2016-02-03 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: thor
|