knife-essentials 0.3 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/chef/knife/show.rb +1 -1
- data/lib/chef_fs/file_system.rb +6 -8
- data/lib/chef_fs/file_system/chef_server_root_dir.rb +3 -2
- data/lib/chef_fs/file_system/data_bag_dir.rb +0 -2
- data/lib/chef_fs/file_system/data_bags_dir.rb +0 -2
- data/lib/chef_fs/file_system/nodes_dir.rb +27 -0
- data/lib/chef_fs/file_system/rest_list_dir.rb +0 -2
- data/lib/chef_fs/file_system/rest_list_entry.rb +1 -3
- data/lib/chef_fs/version.rb +1 -1
- metadata +2 -1
data/lib/chef/knife/show.rb
CHANGED
@@ -16,7 +16,7 @@ class Chef
|
|
16
16
|
begin
|
17
17
|
value = result.read
|
18
18
|
puts "#{format_path(result.path)}:"
|
19
|
-
output(format_for_display(
|
19
|
+
output(format_for_display(value))
|
20
20
|
rescue ChefFS::FileSystem::NotFoundError
|
21
21
|
STDERR.puts "#{format_path(result.path)}: No such file or directory" if pattern.exact_path
|
22
22
|
end
|
data/lib/chef_fs/file_system.rb
CHANGED
@@ -3,10 +3,6 @@ require 'chef_fs/diff'
|
|
3
3
|
|
4
4
|
module ChefFS
|
5
5
|
module FileSystem
|
6
|
-
def self.copy_to(pattern, src_root, dest_root)
|
7
|
-
|
8
|
-
end
|
9
|
-
|
10
6
|
# Yields a list of all things under (and including) this entry that match the
|
11
7
|
# given pattern.
|
12
8
|
#
|
@@ -121,16 +117,18 @@ module ChefFS
|
|
121
117
|
if purge
|
122
118
|
# If we would not have uploaded it, we will not purge it.
|
123
119
|
if src_entry.parent.can_have_child?(dest_entry.name, dest_entry.dir?)
|
124
|
-
Chef::Log.info("Deleting extra entry #{dest_entry.path_for_printing} (purge is on)")
|
125
120
|
dest_entry.delete
|
121
|
+
puts "Delete extra entry #{dest_entry.path_for_printing} (purge is on)"
|
122
|
+
else
|
123
|
+
Chef::Log.info("Not deleting extra entry #{dest_entry.path_for_printing} (purge is off)")
|
126
124
|
end
|
127
125
|
end
|
128
126
|
|
129
127
|
elsif !dest_entry.exists?
|
130
128
|
if dest_entry.parent.can_have_child?(src_entry.name, src_entry.dir?)
|
131
129
|
if src_entry.dir?
|
132
|
-
Chef::Log.info("Creating #{dest_entry.path_for_printing}/")
|
133
130
|
new_dest_dir = dest_entry.parent.create_child(src_entry.name, nil)
|
131
|
+
puts "Created #{dest_entry.path_for_printing}/"
|
134
132
|
# Directory creation is recursive.
|
135
133
|
if recurse_depth != 0
|
136
134
|
src_entry.children.each do |src_child|
|
@@ -139,8 +137,8 @@ module ChefFS
|
|
139
137
|
end
|
140
138
|
end
|
141
139
|
else
|
142
|
-
Chef::Log.info("Creating #{dest_entry.path_for_printing}")
|
143
140
|
dest_entry.parent.create_child(src_entry.name, src_entry.read)
|
141
|
+
puts "Created #{dest_entry.path_for_printing}"
|
144
142
|
end
|
145
143
|
end
|
146
144
|
|
@@ -163,9 +161,9 @@ module ChefFS
|
|
163
161
|
# Both are files! Copy them unless we're sure they are the same.
|
164
162
|
different, src_value, dest_value = ChefFS::Diff.diff_files_quick(src_entry, dest_entry)
|
165
163
|
if different || different == nil
|
166
|
-
Chef::Log.info("Copying #{src_entry.path_for_printing} to #{dest_entry.path_for_printing}")
|
167
164
|
src_value = src_entry.read if src_value == :not_retrieved
|
168
165
|
dest_entry.write(src_value)
|
166
|
+
puts "Updated #{dest_entry.path_for_printing}"
|
169
167
|
end
|
170
168
|
end
|
171
169
|
end
|
@@ -1,7 +1,8 @@
|
|
1
1
|
require 'chef_fs/file_system/base_fs_dir'
|
2
2
|
require 'chef_fs/file_system/rest_list_dir'
|
3
|
-
require 'chef_fs/file_system/data_bags_dir'
|
4
3
|
require 'chef_fs/file_system/cookbooks_dir'
|
4
|
+
require 'chef_fs/file_system/data_bags_dir'
|
5
|
+
require 'chef_fs/file_system/nodes_dir'
|
5
6
|
|
6
7
|
module ChefFS
|
7
8
|
module FileSystem
|
@@ -42,7 +43,7 @@ module ChefFS
|
|
42
43
|
CookbooksDir.new(self),
|
43
44
|
DataBagsDir.new(self),
|
44
45
|
RestListDir.new("environments", self),
|
45
|
-
|
46
|
+
NodesDir.new(self),
|
46
47
|
RestListDir.new("roles", self),
|
47
48
|
# RestListDir.new("sandboxes", self)
|
48
49
|
]
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'chef_fs/file_system/base_fs_dir'
|
2
|
+
require 'chef_fs/file_system/rest_list_entry'
|
3
|
+
require 'chef_fs/file_system/not_found_error'
|
4
|
+
|
5
|
+
module ChefFS
|
6
|
+
module FileSystem
|
7
|
+
class NodesDir < RestListDir
|
8
|
+
def initialize(parent)
|
9
|
+
super("nodes", parent)
|
10
|
+
end
|
11
|
+
|
12
|
+
# Override children to respond to environment
|
13
|
+
def children
|
14
|
+
@children ||= begin
|
15
|
+
env_api_path = environment ? "environments/#{environment}/#{api_path}" : api_path
|
16
|
+
rest.get_rest(env_api_path).keys.map { |key| RestListEntry.new("#{key}.json", self, true) }
|
17
|
+
rescue Net::HTTPServerException
|
18
|
+
if $!.response.code == "404"
|
19
|
+
raise ChefFS::FileSystem::NotFoundError.new($!), "#{path_for_printing} not found"
|
20
|
+
else
|
21
|
+
raise
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -1,10 +1,8 @@
|
|
1
1
|
require 'chef_fs/file_system/base_fs_object'
|
2
2
|
require 'chef_fs/file_system/not_found_error'
|
3
|
-
# TODO: these are needed for rest.get_rest() to work. This seems strange.
|
4
3
|
require 'chef/role'
|
5
4
|
require 'chef/node'
|
6
5
|
|
7
|
-
# TODO: take environment into account
|
8
6
|
module ChefFS
|
9
7
|
module FileSystem
|
10
8
|
class RestListEntry < BaseFSObject
|
@@ -18,7 +16,7 @@ module ChefFS
|
|
18
16
|
raise "Invalid name #{path}: must end in .json"
|
19
17
|
end
|
20
18
|
api_child_name = name[0,name.length-5]
|
21
|
-
|
19
|
+
"#{parent.api_path}/#{api_child_name}"
|
22
20
|
end
|
23
21
|
|
24
22
|
def environment
|
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.3.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -42,6 +42,7 @@ files:
|
|
42
42
|
- lib/chef_fs/file_system/data_bags_dir.rb
|
43
43
|
- lib/chef_fs/file_system/file_system_entry.rb
|
44
44
|
- lib/chef_fs/file_system/file_system_root_dir.rb
|
45
|
+
- lib/chef_fs/file_system/nodes_dir.rb
|
45
46
|
- lib/chef_fs/file_system/nonexistent_fs_object.rb
|
46
47
|
- lib/chef_fs/file_system/not_found_error.rb
|
47
48
|
- lib/chef_fs/file_system/rest_list_dir.rb
|