knife-essentials 0.8 → 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +12 -1
- data/lib/chef/knife/delete_essentials.rb +44 -7
- data/lib/chef/knife/{dependencies_essentials.rb → deps_essentials.rb} +3 -3
- data/lib/chef/knife/show_essentials.rb +6 -1
- data/lib/chef_fs/file_system/nonexistent_fs_object.rb +8 -0
- data/lib/chef_fs/version.rb +1 -1
- metadata +3 -3
data/README.rdoc
CHANGED
@@ -10,6 +10,7 @@ that is stored in the Chef server.
|
|
10
10
|
knife download roles data_bags cookbooks/emacs
|
11
11
|
knife upload apache*
|
12
12
|
knife list data_bags/users
|
13
|
+
knife deps roles/base.json
|
13
14
|
cd cookbooks && knife show *base*
|
14
15
|
|
15
16
|
More verbs will be added as time goes by.
|
@@ -105,6 +106,16 @@ Works just like 'ls', except it lists files on the server.
|
|
105
106
|
Works just like +knife node show+, +knife role show+, etc. except there is One Verb To Rule
|
106
107
|
Them All.
|
107
108
|
|
109
|
+
== knife deps
|
110
|
+
|
111
|
+
knife deps [pattern1 pattern2 ...]
|
112
|
+
|
113
|
+
Given a set of nodes, roles, or cookbooks, will traverse dependencies and show
|
114
|
+
other roles, cookbooks, and environments that need to be loaded for them to
|
115
|
+
work. Use +--tree+ parameter to show this in a tree structure. Use +--remote+
|
116
|
+
to perform this operation against the data on the server rather than the local
|
117
|
+
Chef repository.
|
118
|
+
|
108
119
|
== NOTE ABOUT WILDCARDS
|
109
120
|
|
110
121
|
knife-essentials supports wildcards internally, and will use them to sift through objects
|
@@ -128,4 +139,4 @@ yield slightly different results:
|
|
128
139
|
|
129
140
|
You can avoid this problem permanently in zsh with this alias:
|
130
141
|
|
131
|
-
alias knife="noglob knife"
|
142
|
+
alias knife="noglob knife"
|
@@ -15,6 +15,18 @@ class Chef
|
|
15
15
|
:boolean => true,
|
16
16
|
:default => false,
|
17
17
|
:description => "Delete directories recursively."
|
18
|
+
option :remote_only,
|
19
|
+
:short => '-R',
|
20
|
+
:long => '--remote-only',
|
21
|
+
:boolean => true,
|
22
|
+
:default => false,
|
23
|
+
:description => "Only delete the remote copy (leave the local copy)."
|
24
|
+
option :local_only,
|
25
|
+
:short => '-L',
|
26
|
+
:long => '--local-only',
|
27
|
+
:boolean => true,
|
28
|
+
:default => false,
|
29
|
+
:description => "Only delete the local copy (leave the remote copy)."
|
18
30
|
|
19
31
|
def run
|
20
32
|
if name_args.length == 0
|
@@ -24,15 +36,40 @@ class Chef
|
|
24
36
|
end
|
25
37
|
|
26
38
|
# Get the matches (recursively)
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
result
|
31
|
-
puts "Deleted #{result.path_for_printing}"
|
32
|
-
rescue ChefFS::FileSystem::NotFoundError
|
33
|
-
STDERR.puts "#{result.path_for_printing}: No such file or directory"
|
39
|
+
if config[:remote_only]
|
40
|
+
pattern_args.each do |pattern|
|
41
|
+
ChefFS::FileSystem.list(chef_fs, pattern) do |result|
|
42
|
+
delete_result(result)
|
34
43
|
end
|
35
44
|
end
|
45
|
+
elsif config[:local_only]
|
46
|
+
pattern_args.each do |pattern|
|
47
|
+
ChefFS::FileSystem.list(local_fs, pattern) do |result|
|
48
|
+
delete_result(result)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
else
|
52
|
+
pattern_args.each do |pattern|
|
53
|
+
ChefFS::FileSystem.list_pairs(pattern, chef_fs, local_fs) do |chef_result, local_result|
|
54
|
+
delete_result(chef_result, local_result)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def delete_result(*results)
|
61
|
+
deleted_any = false
|
62
|
+
results.each do |result|
|
63
|
+
begin
|
64
|
+
result.delete(config[:recurse])
|
65
|
+
deleted_any = true
|
66
|
+
rescue ChefFS::FileSystem::NotFoundError
|
67
|
+
end
|
68
|
+
end
|
69
|
+
if deleted_any
|
70
|
+
puts "Deleted #{format_path(results[0].path)}"
|
71
|
+
else
|
72
|
+
STDERR.puts "#{format_path(results[0].path)}: No such file or directory"
|
36
73
|
end
|
37
74
|
end
|
38
75
|
end
|
@@ -3,10 +3,10 @@ require 'chef_fs/file_system'
|
|
3
3
|
|
4
4
|
class Chef
|
5
5
|
class Knife
|
6
|
-
remove_const(:
|
7
|
-
class
|
6
|
+
remove_const(:Deps) if const_defined?(:Deps) # override Chef's version
|
7
|
+
class Deps < ::ChefFS::Knife
|
8
8
|
ChefFS = ::ChefFS
|
9
|
-
banner "knife
|
9
|
+
banner "knife deps PATTERN1 [PATTERNn]"
|
10
10
|
|
11
11
|
common_options
|
12
12
|
|
@@ -10,10 +10,15 @@ class Chef
|
|
10
10
|
|
11
11
|
common_options
|
12
12
|
|
13
|
+
option :local,
|
14
|
+
:long => '--local',
|
15
|
+
:boolean => true,
|
16
|
+
:description => "Show local files instead of remote"
|
17
|
+
|
13
18
|
def run
|
14
19
|
# Get the matches (recursively)
|
15
20
|
pattern_args.each do |pattern|
|
16
|
-
ChefFS::FileSystem.list(chef_fs, pattern) do |result|
|
21
|
+
ChefFS::FileSystem.list(config[:local] ? local_fs : chef_fs, pattern) do |result|
|
17
22
|
if result.dir?
|
18
23
|
STDERR.puts "#{result.path_for_printing}: is a directory" if pattern.exact_path
|
19
24
|
else
|
@@ -33,6 +33,14 @@ module ChefFS
|
|
33
33
|
def read
|
34
34
|
raise ChefFS::FileSystem::NotFoundError, "Nonexistent #{path_for_printing}"
|
35
35
|
end
|
36
|
+
|
37
|
+
def write(contents)
|
38
|
+
raise ChefFS::FileSystem::NotFoundError, "Nonexistent #{path_for_printing}"
|
39
|
+
end
|
40
|
+
|
41
|
+
def delete(recurse)
|
42
|
+
raise ChefFS::FileSystem::NotFoundError, "Nonexistent #{path_for_printing}"
|
43
|
+
end
|
36
44
|
end
|
37
45
|
end
|
38
46
|
end
|
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.8.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-12-
|
12
|
+
date: 2012-12-19 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Universal knife verbs that work with your Chef repository
|
15
15
|
email: jkeiser@opscode.com
|
@@ -23,7 +23,7 @@ files:
|
|
23
23
|
- README.rdoc
|
24
24
|
- Rakefile
|
25
25
|
- lib/chef/knife/delete_essentials.rb
|
26
|
-
- lib/chef/knife/
|
26
|
+
- lib/chef/knife/deps_essentials.rb
|
27
27
|
- lib/chef/knife/diff_essentials.rb
|
28
28
|
- lib/chef/knife/download_essentials.rb
|
29
29
|
- lib/chef/knife/list_essentials.rb
|