itamae 1.9.6 → 1.9.7.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -4
- data/lib/itamae/logger.rb +3 -6
- data/lib/itamae/resource/file.rb +34 -31
- data/lib/itamae/resource/http_request.rb +26 -8
- data/lib/itamae/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 063ccd6fdae32d852d450265017ede39586ea176
|
4
|
+
data.tar.gz: e4456e84fc2421e01c86247f926aa6625f6921c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b88477096228dfad7451b746f41ccf727ee5ddf0b0da023d019e348467cd591e4f014cb4cd1417317599dbeb6e288e67657c775490db98b9064865e109d30191
|
7
|
+
data.tar.gz: e73bfa3cf90a183b5e6ef4931679d56bf88d420d0c946c591fda609a167c3fb4d8cb9298565b5d0cd142f09badc8226e3d697d73c8c68bb4a64c01fd955d3206
|
data/CHANGELOG.md
CHANGED
@@ -1,13 +1,20 @@
|
|
1
|
+
## v1.9.7 (pre)
|
2
|
+
|
3
|
+
Bugfixes
|
4
|
+
|
5
|
+
- [Mark a file as updated in dry-run mode (by @ryotarai)](https://github.com/itamae-kitchen/itamae/pull/208)
|
6
|
+
- [Do not surround LF with the ANSI escape sequence (by @daic-h)](https://github.com/itamae-kitchen/itamae/pull/209)
|
7
|
+
|
1
8
|
## v1.9.6
|
2
9
|
|
3
10
|
Features
|
4
11
|
|
5
|
-
- [Introduce `--detailed-exitcode` option.](https://github.com/itamae-kitchen/itamae/pull/206)
|
12
|
+
- [Introduce `--detailed-exitcode` option. (by @ryotarai)](https://github.com/itamae-kitchen/itamae/pull/206)
|
6
13
|
|
7
14
|
Bugfixes
|
8
15
|
|
9
|
-
- [If `git rev-list` fails, do `git fetch origin`](https://github.com/itamae-kitchen/itamae/pull/205)
|
10
|
-
- [If gid passed to user resource is a String, treat it as group name.](https://github.com/itamae-kitchen/itamae/pull/207)
|
16
|
+
- [If `git rev-list` fails, do `git fetch origin` (by @ryotarai)](https://github.com/itamae-kitchen/itamae/pull/205)
|
17
|
+
- [If gid passed to user resource is a String, treat it as group name. (by @ryotarai)](https://github.com/itamae-kitchen/itamae/pull/207)
|
11
18
|
|
12
19
|
## v1.9.5
|
13
20
|
|
@@ -48,7 +55,7 @@ Improvements
|
|
48
55
|
|
49
56
|
Features
|
50
57
|
|
51
|
-
- [Add `get`, `post`, `put`, `delete` and `options` actions to `http_request` resource](https://github.com/itamae-kitchen/itamae/pull/184)
|
58
|
+
- [Add `get`, `post`, `put`, `delete` and `options` actions to `http_request` resource (by @hico-horiuchi)](https://github.com/itamae-kitchen/itamae/pull/184)
|
52
59
|
|
53
60
|
## v1.9.0
|
54
61
|
|
data/lib/itamae/logger.rb
CHANGED
@@ -73,12 +73,9 @@ module Itamae
|
|
73
73
|
attr_accessor :colored
|
74
74
|
|
75
75
|
def call(severity, datetime, progname, msg)
|
76
|
-
log = "%s : %s
|
77
|
-
|
78
|
-
|
79
|
-
else
|
80
|
-
log
|
81
|
-
end
|
76
|
+
log = "%s : %s" % ["%5s" % severity, msg2str(msg)]
|
77
|
+
|
78
|
+
(colored ? colorize(log, severity) : log) + "\n"
|
82
79
|
end
|
83
80
|
|
84
81
|
def color(code)
|
data/lib/itamae/resource/file.rb
CHANGED
@@ -30,9 +30,11 @@ module Itamae
|
|
30
30
|
end
|
31
31
|
|
32
32
|
send_tempfile
|
33
|
+
compare_file
|
33
34
|
end
|
34
35
|
|
35
36
|
def set_current_attributes
|
37
|
+
current.modified = false
|
36
38
|
if current.exist
|
37
39
|
current.mode = run_specinfra(:get_file_mode, attributes.path).stdout.chomp
|
38
40
|
current.owner = run_specinfra(:get_file_owner_user, attributes.path).stdout.chomp
|
@@ -51,7 +53,7 @@ module Itamae
|
|
51
53
|
super
|
52
54
|
|
53
55
|
if @temppath && @current_action != :delete
|
54
|
-
|
56
|
+
show_content_diff
|
55
57
|
end
|
56
58
|
end
|
57
59
|
|
@@ -60,19 +62,7 @@ module Itamae
|
|
60
62
|
run_command(["touch", attributes.path])
|
61
63
|
end
|
62
64
|
|
63
|
-
|
64
|
-
if run_specinfra(:check_file_is_file, attributes.path)
|
65
|
-
unless check_command(["diff", "-q", @temppath, attributes.path])
|
66
|
-
# the file is modified
|
67
|
-
updated!
|
68
|
-
end
|
69
|
-
else
|
70
|
-
# new file
|
71
|
-
updated!
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
change_target = @temppath && updated? ? @temppath : attributes.path
|
65
|
+
change_target = attributes.modified ? @temppath : attributes.path
|
76
66
|
|
77
67
|
if attributes.mode
|
78
68
|
run_specinfra(:change_file_mode, change_target, attributes.mode)
|
@@ -82,7 +72,7 @@ module Itamae
|
|
82
72
|
run_specinfra(:change_file_owner, change_target, attributes.owner, attributes.group)
|
83
73
|
end
|
84
74
|
|
85
|
-
if
|
75
|
+
if attributes.modified
|
86
76
|
run_specinfra(:move_file, @temppath, attributes.path)
|
87
77
|
end
|
88
78
|
end
|
@@ -110,29 +100,39 @@ module Itamae
|
|
110
100
|
run_specinfra(:change_file_group, @temppath, group)
|
111
101
|
end
|
112
102
|
|
113
|
-
unless check_command(["diff", "-q", @temppath, attributes.path])
|
114
|
-
# the file is modified
|
115
|
-
updated!
|
116
|
-
end
|
117
|
-
|
118
103
|
run_specinfra(:move_file, @temppath, attributes.path)
|
119
104
|
end
|
120
105
|
|
121
106
|
private
|
122
107
|
|
123
|
-
def
|
124
|
-
|
125
|
-
|
126
|
-
else
|
127
|
-
'/dev/null'
|
128
|
-
end
|
129
|
-
|
130
|
-
diff = run_command(["diff", "-u", compare_to, @temppath], error: false)
|
131
|
-
if diff.exit_status == 0
|
132
|
-
# no change
|
133
|
-
Itamae.logger.debug "file content will not change"
|
108
|
+
def compare_to
|
109
|
+
if current.exist
|
110
|
+
attributes.path
|
134
111
|
else
|
112
|
+
'/dev/null'
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
def compare_file
|
117
|
+
attributes.modified = false
|
118
|
+
unless @temppath
|
119
|
+
return
|
120
|
+
end
|
121
|
+
|
122
|
+
case run_command(["diff", "-q", compare_to, @temppath], error: false).exit_status
|
123
|
+
when 1
|
124
|
+
# diff found
|
125
|
+
attributes.modified = true
|
126
|
+
when 2
|
127
|
+
# error
|
128
|
+
raise Itamae::Backend::CommandExecutionError, "diff command exited with 2"
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
def show_content_diff
|
133
|
+
if attributes.modified
|
135
134
|
Itamae.logger.info "diff:"
|
135
|
+
diff = run_command(["diff", "-u", compare_to, @temppath], error: false)
|
136
136
|
diff.stdout.each_line do |line|
|
137
137
|
color = if line.start_with?('+')
|
138
138
|
:green
|
@@ -146,6 +146,9 @@ module Itamae
|
|
146
146
|
end
|
147
147
|
end
|
148
148
|
runner.handler.event(:file_content_changed, diff: diff.stdout)
|
149
|
+
else
|
150
|
+
# no change
|
151
|
+
Itamae.logger.debug "file content will not change"
|
149
152
|
end
|
150
153
|
end
|
151
154
|
|
@@ -7,6 +7,9 @@ module Itamae
|
|
7
7
|
class HttpRequest < File
|
8
8
|
RedirectLimitExceeded = Class.new(StandardError)
|
9
9
|
|
10
|
+
alias_method :_action_create, :action_create
|
11
|
+
undef_method :action_create, :action_delete, :action_edit
|
12
|
+
|
10
13
|
define_attribute :action, default: :get
|
11
14
|
define_attribute :headers, type: Hash, default: {}
|
12
15
|
define_attribute :message, type: String, default: ""
|
@@ -14,6 +17,23 @@ module Itamae
|
|
14
17
|
define_attribute :url, type: String, required: true
|
15
18
|
|
16
19
|
def pre_action
|
20
|
+
attributes.exist = true
|
21
|
+
attributes.content = fetch_content
|
22
|
+
|
23
|
+
send_tempfile
|
24
|
+
compare_file
|
25
|
+
end
|
26
|
+
|
27
|
+
def show_differences
|
28
|
+
current.mode = current.mode.rjust(4, '0') if current.mode
|
29
|
+
attributes.mode = attributes.mode.rjust(4, '0') if attributes.mode
|
30
|
+
|
31
|
+
super
|
32
|
+
|
33
|
+
show_content_diff
|
34
|
+
end
|
35
|
+
|
36
|
+
def fetch_content
|
17
37
|
uri = URI.parse(attributes.url)
|
18
38
|
response = nil
|
19
39
|
redirects_followed = 0
|
@@ -42,29 +62,27 @@ module Itamae
|
|
42
62
|
end
|
43
63
|
end
|
44
64
|
|
45
|
-
|
46
|
-
|
47
|
-
super
|
65
|
+
response.body
|
48
66
|
end
|
49
67
|
|
50
68
|
def action_delete(options)
|
51
|
-
|
69
|
+
_action_create(options)
|
52
70
|
end
|
53
71
|
|
54
72
|
def action_get(options)
|
55
|
-
|
73
|
+
_action_create(options)
|
56
74
|
end
|
57
75
|
|
58
76
|
def action_options(options)
|
59
|
-
|
77
|
+
_action_create(options)
|
60
78
|
end
|
61
79
|
|
62
80
|
def action_post(options)
|
63
|
-
|
81
|
+
_action_create(options)
|
64
82
|
end
|
65
83
|
|
66
84
|
def action_put(options)
|
67
|
-
|
85
|
+
_action_create(options)
|
68
86
|
end
|
69
87
|
end
|
70
88
|
end
|
data/lib/itamae/version.rb
CHANGED
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.7.pre
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryota Arai
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -308,9 +308,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
308
308
|
version: '0'
|
309
309
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
310
310
|
requirements:
|
311
|
-
- - "
|
311
|
+
- - ">"
|
312
312
|
- !ruby/object:Gem::Version
|
313
|
-
version:
|
313
|
+
version: 1.3.1
|
314
314
|
requirements: []
|
315
315
|
rubyforge_project:
|
316
316
|
rubygems_version: 2.5.1
|