knife-essentials 1.0.0.beta1 → 1.0.0.beta2

Sign up to get free protection for your applications and to get access to all the features.
@@ -35,6 +35,12 @@ class Chef
35
35
  :default => false,
36
36
  :description => "Don't take action, only print what would happen"
37
37
 
38
+ option :diff,
39
+ :long => '--[no-]diff',
40
+ :boolean => true,
41
+ :default => true,
42
+ :description => 'Turn off to avoid uploading existing files; only new (and possibly deleted) files with --no-diff'
43
+
38
44
  def run
39
45
  if name_args.length == 0
40
46
  show_usage
@@ -35,6 +35,12 @@ class Chef
35
35
  :default => false,
36
36
  :description => "Don't take action, only print what would happen"
37
37
 
38
+ option :diff,
39
+ :long => '--[no-]diff',
40
+ :boolean => true,
41
+ :default => true,
42
+ :description => 'Turn off to avoid uploading existing files; only new (and possibly deleted) files with --no-diff'
43
+
38
44
  def run
39
45
  if name_args.length == 0
40
46
  show_usage
@@ -368,8 +368,10 @@ module ChefFS
368
368
  return
369
369
  else
370
370
 
371
- # Both are files! Copy them unless we're sure they are the same.
372
- if options[:force]
371
+ # Both are files! Copy them unless we're sure they are the same.'
372
+ if options[:diff] == false
373
+ should_copy = false
374
+ elsif options[:force]
373
375
  should_copy = true
374
376
  src_value = nil
375
377
  else
@@ -1,3 +1,3 @@
1
1
  module ChefFS
2
- VERSION = "1.0.0.beta1"
2
+ VERSION = "1.0.0.beta2"
3
3
  end
@@ -90,6 +90,11 @@ EOM
90
90
  knife('download /').should_succeed "Updated /roles/x.json\n"
91
91
  knife('diff --name-status /').should_succeed ''
92
92
  end
93
+
94
+ it 'knife download --no-diff does not change the role' do
95
+ knife('download --no-diff /').should_succeed ''
96
+ knife('diff --name-status /').should_succeed "M\t/roles/x.json\n"
97
+ end
93
98
  end
94
99
 
95
100
  context 'except the role file is textually different, but not ACTUALLY different' do
@@ -186,6 +191,32 @@ EOM
186
191
  knife('diff --name-status /').should_succeed ''
187
192
  end
188
193
 
194
+ it 'knife download --no-diff creates the extra files' do
195
+ knife('download /').should_succeed <<EOM
196
+ Created /clients
197
+ Created /clients/chef-validator.json
198
+ Created /clients/chef-webui.json
199
+ Created /clients/x.json
200
+ Created /cookbooks
201
+ Created /cookbooks/x
202
+ Created /cookbooks/x/metadata.rb
203
+ Created /data_bags
204
+ Created /data_bags/x
205
+ Created /data_bags/x/y.json
206
+ Created /environments
207
+ Created /environments/_default.json
208
+ Created /environments/x.json
209
+ Created /nodes
210
+ Created /nodes/x.json
211
+ Created /roles
212
+ Created /roles/x.json
213
+ Created /users
214
+ Created /users/admin.json
215
+ Created /users/x.json
216
+ EOM
217
+ knife('diff --name-status /').should_succeed ''
218
+ end
219
+
189
220
  context 'when current directory is top level' do
190
221
  cwd '.'
191
222
  it 'knife download with no parameters reports an error' do
@@ -90,6 +90,10 @@ EOM
90
90
  knife('upload /').should_succeed "Updated /roles/x.json\n"
91
91
  knife('diff --name-status /').should_succeed ''
92
92
  end
93
+ it 'knife upload --no-diff does not change the role' do
94
+ knife('upload /').should_succeed ''
95
+ knife('diff --name-status /').should_succeed "M\t/roles/x.json\n"
96
+ end
93
97
  end
94
98
 
95
99
  context 'except the role file is textually different, but not ACTUALLY different' do
@@ -139,6 +143,22 @@ Created /environments/y.json
139
143
  Created /nodes/y.json
140
144
  Created /roles/y.json
141
145
  Created /users/y.json
146
+ EOM
147
+ knife('diff --name-status /').should_succeed ''
148
+ end
149
+
150
+ it 'knife upload --no-diff adds the new files' do
151
+ knife('upload /').should_succeed <<EOM
152
+ Created /clients/y.json
153
+ Updated /cookbooks/x
154
+ Created /cookbooks/y
155
+ Created /data_bags/x/z.json
156
+ Created /data_bags/y
157
+ Created /data_bags/y/zz.json
158
+ Created /environments/y.json
159
+ Created /nodes/y.json
160
+ Created /roles/y.json
161
+ Created /users/y.json
142
162
  EOM
143
163
  knife('diff --name-status /').should_succeed ''
144
164
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-essentials
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.beta1
4
+ version: 1.0.0.beta2
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-03 00:00:00.000000000 Z
12
+ date: 2013-05-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: chef-zero