knife-essentials 0.7.6 → 0.8

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.
Files changed (46) hide show
  1. data/Rakefile +2 -2
  2. data/lib/chef/knife/{delete.rb → delete_essentials.rb} +10 -2
  3. data/lib/chef/knife/dependencies_essentials.rb +117 -0
  4. data/lib/chef/knife/{diff.rb → diff_essentials.rb} +3 -1
  5. data/lib/chef/knife/{download.rb → download_essentials.rb} +9 -4
  6. data/lib/chef/knife/{list.rb → list_essentials.rb} +8 -2
  7. data/lib/chef/knife/{raw.rb → raw_essentials.rb} +2 -0
  8. data/lib/chef/knife/{show.rb → show_essentials.rb} +3 -1
  9. data/lib/chef/knife/{upload.rb → upload_essentials.rb} +9 -4
  10. data/lib/chef_fs/command_line.rb +18 -0
  11. data/lib/chef_fs/file_pattern.rb +18 -0
  12. data/lib/chef_fs/file_system.rb +18 -1
  13. data/lib/chef_fs/file_system/base_fs_dir.rb +18 -0
  14. data/lib/chef_fs/file_system/base_fs_object.rb +19 -1
  15. data/lib/chef_fs/file_system/chef_repository_file_system_entry.rb +49 -8
  16. data/lib/chef_fs/file_system/chef_repository_file_system_root_dir.rb +62 -3
  17. data/lib/chef_fs/file_system/chef_server_root_dir.rb +18 -0
  18. data/lib/chef_fs/file_system/cookbook_dir.rb +26 -0
  19. data/lib/chef_fs/file_system/cookbook_file.rb +18 -0
  20. data/lib/chef_fs/file_system/cookbook_subdir.rb +18 -0
  21. data/lib/chef_fs/file_system/cookbooks_dir.rb +18 -2
  22. data/lib/chef_fs/file_system/data_bag_dir.rb +18 -0
  23. data/lib/chef_fs/file_system/data_bag_item.rb +18 -0
  24. data/lib/chef_fs/file_system/data_bags_dir.rb +18 -0
  25. data/lib/chef_fs/file_system/file_system_entry.rb +18 -0
  26. data/lib/chef_fs/file_system/file_system_error.rb +18 -0
  27. data/lib/chef_fs/file_system/file_system_root_dir.rb +18 -0
  28. data/lib/chef_fs/file_system/multiplexed_dir.rb +46 -0
  29. data/lib/chef_fs/file_system/must_delete_recursively_error.rb +18 -0
  30. data/lib/chef_fs/file_system/nodes_dir.rb +18 -0
  31. data/lib/chef_fs/file_system/nonexistent_fs_object.rb +18 -0
  32. data/lib/chef_fs/file_system/not_found_error.rb +18 -0
  33. data/lib/chef_fs/file_system/rest_list_dir.rb +18 -0
  34. data/lib/chef_fs/file_system/rest_list_entry.rb +18 -0
  35. data/lib/chef_fs/knife.rb +128 -18
  36. data/lib/chef_fs/path_utils.rb +19 -1
  37. data/lib/chef_fs/version.rb +1 -1
  38. data/spec/chef_fs/diff_spec.rb +69 -44
  39. data/spec/chef_fs/file_pattern_spec.rb +497 -479
  40. data/spec/chef_fs/file_system/chef_server_root_dir_spec.rb +18 -0
  41. data/spec/chef_fs/file_system/cookbooks_dir_spec.rb +18 -0
  42. data/spec/chef_fs/file_system/data_bags_dir_spec.rb +18 -0
  43. data/spec/chef_fs/file_system_spec.rb +124 -106
  44. data/spec/support/file_system_support.rb +93 -75
  45. metadata +12 -11
  46. data/lib/chef/sandbox_uploader.rb +0 -208
@@ -1,10 +1,69 @@
1
+ #
2
+ # Author:: John Keiser (<jkeiser@opscode.com>)
3
+ # Copyright:: Copyright (c) 2012 Opscode, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require 'chef_fs/file_system/base_fs_dir'
1
20
  require 'chef_fs/file_system/chef_repository_file_system_entry'
21
+ require 'chef_fs/file_system/multiplexed_dir'
2
22
 
3
23
  module ChefFS
4
24
  module FileSystem
5
- class ChefRepositoryFileSystemRootDir < ChefRepositoryFileSystemEntry
6
- def initialize(file_path)
7
- super("", nil, file_path)
25
+ class ChefRepositoryFileSystemRootDir < BaseFSDir
26
+ def initialize(child_paths)
27
+ super("", nil)
28
+ @child_paths = child_paths
29
+ end
30
+
31
+ attr_reader :child_paths
32
+
33
+ def children
34
+ @children ||= child_paths.keys.map { |name| make_child_entry(name) }.select { |child| !child.nil? }
35
+ end
36
+
37
+ def can_have_child?(name, is_dir)
38
+ child_paths.has_key?(name) && is_dir
39
+ end
40
+
41
+ def create_child(name, file_contents = nil)
42
+ child_paths[name].each do |path|
43
+ Dir.mkdir(path)
44
+ end
45
+ make_child_entry(name)
46
+ end
47
+
48
+ def ignore_empty_directories?
49
+ false
50
+ end
51
+
52
+ def chefignore
53
+ nil
54
+ end
55
+
56
+ private
57
+
58
+ def make_child_entry(name)
59
+ paths = child_paths[name].select do |path|
60
+ File.exists?(path)
61
+ end
62
+ if paths.size == 0
63
+ return nil
64
+ end
65
+ dirs = paths.map { |path| ChefRepositoryFileSystemEntry.new(name, self, path) }
66
+ MultiplexedDir.new(dirs)
8
67
  end
9
68
  end
10
69
  end
@@ -1,3 +1,21 @@
1
+ #
2
+ # Author:: John Keiser (<jkeiser@opscode.com>)
3
+ # Copyright:: Copyright (c) 2012 Opscode, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
1
19
  require 'chef_fs/file_system/base_fs_dir'
2
20
  require 'chef_fs/file_system/rest_list_dir'
3
21
  require 'chef_fs/file_system/cookbooks_dir'
@@ -1,3 +1,21 @@
1
+ #
2
+ # Author:: John Keiser (<jkeiser@opscode.com>)
3
+ # Copyright:: Copyright (c) 2012 Opscode, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
1
19
  require 'chef_fs/file_system/rest_list_dir'
2
20
  require 'chef_fs/file_system/cookbook_subdir'
3
21
  require 'chef_fs/file_system/cookbook_file'
@@ -94,6 +112,14 @@ module ChefFS
94
112
  raise ChefFS::FileSystem::NotFoundError, path_for_printing
95
113
  end
96
114
 
115
+ def delete(recurse)
116
+ if recurse
117
+ rest.delete_rest(api_path)
118
+ else
119
+ raise ChefFS::FileSystem::MustDeleteRecursivelyError.new, "#{path_for_printing} must be deleted recursively"
120
+ end
121
+ end
122
+
97
123
  def exists?
98
124
  if !@versions
99
125
  child = parent.children.select { |child| child.name == name }.first
@@ -1,3 +1,21 @@
1
+ #
2
+ # Author:: John Keiser (<jkeiser@opscode.com>)
3
+ # Copyright:: Copyright (c) 2012 Opscode, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
1
19
  require 'chef_fs/file_system/base_fs_object'
2
20
  require 'digest/md5'
3
21
 
@@ -1,3 +1,21 @@
1
+ #
2
+ # Author:: John Keiser (<jkeiser@opscode.com>)
3
+ # Copyright:: Copyright (c) 2012 Opscode, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
1
19
  require 'chef_fs/file_system/base_fs_dir'
2
20
 
3
21
  module ChefFS
@@ -1,3 +1,21 @@
1
+ #
2
+ # Author:: John Keiser (<jkeiser@opscode.com>)
3
+ # Copyright:: Copyright (c) 2012 Opscode, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
1
19
  require 'chef_fs/file_system/rest_list_dir'
2
20
  require 'chef_fs/file_system/cookbook_dir'
3
21
 
@@ -29,10 +47,8 @@ module ChefFS
29
47
  uploader = Chef::CookbookUploader.new(other_cookbook_version, other.parent.file_path)
30
48
  # Chef 11 changes this API
31
49
  if uploader.respond_to?(:upload_cookbook)
32
- puts "upload_cookbook"
33
50
  uploader.upload_cookbook
34
51
  else
35
- puts "upload_cookbooks"
36
52
  uploader.upload_cookbooks
37
53
  end
38
54
  rescue Net::HTTPServerException => e
@@ -1,3 +1,21 @@
1
+ #
2
+ # Author:: John Keiser (<jkeiser@opscode.com>)
3
+ # Copyright:: Copyright (c) 2012 Opscode, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
1
19
  require 'chef_fs/file_system/rest_list_dir'
2
20
  require 'chef_fs/file_system/data_bag_item'
3
21
  require 'chef_fs/file_system/not_found_error'
@@ -1,3 +1,21 @@
1
+ #
2
+ # Author:: John Keiser (<jkeiser@opscode.com>)
3
+ # Copyright:: Copyright (c) 2012 Opscode, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
1
19
  require 'chef_fs/file_system/rest_list_entry'
2
20
 
3
21
  module ChefFS
@@ -1,3 +1,21 @@
1
+ #
2
+ # Author:: John Keiser (<jkeiser@opscode.com>)
3
+ # Copyright:: Copyright (c) 2012 Opscode, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
1
19
  require 'chef_fs/file_system/rest_list_dir'
2
20
  require 'chef_fs/file_system/data_bag_dir'
3
21
 
@@ -1,3 +1,21 @@
1
+ #
2
+ # Author:: John Keiser (<jkeiser@opscode.com>)
3
+ # Copyright:: Copyright (c) 2012 Opscode, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
1
19
  require 'chef_fs/file_system/base_fs_dir'
2
20
  require 'chef_fs/file_system/rest_list_dir'
3
21
  require 'chef_fs/file_system/not_found_error'
@@ -1,3 +1,21 @@
1
+ #
2
+ # Author:: John Keiser (<jkeiser@opscode.com>)
3
+ # Copyright:: Copyright (c) 2012 Opscode, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
1
19
  module ChefFS
2
20
  module FileSystem
3
21
  class FileSystemError < StandardError
@@ -1,3 +1,21 @@
1
+ #
2
+ # Author:: John Keiser (<jkeiser@opscode.com>)
3
+ # Copyright:: Copyright (c) 2012 Opscode, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
1
19
  require 'chef_fs/file_system/file_system_entry'
2
20
 
3
21
  module ChefFS
@@ -0,0 +1,46 @@
1
+ require 'chef_fs/file_system/base_fs_object'
2
+ require 'chef_fs/file_system/nonexistent_fs_object'
3
+
4
+ module ChefFS
5
+ module FileSystem
6
+ class MultiplexedDir < BaseFSDir
7
+ def initialize(*multiplexed_dirs)
8
+ @multiplexed_dirs = multiplexed_dirs.flatten
9
+ super(@multiplexed_dirs[0].name, @multiplexed_dirs[0].parent)
10
+ end
11
+
12
+ attr_reader :multiplexed_dirs
13
+
14
+ def write_dir
15
+ multiplexed_dirs[0]
16
+ end
17
+
18
+ def children
19
+ @children ||= begin
20
+ result = []
21
+ seen = {}
22
+ # If multiple things have the same name, the first one wins.
23
+ multiplexed_dirs.each do |dir|
24
+ dir.children.each do |child|
25
+ if seen[child.name]
26
+ Chef::Log.warn("Child with name '#{child.name}' found in multiple directories: #{child} and #{seen[child.name]}")
27
+ else
28
+ result << child
29
+ seen[child.name] = child
30
+ end
31
+ end
32
+ end
33
+ result
34
+ end
35
+ end
36
+
37
+ def can_have_child?(name, is_dir)
38
+ write_dir.can_have_child?(name, is_dir)
39
+ end
40
+
41
+ def create_child(name, file_contents = nil)
42
+ write_dir.create_child(name, file_contents)
43
+ end
44
+ end
45
+ end
46
+ end
@@ -1,3 +1,21 @@
1
+ #
2
+ # Author:: John Keiser (<jkeiser@opscode.com>)
3
+ # Copyright:: Copyright (c) 2012 Opscode, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
1
19
  require 'chef_fs/file_system/file_system_error'
2
20
 
3
21
  module ChefFS
@@ -1,3 +1,21 @@
1
+ #
2
+ # Author:: John Keiser (<jkeiser@opscode.com>)
3
+ # Copyright:: Copyright (c) 2012 Opscode, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
1
19
  require 'chef_fs/file_system/base_fs_dir'
2
20
  require 'chef_fs/file_system/rest_list_entry'
3
21
  require 'chef_fs/file_system/not_found_error'
@@ -1,3 +1,21 @@
1
+ #
2
+ # Author:: John Keiser (<jkeiser@opscode.com>)
3
+ # Copyright:: Copyright (c) 2012 Opscode, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
1
19
  require 'chef_fs/file_system/base_fs_object'
2
20
  require 'chef_fs/file_system/not_found_error'
3
21