itamae 1.3.4 → 1.3.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3c3734924aed2c2ab9472e781e7c512c31599b46
4
- data.tar.gz: fe29b7a53a36075a3886be1d89e17355edf528cd
3
+ metadata.gz: 9b5da1c2ff4d918217ee4f29df62cb0660fdb7a9
4
+ data.tar.gz: 18078c7885176596c4c3396a8908ff5cc8baa72c
5
5
  SHA512:
6
- metadata.gz: c7a9d8d4400cc1b46276c7e5115e4c5bd653fb9d2cb63c3edcd548d36207b021947b8925aaaab9b693bf8e4a26db4c9324275c0b80a4e2ea9ac5e4cb382f97a2
7
- data.tar.gz: abd0f092cfa89168efe723b0210a58ba3a4ec82993818be5cda8a7787d5827148744fd6dda2355e2482146b79d7414f084bc7e4d3b568a2d695385abc4721379
6
+ metadata.gz: cc92d067302c74eabb5e20c0856540bf6a39486ed520f43744346150c82a69e338de577fa44277156fbdad8bb40ee67a1ee08bb28330c4ef8d6c81bdd414001a
7
+ data.tar.gz: 3932d9c1c1053356b4bb45fbfbbdadf73a35e2edcc7025ad12241b21b645e90834ea55c21bd7d3042a7d00830e38e666a45dadec937f6299eaa01f2092b8ba3c
@@ -1,3 +1,13 @@
1
+ ## v1.3.5
2
+
3
+ Improvements
4
+
5
+ - [`create` action of `file` resource without `content` attribute changes mode and owner without touching the content of the file](https://github.com/itamae-kitchen/itamae/compare/itamae-kitchen:d4a0abc...itamae-kitchen:3eae144)
6
+
7
+ Bugfixes
8
+
9
+ - [Edit action of file resource should set owner and mode if specified (by @eagletmt)](https://github.com/itamae-kitchen/itamae/pull/143)
10
+
1
11
  ## v1.3.4
2
12
 
3
13
  Improvements
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Itamae [![Gem Version](https://badge.fury.io/rb/itamae.svg)](http://badge.fury.io/rb/itamae) [![Code Climate](https://codeclimate.com/github/ryotarai/itamae/badges/gpa.svg)](https://codeclimate.com/github/ryotarai/itamae) [![wercker status](https://app.wercker.com/status/3e7be3b982d3671940a07e3ef45d9f5f/s/master "wercker status")](https://app.wercker.com/project/bykey/3e7be3b982d3671940a07e3ef45d9f5f) [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/itamae-kitchen/itamae?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
1
+ # Itamae [![Gem Version](https://badge.fury.io/rb/itamae.svg)](http://badge.fury.io/rb/itamae) [![Code Climate](https://codeclimate.com/github/ryotarai/itamae/badges/gpa.svg)](https://codeclimate.com/github/ryotarai/itamae) [![wercker status](https://app.wercker.com/status/3e7be3b982d3671940a07e3ef45d9f5f/s/master "wercker status")](https://app.wercker.com/project/bykey/3e7be3b982d3671940a07e3ef45d9f5f) [![Slack](https://itamae-slackin.herokuapp.com/badge.svg)](https://itamae-slackin.herokuapp.com/)
2
2
 
3
3
  Simple and lightweight configuration management tool inspired by Chef.
4
4
 
@@ -37,6 +37,10 @@ $ bundle exec rake spec
37
37
 
38
38
  - [(in Japanese) Itamae - Infra as Code 現状確認会](https://speakerdeck.com/ryotarai/itamae-infra-as-code-xian-zhuang-que-ren-hui)
39
39
 
40
+ ## Get Involved
41
+
42
+ [Don't hesitate to join our Slack team!](https://itamae-slackin.herokuapp.com/)
43
+
40
44
  ## Contributing
41
45
 
42
46
  If you have a problem, please [create an issue](https://github.com/ryotarai/itamae/issues/new) or a pull request.
@@ -5,7 +5,7 @@ module Itamae
5
5
  class File < Base
6
6
  define_attribute :action, default: :create
7
7
  define_attribute :path, type: String, default_name: true
8
- define_attribute :content, type: String, default: ''
8
+ define_attribute :content, type: String, default: nil
9
9
  define_attribute :mode, type: String
10
10
  define_attribute :owner, type: String
11
11
  define_attribute :group, type: String
@@ -54,24 +54,28 @@ module Itamae
54
54
  end
55
55
 
56
56
  def action_create(options)
57
+ change_target = @temppath || attributes.path
58
+
57
59
  if attributes.mode
58
- run_specinfra(:change_file_mode, @temppath, attributes.mode)
60
+ run_specinfra(:change_file_mode, change_target, attributes.mode)
59
61
  end
60
62
  if attributes.owner || attributes.group
61
- run_specinfra(:change_file_owner, @temppath, attributes.owner, attributes.group)
63
+ run_specinfra(:change_file_owner, change_target, attributes.owner, attributes.group)
62
64
  end
63
65
 
64
- if run_specinfra(:check_file_is_file, attributes.path)
65
- unless check_command(["diff", "-q", @temppath, attributes.path])
66
- # the file is modified
66
+ if @temppath
67
+ if run_specinfra(:check_file_is_file, attributes.path)
68
+ unless check_command(["diff", "-q", @temppath, attributes.path])
69
+ # the file is modified
70
+ updated!
71
+ end
72
+ else
73
+ # new file
67
74
  updated!
68
75
  end
69
- else
70
- # new file
71
- updated!
72
- end
73
76
 
74
- run_specinfra(:move_file, @temppath, attributes.path)
77
+ run_specinfra(:move_file, @temppath, attributes.path)
78
+ end
75
79
  end
76
80
 
77
81
  def action_delete(options)
@@ -81,8 +85,18 @@ module Itamae
81
85
  end
82
86
 
83
87
  def action_edit(options)
84
- run_command(['chmod', '--reference', attributes.path, @temppath])
85
- run_command(['chown', '--reference', attributes.path, @temppath])
88
+ if attributes.mode
89
+ run_specinfra(:change_file_mode, @temppath, attributes.mode)
90
+ else
91
+ run_command(['chmod', '--reference', attributes.path, @temppath])
92
+ end
93
+
94
+ if attributes.owner || attributes.group
95
+ run_specinfra(:change_file_owner, @temppath, attributes.owner, attributes.group)
96
+ else
97
+ run_command(['chown', '--reference', attributes.path, @temppath])
98
+ end
99
+
86
100
  run_specinfra(:move_file, @temppath, attributes.path)
87
101
  end
88
102
 
@@ -116,6 +130,11 @@ module Itamae
116
130
  end
117
131
 
118
132
  def send_tempfile
133
+ if current.exist && !attributes.content && !content_file
134
+ @temppath = nil
135
+ return
136
+ end
137
+
119
138
  begin
120
139
  src = if content_file
121
140
  content_file
@@ -1 +1 @@
1
- 1.3.4
1
+ 1.3.5
@@ -163,9 +163,9 @@ end
163
163
  describe file('/tmp/file_edit_sample') do
164
164
  it { should be_file }
165
165
  its(:content) { should eq("Hello, Itamae") }
166
- it { should be_mode 444 }
167
- it { should be_owned_by "itamae" }
168
- it { should be_grouped_into "itamae" }
166
+ it { should be_mode 400 }
167
+ it { should be_owned_by "itamae2" }
168
+ it { should be_grouped_into "itamae2" }
169
169
  end
170
170
 
171
171
  describe file('/home/itamae2') do
@@ -173,3 +173,10 @@ describe file('/home/itamae2') do
173
173
  it { should be_owned_by "itamae2" }
174
174
  it { should be_grouped_into "itamae2" }
175
175
  end
176
+
177
+ describe file('/tmp/file_create_without_content') do
178
+ its(:content) { should eq("Hello, World") }
179
+ it { should be_mode 600 }
180
+ it { should be_owned_by "itamae" }
181
+ it { should be_grouped_into "itamae" }
182
+ end
@@ -263,6 +263,18 @@ end
263
263
 
264
264
  #####
265
265
 
266
+ file "/tmp/file_create_without_content" do
267
+ content "Hello, World"
268
+ end
269
+
270
+ file "/tmp/file_create_without_content" do
271
+ owner "itamae"
272
+ group "itamae"
273
+ mode "600"
274
+ end
275
+
276
+ #####
277
+
266
278
  execute 'true' do
267
279
  verify 'true'
268
280
  end
@@ -318,6 +330,9 @@ end
318
330
 
319
331
  file '/tmp/file_edit_sample' do
320
332
  action :edit
333
+ owner 'itamae2'
334
+ group 'itamae2'
335
+ mode '400'
321
336
  block do |content|
322
337
  content.gsub!('world', 'Itamae')
323
338
  end
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.3.4
4
+ version: 1.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryota Arai
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-09 00:00:00.000000000 Z
11
+ date: 2015-07-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor