itamae 1.3.6 → 1.4.0

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
  SHA1:
3
- metadata.gz: b4842b27c4ba16379169c4bc7bbfdfff7bc45b44
4
- data.tar.gz: 1e5a9a87bb3a4fe69b46877882013ca8a03f5dad
3
+ metadata.gz: 0fddee080e3424d311b0bcac35fcd5f91b2da227
4
+ data.tar.gz: 17283f41482ec965cd35a615f21074cbd9609a04
5
5
  SHA512:
6
- metadata.gz: abb1822d970c0505c4712498712982bc91e73fda3cc9b637087ff506e25424909412bf9eaa89af5de9a28bcc1d647dfb746bef73c455b4f967cf17a68a1e1d24
7
- data.tar.gz: 8387eafd45ca3ee9fb52cac8d317e4ef59d293d9f4cb6404e6e0b740edc6d90b81512f0903813a3bb641ee3bd90e76342ad2d6f1bbf9b436eac140829bf6b7ca
6
+ metadata.gz: 0f7a9211a591f1a5cff1171da061bfc899ffe653759a76beb41aba25171820c808c60cec3107f1c8461cd08f748c7dc5b495ff791f49e3b89356320a4a4107e5
7
+ data.tar.gz: bb9325ae57e1a3358566bb9aa43cce58a6837d683b5aa985d8c738cf2d6ad7b8be7f65b3c64dbce38e8503bc5e13d8d6ae30f448ea3a99d3067efa9bacd475d2
data/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ ## v1.4.0
2
+
3
+ Improvements
4
+
5
+ - Make `cwd` a common attribute. (idea by @tacahilo)
6
+ - It was an attribute for execute resource
7
+ - When `user` attribute is set, change directory to the user's home directory. (idea by @tacahilo)
8
+ - even if cd command fail, it will be ignored
9
+ - directory specified by cwd will take precedence over this
10
+
1
11
  ## v1.3.6
2
12
 
3
13
  Bugfixes
@@ -163,7 +163,7 @@ module Itamae
163
163
  def build_command(commands, options)
164
164
  if commands.is_a?(Array)
165
165
  command = commands.map do |cmd|
166
- Shellwords.escape(cmd)
166
+ cmd.shellescape
167
167
  end.join(' ')
168
168
  else
169
169
  command = commands
@@ -171,12 +171,13 @@ module Itamae
171
171
 
172
172
  cwd = options[:cwd]
173
173
  if cwd
174
- command = "cd #{Shellwords.escape(cwd)} && #{command}"
174
+ command = "cd #{cwd.shellescape} && #{command}"
175
175
  end
176
176
 
177
177
  user = options[:user]
178
178
  if user
179
- command = "sudo -H -u #{Shellwords.escape(user)} -- /bin/sh -c #{Shellwords.escape(command)}"
179
+ command = "cd ~#{user.shellescape} ; #{command}"
180
+ command = "sudo -H -u #{user.shellescape} -- /bin/sh -c #{command.shellescape}"
180
181
  end
181
182
 
182
183
  command
@@ -91,6 +91,7 @@ module Itamae
91
91
 
92
92
  define_attribute :action, type: [Symbol, Array], required: true
93
93
  define_attribute :user, type: String
94
+ define_attribute :cwd, type: String
94
95
 
95
96
  attr_reader :recipe
96
97
  attr_reader :resource_name
@@ -286,6 +287,7 @@ module Itamae
286
287
  end
287
288
 
288
289
  args.last[:user] ||= attributes.user
290
+ args.last[:cwd] ||= attributes.cwd
289
291
 
290
292
  backend.run_command(*args)
291
293
  end
@@ -311,7 +313,7 @@ module Itamae
311
313
  end
312
314
 
313
315
  def shell_escape(str)
314
- Shellwords.escape(str)
316
+ str.shellescape
315
317
  end
316
318
 
317
319
  def updated!
@@ -5,7 +5,6 @@ module Itamae
5
5
  class Execute < Base
6
6
  define_attribute :action, default: :run
7
7
  define_attribute :command, type: String, default_name: true
8
- define_attribute :cwd, type: String
9
8
 
10
9
  def pre_action
11
10
  case @current_action
@@ -19,7 +18,7 @@ module Itamae
19
18
  end
20
19
 
21
20
  def action_run(options)
22
- run_command(attributes.command, cwd: attributes.cwd)
21
+ run_command(attributes.command)
23
22
  updated!
24
23
  end
25
24
  end
@@ -48,7 +48,7 @@ module Itamae
48
48
 
49
49
  super
50
50
 
51
- if current.exist
51
+ if current.exist && @temppath
52
52
  show_file_diff
53
53
  end
54
54
  end
@@ -1 +1 @@
1
- 1.3.6
1
+ 1.4.0
@@ -116,7 +116,7 @@ end
116
116
  describe file('/tmp/created_by_itamae_user') do
117
117
  it { should be_file }
118
118
  it { should be_owned_by 'itamae' }
119
- its(:content) { should eq('/home/itamae') }
119
+ its(:content) { should eq("/home/itamae\n/home/itamae") }
120
120
  end
121
121
 
122
122
  describe file('/tmp/created_in_default2') do
@@ -26,6 +26,12 @@ user "update itamae user" do
26
26
  shell '/bin/dash'
27
27
  end
28
28
 
29
+ directory "/home/itamae" do
30
+ mode "755"
31
+ owner "itamae"
32
+ group "itamae"
33
+ end
34
+
29
35
  user "create itamae2 user with create home directory" do
30
36
  username "itamae2"
31
37
  create_home true
@@ -218,7 +224,7 @@ end
218
224
 
219
225
  #####
220
226
 
221
- execute "echo -n $HOME > /tmp/created_by_itamae_user" do
227
+ execute "echo -n \"$HOME\n$(pwd)\" > /tmp/created_by_itamae_user" do
222
228
  user "itamae"
223
229
  end
224
230
 
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.6
4
+ version: 1.4.0
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-13 00:00:00.000000000 Z
11
+ date: 2015-07-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor