knife-essentials 0.1 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +24 -18
- data/lib/chef_fs/diff.rb +2 -2
- data/lib/chef_fs/file_system/cookbook_dir.rb +9 -0
- data/lib/chef_fs/file_system/data_bag_dir.rb +9 -0
- data/lib/chef_fs/path_utils.rb +2 -1
- data/lib/chef_fs/version.rb +1 -1
- data/spec/chef_fs/diff_spec.rb +57 -8
- metadata +3 -3
data/README.rdoc
CHANGED
@@ -94,21 +94,27 @@ Works just like 'ls', except it lists files on the server.
|
|
94
94
|
Works just like +knife node show+, +knife role show+, etc. except there is One Verb To Rule
|
95
95
|
Them All.
|
96
96
|
|
97
|
-
== NOTE
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
knife list data_bags/
|
113
|
-
|
114
|
-
|
97
|
+
== NOTE ABOUT WILDCARDS
|
98
|
+
|
99
|
+
knife-essentials supports wildcards internally, and will use them to sift through objects
|
100
|
+
on the server. This can be very useful. However, since it uses the same wildcard
|
101
|
+
characters as the Unix command line (+*+, +?+, etc.), you need to backslash them so that
|
102
|
+
the +*+ actually reaches the server. If you don't, the shell will expand the * into
|
103
|
+
actual filenames and knife will never know you typed +*+ in the first place. For example,
|
104
|
+
if the Chef server has data bags +aardvarks+, +anagrams+ and +arp_tables+, but your local
|
105
|
+
filesystem only has +aardvarks+ and +anagrams+, backslashing vs. not backslashing will
|
106
|
+
yield slightly different results:
|
107
|
+
|
108
|
+
# This actually asks the server for everything starting with a
|
109
|
+
$ knife list data_bags/a\*
|
110
|
+
aardvarks/ anagrams/ arp_tables/
|
111
|
+
# But this ...
|
112
|
+
$ knife list data_bags/a*
|
113
|
+
aardvarks/ anagrams/
|
114
|
+
# Is actually expanded by the command line to this:
|
115
|
+
$ knife list data_bags/aardvarks data_bags/aardvarks
|
116
|
+
aardvarks/ anagrams/
|
117
|
+
|
118
|
+
You can avoid this problem permanently in zsh with this alias:
|
119
|
+
|
120
|
+
alias knife="noglob knife"
|
data/lib/chef_fs/diff.rb
CHANGED
@@ -121,8 +121,8 @@ module ChefFS
|
|
121
121
|
# infinitely.
|
122
122
|
#
|
123
123
|
def self.diffable_leaves(a, b, recurse_depth)
|
124
|
-
# If
|
125
|
-
if recurse_depth != 0 && a.dir? && b.dir?
|
124
|
+
# If both are directories, recurse into them and diff the children instead of returning ourselves.
|
125
|
+
if recurse_depth != 0 && a.dir? && b.dir?
|
126
126
|
a_children_names = Set.new
|
127
127
|
a.children.each do |a_child|
|
128
128
|
a_children_names << a_child.name
|
@@ -50,6 +50,15 @@ module ChefFS
|
|
50
50
|
@children
|
51
51
|
end
|
52
52
|
|
53
|
+
def dir?
|
54
|
+
exists?
|
55
|
+
end
|
56
|
+
|
57
|
+
def read
|
58
|
+
# This will only be called if dir? is false, which means exists? is false.
|
59
|
+
raise ChefFS::FileSystem::NotFoundException, path_for_printing
|
60
|
+
end
|
61
|
+
|
53
62
|
def exists?
|
54
63
|
if !@versions
|
55
64
|
child = parent.children.select { |child| child.name == name }.first
|
@@ -11,6 +11,15 @@ module ChefFS
|
|
11
11
|
@exists = nil
|
12
12
|
end
|
13
13
|
|
14
|
+
def dir?
|
15
|
+
exists?
|
16
|
+
end
|
17
|
+
|
18
|
+
def read
|
19
|
+
# This will only be called if dir? is false, which means exists? is false.
|
20
|
+
raise ChefFS::FileSystem::NotFoundException, path_for_printing
|
21
|
+
end
|
22
|
+
|
14
23
|
def exists?
|
15
24
|
if @exists.nil?
|
16
25
|
@exists = parent.children.any? { |child| child.name == name }
|
data/lib/chef_fs/path_utils.rb
CHANGED
@@ -16,7 +16,8 @@ module ChefFS
|
|
16
16
|
end
|
17
17
|
# dot-dot up from 'source' to the common ancestor, then
|
18
18
|
# descend to 'dest' from the common ancestor
|
19
|
-
ChefFS::PathUtils.join(*(['..']*(source_parts.length-i) + dest_parts[i,dest.length-i]))
|
19
|
+
result = ChefFS::PathUtils.join(*(['..']*(source_parts.length-i) + dest_parts[i,dest.length-i]))
|
20
|
+
result == '' ? '.' : result
|
20
21
|
end
|
21
22
|
|
22
23
|
def self.join(*parts)
|
data/lib/chef_fs/version.rb
CHANGED
data/spec/chef_fs/diff_spec.rb
CHANGED
@@ -14,6 +14,8 @@ describe ChefFS::Diff do
|
|
14
14
|
:sub_both_files => nil,
|
15
15
|
:sub_both_files_different => "a\n",
|
16
16
|
:sub_both_dirs_empty => {},
|
17
|
+
:sub_dirs_empty_in_a_filled_in_b => {},
|
18
|
+
:sub_dirs_empty_in_b_filled_in_a => { :subsub => nil },
|
17
19
|
:sub_a_only_dir => { :subsub => nil },
|
18
20
|
:sub_a_only_file => nil,
|
19
21
|
:sub_dir_in_a_file_in_b => {},
|
@@ -21,7 +23,9 @@ describe ChefFS::Diff do
|
|
21
23
|
},
|
22
24
|
:both_files => nil,
|
23
25
|
:both_files_different => "a\n",
|
24
|
-
|
26
|
+
:both_dirs_empty => {},
|
27
|
+
:dirs_empty_in_a_filled_in_b => {},
|
28
|
+
:dirs_empty_in_b_filled_in_a => { :subsub => nil },
|
25
29
|
:a_only_dir => { :subsub => nil },
|
26
30
|
:a_only_file => nil,
|
27
31
|
:dir_in_a_file_in_b => {},
|
@@ -35,6 +39,8 @@ describe ChefFS::Diff do
|
|
35
39
|
:sub_both_files => nil,
|
36
40
|
:sub_both_files_different => "b\n",
|
37
41
|
:sub_both_dirs_empty => {},
|
42
|
+
:sub_dirs_empty_in_a_filled_in_b => { :subsub => nil },
|
43
|
+
:sub_dirs_empty_in_b_filled_in_a => {},
|
38
44
|
:sub_b_only_dir => { :subsub => nil },
|
39
45
|
:sub_b_only_file => nil,
|
40
46
|
:sub_dir_in_a_file_in_b => nil,
|
@@ -43,6 +49,8 @@ describe ChefFS::Diff do
|
|
43
49
|
:both_files => nil,
|
44
50
|
:both_files_different => "b\n",
|
45
51
|
:both_dirs_empty => {},
|
52
|
+
:dirs_empty_in_a_filled_in_b => { :subsub => nil },
|
53
|
+
:dirs_empty_in_b_filled_in_a => {},
|
46
54
|
:b_only_dir => { :subsub => nil },
|
47
55
|
:b_only_file => nil,
|
48
56
|
:dir_in_a_file_in_b => nil,
|
@@ -55,7 +63,8 @@ describe ChefFS::Diff do
|
|
55
63
|
/both_dirs/sub_both_dirs/subsub
|
56
64
|
/both_dirs/sub_both_files
|
57
65
|
/both_dirs/sub_both_files_different
|
58
|
-
/both_dirs/
|
66
|
+
/both_dirs/sub_dirs_empty_in_b_filled_in_a/subsub
|
67
|
+
/both_dirs/sub_dirs_empty_in_a_filled_in_b/subsub
|
59
68
|
/both_dirs/sub_a_only_dir
|
60
69
|
/both_dirs/sub_a_only_file
|
61
70
|
/both_dirs/sub_b_only_dir
|
@@ -64,7 +73,8 @@ describe ChefFS::Diff do
|
|
64
73
|
/both_dirs/sub_file_in_a_dir_in_b
|
65
74
|
/both_files
|
66
75
|
/both_files_different
|
67
|
-
/
|
76
|
+
/dirs_empty_in_b_filled_in_a/subsub
|
77
|
+
/dirs_empty_in_a_filled_in_b/subsub
|
68
78
|
/a_only_dir
|
69
79
|
/a_only_file
|
70
80
|
/b_only_dir
|
@@ -96,14 +106,16 @@ describe ChefFS::Diff do
|
|
96
106
|
/both_dirs/sub_both_dirs/subsub
|
97
107
|
/both_dirs/sub_both_files
|
98
108
|
/both_dirs/sub_both_files_different
|
99
|
-
/both_dirs/
|
109
|
+
/both_dirs/sub_dirs_empty_in_b_filled_in_a/subsub
|
110
|
+
/both_dirs/sub_dirs_empty_in_a_filled_in_b/subsub
|
100
111
|
/both_dirs/sub_a_only_dir
|
101
112
|
/both_dirs/sub_a_only_file
|
102
113
|
/both_dirs/sub_b_only_dir
|
103
114
|
/both_dirs/sub_b_only_file
|
104
115
|
/both_dirs/sub_dir_in_a_file_in_b
|
105
116
|
/both_dirs/sub_file_in_a_dir_in_b
|
106
|
-
/
|
117
|
+
/dirs_empty_in_b_filled_in_a/subsub
|
118
|
+
/dirs_empty_in_a_filled_in_b/subsub
|
107
119
|
/a_only_dir
|
108
120
|
/b_only_dir
|
109
121
|
/dir_in_a_file_in_b
|
@@ -122,7 +134,18 @@ describe ChefFS::Diff do
|
|
122
134
|
@@ -1 +1 @@
|
123
135
|
-a
|
124
136
|
+b
|
125
|
-
','
|
137
|
+
','diff --knife a/both_dirs/sub_dirs_empty_in_a_filled_in_b/subsub b/both_dirs/sub_dirs_empty_in_a_filled_in_b/subsub
|
138
|
+
new file
|
139
|
+
--- /dev/null DATE
|
140
|
+
+++ b/both_dirs/sub_dirs_empty_in_a_filled_in_b/subsub DATE
|
141
|
+
@@ -0,0 +1 @@
|
142
|
+
+subsub
|
143
|
+
','diff --knife a/both_dirs/sub_dirs_empty_in_b_filled_in_a/subsub b/both_dirs/sub_dirs_empty_in_b_filled_in_a/subsub
|
144
|
+
deleted file
|
145
|
+
--- a/both_dirs/sub_dirs_empty_in_b_filled_in_a/subsub DATE
|
146
|
+
+++ /dev/null DATE
|
147
|
+
@@ -1 +0,0 @@
|
148
|
+
-subsub
|
126
149
|
','Only in a/both_dirs: sub_a_only_dir
|
127
150
|
','diff --knife a/both_dirs/sub_a_only_file b/both_dirs/sub_a_only_file
|
128
151
|
deleted file
|
@@ -145,7 +168,18 @@ new file
|
|
145
168
|
@@ -1 +1 @@
|
146
169
|
-a
|
147
170
|
+b
|
148
|
-
','
|
171
|
+
','diff --knife a/dirs_empty_in_a_filled_in_b/subsub b/dirs_empty_in_a_filled_in_b/subsub
|
172
|
+
new file
|
173
|
+
--- /dev/null DATE
|
174
|
+
+++ b/dirs_empty_in_a_filled_in_b/subsub DATE
|
175
|
+
@@ -0,0 +1 @@
|
176
|
+
+subsub
|
177
|
+
','diff --knife a/dirs_empty_in_b_filled_in_a/subsub b/dirs_empty_in_b_filled_in_a/subsub
|
178
|
+
deleted file
|
179
|
+
--- a/dirs_empty_in_b_filled_in_a/subsub DATE
|
180
|
+
+++ /dev/null DATE
|
181
|
+
@@ -1 +0,0 @@
|
182
|
+
-subsub
|
149
183
|
','Only in a: a_only_dir
|
150
184
|
','diff --knife a/a_only_file b/a_only_file
|
151
185
|
deleted file
|
@@ -176,7 +210,18 @@ new file
|
|
176
210
|
@@ -1 +1 @@
|
177
211
|
-a
|
178
212
|
+b
|
179
|
-
','
|
213
|
+
','diff --knife a/both_dirs/sub_dirs_empty_in_a_filled_in_b/subsub b/both_dirs/sub_dirs_empty_in_a_filled_in_b/subsub
|
214
|
+
new file
|
215
|
+
--- /dev/null DATE
|
216
|
+
+++ b/both_dirs/sub_dirs_empty_in_a_filled_in_b/subsub DATE
|
217
|
+
@@ -0,0 +1 @@
|
218
|
+
+subsub
|
219
|
+
','diff --knife a/both_dirs/sub_dirs_empty_in_b_filled_in_a/subsub b/both_dirs/sub_dirs_empty_in_b_filled_in_a/subsub
|
220
|
+
deleted file
|
221
|
+
--- a/both_dirs/sub_dirs_empty_in_b_filled_in_a/subsub DATE
|
222
|
+
+++ /dev/null DATE
|
223
|
+
@@ -1 +0,0 @@
|
224
|
+
-subsub
|
180
225
|
','Only in a/both_dirs: sub_a_only_dir
|
181
226
|
','diff --knife a/both_dirs/sub_a_only_file b/both_dirs/sub_a_only_file
|
182
227
|
deleted file
|
@@ -209,6 +254,8 @@ new file
|
|
209
254
|
-a
|
210
255
|
+b
|
211
256
|
','Common subdirectories: /both_dirs_empty
|
257
|
+
','Common subdirectories: /dirs_empty_in_b_filled_in_a
|
258
|
+
','Common subdirectories: /dirs_empty_in_a_filled_in_b
|
212
259
|
','Only in a: a_only_dir
|
213
260
|
','diff --knife a/a_only_file b/a_only_file
|
214
261
|
deleted file
|
@@ -241,6 +288,8 @@ new file
|
|
241
288
|
-a
|
242
289
|
+b
|
243
290
|
','Common subdirectories: /both_dirs_empty
|
291
|
+
','Common subdirectories: /dirs_empty_in_b_filled_in_a
|
292
|
+
','Common subdirectories: /dirs_empty_in_a_filled_in_b
|
244
293
|
','Only in a: a_only_dir
|
245
294
|
','diff --knife a/a_only_file b/a_only_file
|
246
295
|
deleted file
|
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:
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ bindir: bin
|
|
11
11
|
cert_chain: []
|
12
12
|
date: 2012-04-26 00:00:00.000000000Z
|
13
13
|
dependencies: []
|
14
|
-
description:
|
14
|
+
description: Universal knife verbs that work with your Chef repository
|
15
15
|
email: jkeiser@opscode.com
|
16
16
|
executables: []
|
17
17
|
extensions: []
|
@@ -75,5 +75,5 @@ rubyforge_project:
|
|
75
75
|
rubygems_version: 1.8.10
|
76
76
|
signing_key:
|
77
77
|
specification_version: 3
|
78
|
-
summary:
|
78
|
+
summary: Universal knife verbs that work with your Chef repository
|
79
79
|
test_files: []
|