knife-essentials 0.6 → 0.6.1
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.
data/README.rdoc
CHANGED
@@ -8,11 +8,19 @@ that is stored in the Chef server.
|
|
8
8
|
|
9
9
|
knife diff cookbooks/*apache*
|
10
10
|
knife download roles data_bags cookbooks/emacs
|
11
|
+
knife upload apache*
|
11
12
|
knife list data_bags/users
|
12
|
-
knife show
|
13
|
+
cd cookbooks && knife show *base*
|
13
14
|
|
14
|
-
|
15
|
-
|
15
|
+
More verbs will be added as time goes by.
|
16
|
+
|
17
|
+
= INSTALLATION:
|
18
|
+
|
19
|
+
This plugin can be installed as a Ruby Gem.
|
20
|
+
|
21
|
+
gem install knife-essentials
|
22
|
+
|
23
|
+
You can also copy the source repository and install it using +rake install+.
|
16
24
|
|
17
25
|
= PRINCIPLES
|
18
26
|
|
@@ -43,12 +51,6 @@ When you're in the +roles+ directory, the system knows that's what you are
|
|
43
51
|
working with. Just type +knife show base.json+ and it will show you the base
|
44
52
|
role from the server. knife-essentials knows.
|
45
53
|
|
46
|
-
= INSTALLATION:
|
47
|
-
|
48
|
-
This plugin builds a Ruby Gem (but has not yet been released to RubyGems). To install it, run:
|
49
|
-
|
50
|
-
rake install
|
51
|
-
|
52
54
|
= KNIFE PLUGINS
|
53
55
|
|
54
56
|
chef_fs installs a number of useful knife verbs, including:
|
data/lib/chef_fs/command_line.rb
CHANGED
@@ -5,10 +5,10 @@ module ChefFS
|
|
5
5
|
def self.diff(pattern, a_root, b_root, recurse_depth, output_mode)
|
6
6
|
found_result = false
|
7
7
|
ChefFS::FileSystem.list_pairs(pattern, a_root, b_root) do |a, b|
|
8
|
-
|
9
|
-
diff_entries(a, b, recurse_depth, output_mode) do |diff|
|
8
|
+
existed = diff_entries(a, b, recurse_depth, output_mode) do |diff|
|
10
9
|
yield diff
|
11
10
|
end
|
11
|
+
found_result = true if existed
|
12
12
|
end
|
13
13
|
if !found_result && pattern.exact_path
|
14
14
|
yield "#{pattern}: No such file or directory on remote or local"
|
@@ -76,10 +76,12 @@ module ChefFS
|
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
79
|
+
# Neither is a directory, so they are diffable with file diff
|
79
80
|
else
|
80
|
-
# Neither is a directory, so they are diffable with file diff
|
81
81
|
are_same, old_value, new_value = ChefFS::FileSystem.compare(old_entry, new_entry)
|
82
|
-
if
|
82
|
+
if are_same
|
83
|
+
return old_value != :none
|
84
|
+
else
|
83
85
|
if old_value == :none
|
84
86
|
old_exists = false
|
85
87
|
elsif old_value.nil?
|
@@ -98,10 +100,10 @@ module ChefFS
|
|
98
100
|
# If one of the files doesn't exist, we only want to print the diff if the
|
99
101
|
# other file *could be uploaded/downloaded*.
|
100
102
|
if !old_exists && !old_entry.parent.can_have_child?(new_entry.name, new_entry.dir?)
|
101
|
-
return
|
103
|
+
return true
|
102
104
|
end
|
103
105
|
if !new_exists && !new_entry.parent.can_have_child?(old_entry.name, old_entry.dir?)
|
104
|
-
return
|
106
|
+
return true
|
105
107
|
end
|
106
108
|
|
107
109
|
if output_mode == :name_only
|
@@ -146,6 +148,7 @@ module ChefFS
|
|
146
148
|
end
|
147
149
|
end
|
148
150
|
end
|
151
|
+
return true
|
149
152
|
end
|
150
153
|
|
151
154
|
private
|
data/lib/chef_fs/file_system.rb
CHANGED
@@ -224,13 +224,14 @@ module ChefFS
|
|
224
224
|
end
|
225
225
|
|
226
226
|
elsif !dest_entry.exists?
|
227
|
-
|
227
|
+
dest_parent = get_or_create_parent(dest_entry, options)
|
228
|
+
if dest_parent.can_have_child?(src_entry.name, src_entry.dir?)
|
228
229
|
if src_entry.dir?
|
229
230
|
if options[:dry_run]
|
230
231
|
puts "Would create #{dest_entry.path_for_printing}"
|
231
|
-
new_dest_dir =
|
232
|
+
new_dest_dir = dest_parent.child(src_entry.name)
|
232
233
|
else
|
233
|
-
new_dest_dir =
|
234
|
+
new_dest_dir = dest_parent.create_child(src_entry.name, nil)
|
234
235
|
puts "Created #{dest_entry.path_for_printing}/"
|
235
236
|
end
|
236
237
|
# Directory creation is recursive.
|
@@ -286,6 +287,7 @@ module ChefFS
|
|
286
287
|
Chef::Log.error("File #{dest_entry.path_for_printing} is a directory while file #{dest_entry.path_for_printing} is a regular file\n")
|
287
288
|
return
|
288
289
|
else
|
290
|
+
|
289
291
|
# Both are files! Copy them unless we're sure they are the same.
|
290
292
|
if options[:force]
|
291
293
|
should_copy = true
|
@@ -308,6 +310,20 @@ module ChefFS
|
|
308
310
|
end
|
309
311
|
end
|
310
312
|
|
313
|
+
def self.get_or_create_parent(entry, options)
|
314
|
+
parent = entry.parent
|
315
|
+
if !parent.exists?
|
316
|
+
parent_parent = get_or_create_parent(entry.parent, options)
|
317
|
+
if options[:dry_run]
|
318
|
+
puts "Would create #{parent.path_for_printing}"
|
319
|
+
else
|
320
|
+
parent = parent_parent.create_child(parent.name, true)
|
321
|
+
puts "Created #{parent.path_for_printing}"
|
322
|
+
end
|
323
|
+
end
|
324
|
+
return parent
|
325
|
+
end
|
326
|
+
|
311
327
|
end
|
312
328
|
end
|
313
329
|
|
@@ -26,7 +26,12 @@ module ChefFS
|
|
26
26
|
|
27
27
|
def path_for_printing
|
28
28
|
if parent
|
29
|
-
|
29
|
+
parent_path = parent.path_for_printing
|
30
|
+
if parent_path == '.'
|
31
|
+
name
|
32
|
+
else
|
33
|
+
ChefFS::PathUtils::join(parent.path_for_printing, name)
|
34
|
+
end
|
30
35
|
else
|
31
36
|
name
|
32
37
|
end
|
@@ -25,7 +25,11 @@ module ChefFS
|
|
25
25
|
|
26
26
|
def exists?
|
27
27
|
if @exists.nil?
|
28
|
-
|
28
|
+
begin
|
29
|
+
@exists = parent.children.any? { |child| child.name == name }
|
30
|
+
rescue ChefFS::FileSystem::NotFoundError
|
31
|
+
@exists = false
|
32
|
+
end
|
29
33
|
end
|
30
34
|
@exists
|
31
35
|
end
|
data/lib/chef_fs/knife.rb
CHANGED
@@ -14,7 +14,10 @@ module ChefFS
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def base_path
|
17
|
-
@base_path ||=
|
17
|
+
@base_path ||= begin
|
18
|
+
relative_to_base = ChefFS::PathUtils::relative_to(File.absolute_path(Dir.pwd), chef_repo)
|
19
|
+
relative_to_base == '.' ? '/' : "/#{relative_to_base}"
|
20
|
+
end
|
18
21
|
end
|
19
22
|
|
20
23
|
def chef_fs
|
data/lib/chef_fs/version.rb
CHANGED
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.6.1
|
5
5
|
prerelease:
|
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: 2012-05-
|
12
|
+
date: 2012-05-24 00:00:00.000000000Z
|
13
13
|
dependencies: []
|
14
14
|
description: Universal knife verbs that work with your Chef repository
|
15
15
|
email: jkeiser@opscode.com
|