chef 12.9.41-universal-mingw32 → 12.10.24-universal-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (132) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +52 -13
  3. data/README.md +145 -0
  4. data/Rakefile +4 -14
  5. data/VERSION +1 -1
  6. data/acceptance/.gitignore +0 -1
  7. data/acceptance/Gemfile +2 -2
  8. data/acceptance/Gemfile.lock +235 -0
  9. data/acceptance/fips/.kitchen.yml +5 -1
  10. data/acceptance/fips/test/integration/{fips → fips-integration}/serverspec/Gemfile +0 -0
  11. data/acceptance/fips/test/integration/fips-integration/serverspec/fips-integration_spec.rb +51 -0
  12. data/acceptance/fips/test/integration/fips-unit-functional/serverspec/Gemfile +3 -0
  13. data/acceptance/fips/test/integration/fips-unit-functional/serverspec/fips-unit-functional_spec.rb +56 -0
  14. data/{chef-windows.gemspec → chef-universal-mingw32.gemspec} +0 -0
  15. data/chef.gemspec +0 -6
  16. data/{lib → lib-backcompat}/chef/chef_fs/file_system/already_exists_error.rb +0 -0
  17. data/{lib → lib-backcompat}/chef/chef_fs/file_system/cookbook_frozen_error.rb +0 -0
  18. data/{lib → lib-backcompat}/chef/chef_fs/file_system/default_environment_cannot_be_modified_error.rb +0 -0
  19. data/{lib → lib-backcompat}/chef/chef_fs/file_system/file_system_error.rb +0 -0
  20. data/{lib → lib-backcompat}/chef/chef_fs/file_system/must_delete_recursively_error.rb +0 -0
  21. data/{lib → lib-backcompat}/chef/chef_fs/file_system/not_found_error.rb +0 -0
  22. data/{lib → lib-backcompat}/chef/chef_fs/file_system/operation_failed_error.rb +0 -0
  23. data/{lib → lib-backcompat}/chef/chef_fs/file_system/operation_not_allowed_error.rb +0 -0
  24. data/lib-backcompat/chef/chef_fs/file_system/repository/chef_repository_file_system_acls_dir.rb +5 -0
  25. data/lib-backcompat/chef/chef_fs/file_system/repository/chef_repository_file_system_client_keys_dir.rb +5 -0
  26. data/lib-backcompat/chef/chef_fs/file_system/repository/chef_repository_file_system_entry.rb +6 -0
  27. data/lib-backcompat/chef/chef_fs/file_system/repository/chef_repository_file_system_policies_dir.rb +5 -0
  28. data/{lib → lib-backcompat}/chef/chef_fs/file_system/repository/file_system_root_dir.rb +1 -0
  29. data/lib/chef/chef_fs/file_system/repository/acl.rb +38 -0
  30. data/lib/chef/chef_fs/file_system/repository/{chef_repository_file_system_acls_dir.rb → acls_dir.rb} +14 -5
  31. data/lib/chef/chef_fs/file_system/repository/acls_sub_dir.rb +42 -0
  32. data/lib/chef/chef_fs/file_system/repository/base_file.rb +120 -0
  33. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_entry.rb +1 -1
  34. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb +36 -32
  35. data/lib/chef/chef_fs/file_system/repository/client.rb +38 -0
  36. data/lib/chef/chef_fs/file_system/repository/client_key.rb +38 -0
  37. data/lib/chef/chef_fs/file_system/repository/{chef_repository_file_system_client_keys_dir.rb → client_keys_dir.rb} +9 -5
  38. data/lib/chef/chef_fs/file_system/repository/client_keys_sub_dir.rb +42 -0
  39. data/lib/chef/chef_fs/file_system/repository/clients_dir.rb +40 -0
  40. data/lib/chef/chef_fs/file_system/repository/container.rb +38 -0
  41. data/lib/chef/chef_fs/file_system/repository/containers_dir.rb +41 -0
  42. data/lib/chef/chef_fs/file_system/repository/cookbooks_dir.rb +0 -1
  43. data/lib/chef/chef_fs/file_system/repository/data_bag_item.rb +3 -79
  44. data/lib/chef/chef_fs/file_system/repository/directory.rb +15 -2
  45. data/lib/chef/chef_fs/file_system/repository/environment.rb +38 -0
  46. data/lib/chef/chef_fs/file_system/repository/environments_dir.rb +41 -0
  47. data/lib/chef/chef_fs/file_system/repository/file_system_entry.rb +66 -30
  48. data/lib/chef/chef_fs/file_system/repository/group.rb +38 -0
  49. data/lib/chef/chef_fs/file_system/repository/groups_dir.rb +41 -0
  50. data/lib/chef/chef_fs/file_system/repository/node.rb +38 -0
  51. data/lib/chef/chef_fs/file_system/repository/nodes_dir.rb +41 -0
  52. data/lib/chef/chef_fs/file_system/repository/{chef_repository_file_system_policies_dir.rb → policies_dir.rb} +9 -5
  53. data/lib/chef/chef_fs/file_system/repository/policy.rb +38 -0
  54. data/lib/chef/chef_fs/file_system/repository/policy_group.rb +38 -0
  55. data/lib/chef/chef_fs/file_system/repository/policy_groups_dir.rb +41 -0
  56. data/lib/chef/chef_fs/file_system/repository/role.rb +38 -0
  57. data/lib/chef/chef_fs/file_system/repository/roles_dir.rb +41 -0
  58. data/lib/chef/chef_fs/file_system/repository/user.rb +38 -0
  59. data/lib/chef/chef_fs/file_system/repository/users_dir.rb +41 -0
  60. data/lib/chef/dsl/declare_resource.rb +182 -7
  61. data/lib/chef/http/json_input.rb +2 -2
  62. data/lib/chef/knife.rb +1 -1
  63. data/lib/chef/mixin/shell_out.rb +10 -21
  64. data/lib/chef/property.rb +9 -2
  65. data/lib/chef/provider.rb +8 -7
  66. data/lib/chef/provider/apt_repository.rb +8 -6
  67. data/lib/chef/provider/directory.rb +15 -1
  68. data/lib/chef/provider/env/windows.rb +1 -1
  69. data/lib/chef/provider/mdadm.rb +1 -0
  70. data/lib/chef/provider/package/easy_install.rb +2 -0
  71. data/lib/chef/provider/package/rubygems.rb +4 -1
  72. data/lib/chef/provider/package/windows.rb +1 -1
  73. data/lib/chef/recipe.rb +1 -2
  74. data/lib/chef/resource/apt_repository.rb +6 -6
  75. data/lib/chef/resource/mdadm.rb +9 -0
  76. data/lib/chef/resource_collection.rb +5 -0
  77. data/lib/chef/resource_collection/resource_list.rb +10 -0
  78. data/lib/chef/resource_collection/resource_set.rb +14 -11
  79. data/lib/chef/version.rb +1 -1
  80. data/spec/functional/resource/git_spec.rb +1 -3
  81. data/spec/functional/resource/group_spec.rb +5 -5
  82. data/spec/functional/tiny_server_spec.rb +1 -1
  83. data/spec/functional/util/powershell/cmdlet_spec.rb +1 -1
  84. data/spec/functional/win32/registry_spec.rb +3 -3
  85. data/spec/integration/solo/solo_spec.rb +2 -2
  86. data/spec/support/shared/functional/securable_resource.rb +1 -1
  87. data/spec/support/shared/unit/provider/file.rb +3 -3
  88. data/spec/support/shared/unit/windows_script_resource.rb +1 -1
  89. data/spec/unit/application/apply_spec.rb +1 -0
  90. data/spec/unit/chef_fs/file_system/repository/base_file_spec.rb +128 -0
  91. data/spec/unit/chef_fs/file_system/repository/directory_spec.rb +174 -0
  92. data/spec/unit/cookbook/metadata_spec.rb +1 -1
  93. data/spec/unit/dsl/declare_resource_spec.rb +335 -0
  94. data/spec/unit/knife/bootstrap_spec.rb +2 -2
  95. data/spec/unit/mixin/shell_out_spec.rb +4 -0
  96. data/spec/unit/node/attribute_spec.rb +1 -1
  97. data/spec/unit/node/immutable_collections_spec.rb +2 -2
  98. data/spec/unit/node_map_spec.rb +1 -1
  99. data/spec/unit/property/validation_spec.rb +23 -7
  100. data/spec/unit/provider/apt_repository_spec.rb +5 -0
  101. data/spec/unit/provider/apt_update_spec.rb +1 -0
  102. data/spec/unit/provider/directory_spec.rb +0 -7
  103. data/spec/unit/provider/file/content_spec.rb +1 -1
  104. data/spec/unit/provider/mdadm_spec.rb +9 -0
  105. data/spec/unit/provider/package/easy_install_spec.rb +6 -0
  106. data/spec/unit/provider/package/rubygems_spec.rb +8 -4
  107. data/spec/unit/provider/package/yum_spec.rb +1 -1
  108. data/spec/unit/provider/powershell_script_spec.rb +1 -1
  109. data/spec/unit/provider/user/dscl_spec.rb +6 -6
  110. data/spec/unit/recipe_spec.rb +1 -0
  111. data/spec/unit/resource/apt_repository_spec.rb +4 -0
  112. data/spec/unit/resource/file/verification_spec.rb +1 -1
  113. data/spec/unit/resource/file_spec.rb +2 -2
  114. data/spec/unit/resource/mdadm_spec.rb +7 -2
  115. data/spec/unit/resource_collection_spec.rb +30 -0
  116. data/spec/unit/resource_spec.rb +1 -1
  117. data/tasks/bin/bundle-platform +15 -0
  118. data/tasks/bin/bundle-platform.bat +2 -0
  119. data/tasks/bin/create-override-gemfile +110 -0
  120. data/tasks/bin/run_chef_tests +17 -0
  121. data/tasks/bin/run_external_test +47 -0
  122. data/tasks/bundle.rb +97 -0
  123. data/tasks/bundle_util.rb +94 -0
  124. data/tasks/changelog.rb +12 -0
  125. data/tasks/dependencies.rb +147 -0
  126. data/tasks/gemfile_util.rb +390 -0
  127. data/tasks/maintainers.rb +2 -1
  128. data/tasks/rspec.rb +2 -1
  129. metadata +61 -83
  130. data/acceptance/fips/test/integration/fips/serverspec/fips_spec.rb +0 -39
  131. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_entry.rb +0 -83
  132. data/tasks/external_tests.rb +0 -64
@@ -66,13 +66,26 @@ class Chef
66
66
  def children
67
67
  dir_ls.sort.
68
68
  map { |child_name| make_child_entry(child_name) }.
69
- select { |maybe_child| maybe_child.fs_entry_valid? }
69
+ select { |new_child| new_child.fs_entry_valid? && can_have_child?(new_child.name, new_child.dir?) }
70
70
  rescue Errno::ENOENT => e
71
71
  raise Chef::ChefFS::FileSystem::NotFoundError.new(self, e)
72
72
  end
73
73
 
74
74
  def create_child(child_name, file_contents = nil)
75
- make_child_entry(child_name).tap { |c| c.create(file_contents) }
75
+ child = make_child_entry(child_name)
76
+ if child.exists?
77
+ raise Chef::ChefFS::FileSystem::AlreadyExistsError.new(:create_child, child)
78
+ end
79
+ if file_contents
80
+ child.write(file_contents)
81
+ else
82
+ begin
83
+ Dir.mkdir(child.file_path)
84
+ rescue Errno::EEXIST
85
+ raise Chef::ChefFS::FileSystem::AlreadyExistsError.new(:create_child, child)
86
+ end
87
+ end
88
+ child
76
89
  end
77
90
 
78
91
  # An empty children array is an empty dir
@@ -0,0 +1,38 @@
1
+ #
2
+ # Author:: Thom May (<thom@chef.io>)
3
+ # Copyright:: Copyright 2013-2016, Chef Software 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/chef_fs/data_handler/environment_data_handler"
20
+ require "chef/chef_fs/file_system/repository/base_file"
21
+
22
+ class Chef
23
+ module ChefFS
24
+ module FileSystem
25
+ module Repository
26
+
27
+ class Environment < BaseFile
28
+
29
+ def initialize(name, parent)
30
+ @data_handler = Chef::ChefFS::DataHandler::EnvironmentDataHandler.new
31
+ super
32
+ end
33
+
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,41 @@
1
+ #
2
+ # Author:: John Keiser (<jkeiser@chef.io>)
3
+ # Author:: Ho-Sheng Hsiao (<hosh@chef.io>)
4
+ # Copyright:: Copyright 2012-2016, Chef Software Inc.
5
+ # License:: Apache License, Version 2.0
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
18
+ #
19
+
20
+ require "chef/chef_fs/file_system/repository/environment"
21
+ require "chef/chef_fs/data_handler/environment_data_handler"
22
+ require "chef/chef_fs/file_system/repository/directory"
23
+
24
+ class Chef
25
+ module ChefFS
26
+ module FileSystem
27
+ module Repository
28
+ class EnvironmentsDir < Repository::Directory
29
+
30
+ def can_have_child?(name, is_dir)
31
+ !is_dir && File.extname(name) == ".json"
32
+ end
33
+
34
+ def make_child_entry(child_name)
35
+ Environment.new(child_name, self)
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -27,26 +27,64 @@ class Chef
27
27
  module FileSystem
28
28
  module Repository
29
29
  class FileSystemEntry < BaseFSDir
30
- def initialize(name, parent, file_path = nil)
30
+ def initialize(name, parent, file_path = nil, data_handler = nil)
31
31
  super(name, parent)
32
32
  @file_path = file_path || "#{parent.file_path}/#{name}"
33
+ @data_handler = data_handler
33
34
  end
34
35
 
35
36
  attr_reader :file_path
36
37
 
38
+ def write_pretty_json=(value)
39
+ @write_pretty_json = value
40
+ end
41
+
42
+ def write_pretty_json
43
+ @write_pretty_json.nil? ? root.write_pretty_json : @write_pretty_json
44
+ end
45
+
46
+ def data_handler
47
+ @data_handler || parent.data_handler
48
+ end
49
+
37
50
  def path_for_printing
38
51
  file_path
39
52
  end
40
53
 
54
+ def chef_object
55
+ data_handler.chef_object(Chef::JSONCompat.parse(read))
56
+ rescue
57
+ Chef::Log.error("Could not read #{path_for_printing} into a Chef object: #{$!}")
58
+ nil
59
+ end
60
+
61
+ def can_have_child?(name, is_dir)
62
+ !is_dir && File.extname(name) == ".json"
63
+ end
64
+
65
+ def name_valid?
66
+ !name.start_with?(".")
67
+ end
68
+
69
+ # basic implementation to support Repository::Directory API
70
+ def fs_entry_valid?
71
+ name_valid? && File.exist?(file_path)
72
+ end
73
+
74
+ def minimize(file_contents, entry)
75
+ object = Chef::JSONCompat.parse(file_contents)
76
+ object = data_handler.normalize(object, entry)
77
+ object = data_handler.minimize(object, entry)
78
+ Chef::JSONCompat.to_json_pretty(object)
79
+ end
80
+
41
81
  def children
42
82
  # Except cookbooks and data bag dirs, all things must be json files
43
- begin
44
- Dir.entries(file_path).sort.
45
- map { |child_name| make_child_entry(child_name) }.
46
- select { |child| child && can_have_child?(child.name, child.dir?) }
47
- rescue Errno::ENOENT
48
- raise Chef::ChefFS::FileSystem::NotFoundError.new(self, $!)
49
- end
83
+ Dir.entries(file_path).sort.
84
+ map { |child_name| make_child_entry(child_name) }.
85
+ select { |new_child| new_child.fs_entry_valid? && can_have_child?(new_child.name, new_child.dir?) }
86
+ rescue Errno::ENOENT
87
+ raise Chef::ChefFS::FileSystem::NotFoundError.new(self, $!)
50
88
  end
51
89
 
52
90
  def create_child(child_name, file_contents = nil)
@@ -57,13 +95,11 @@ class Chef
57
95
  if file_contents
58
96
  child.write(file_contents)
59
97
  else
60
- begin
61
- Dir.mkdir(child.file_path)
62
- rescue Errno::EEXIST
63
- raise Chef::ChefFS::FileSystem::AlreadyExistsError.new(:create_child, child)
64
- end
98
+ Dir.mkdir(child.file_path)
65
99
  end
66
100
  child
101
+ rescue Errno::EEXIST
102
+ raise Chef::ChefFS::FileSystem::AlreadyExistsError.new(:create_child, child)
67
103
  end
68
104
 
69
105
  def dir?
@@ -71,18 +107,16 @@ class Chef
71
107
  end
72
108
 
73
109
  def delete(recurse)
74
- begin
75
- if dir?
76
- if !recurse
77
- raise MustDeleteRecursivelyError.new(self, $!)
78
- end
79
- FileUtils.rm_r(file_path)
80
- else
81
- File.delete(file_path)
110
+ if dir?
111
+ if !recurse
112
+ raise MustDeleteRecursivelyError.new(self, $!)
82
113
  end
83
- rescue Errno::ENOENT
84
- raise Chef::ChefFS::FileSystem::NotFoundError.new(self, $!)
114
+ FileUtils.rm_r(file_path)
115
+ else
116
+ File.delete(file_path)
85
117
  end
118
+ rescue Errno::ENOENT
119
+ raise Chef::ChefFS::FileSystem::NotFoundError.new(self, $!)
86
120
  end
87
121
 
88
122
  def exists?
@@ -90,18 +124,20 @@ class Chef
90
124
  end
91
125
 
92
126
  def read
93
- begin
94
- File.open(file_path, "rb") { |f| f.read }
95
- rescue Errno::ENOENT
96
- raise Chef::ChefFS::FileSystem::NotFoundError.new(self, $!)
97
- end
127
+ File.open(file_path, "rb") { |f| f.read }
128
+ rescue Errno::ENOENT
129
+ raise Chef::ChefFS::FileSystem::NotFoundError.new(self, $!)
98
130
  end
99
131
 
100
- def write(content)
132
+ def write(file_contents)
133
+ if file_contents && write_pretty_json && File.extname(name) == ".json"
134
+ file_contents = minimize(file_contents, self)
135
+ end
101
136
  File.open(file_path, "wb") do |file|
102
- file.write(content)
137
+ file.write(file_contents)
103
138
  end
104
139
  end
140
+ alias :create :write
105
141
 
106
142
  protected
107
143
 
@@ -0,0 +1,38 @@
1
+ #
2
+ # Author:: Thom May (<thom@chef.io>)
3
+ # Copyright:: Copyright 2013-2016, Chef Software 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/chef_fs/data_handler/group_data_handler"
20
+ require "chef/chef_fs/file_system/repository/base_file"
21
+
22
+ class Chef
23
+ module ChefFS
24
+ module FileSystem
25
+ module Repository
26
+
27
+ class Group < BaseFile
28
+
29
+ def initialize(name, parent)
30
+ @data_handler = Chef::ChefFS::DataHandler::GroupDataHandler.new
31
+ super
32
+ end
33
+
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,41 @@
1
+ #
2
+ # Author:: John Keiser (<jkeiser@chef.io>)
3
+ # Author:: Ho-Sheng Hsiao (<hosh@chef.io>)
4
+ # Copyright:: Copyright 2012-2016, Chef Software Inc.
5
+ # License:: Apache License, Version 2.0
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
18
+ #
19
+
20
+ require "chef/chef_fs/file_system/repository/group"
21
+ require "chef/chef_fs/file_system/repository/directory"
22
+ require "chef/chef_fs/file_system/exceptions"
23
+
24
+ class Chef
25
+ module ChefFS
26
+ module FileSystem
27
+ module Repository
28
+ class GroupsDir < Repository::Directory
29
+
30
+ def can_have_child?(name, is_dir)
31
+ !is_dir && File.extname(name) == ".json"
32
+ end
33
+
34
+ def make_child_entry(child_name)
35
+ Group.new(child_name, self)
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,38 @@
1
+ #
2
+ # Author:: Thom May (<thom@chef.io>)
3
+ # Copyright:: Copyright 2013-2016, Chef Software 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/chef_fs/data_handler/node_data_handler"
20
+ require "chef/chef_fs/file_system/repository/base_file"
21
+
22
+ class Chef
23
+ module ChefFS
24
+ module FileSystem
25
+ module Repository
26
+
27
+ class Node < BaseFile
28
+
29
+ def initialize(name, parent)
30
+ @data_handler = Chef::ChefFS::DataHandler::NodeDataHandler.new
31
+ super
32
+ end
33
+
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,41 @@
1
+ #
2
+ # Author:: John Keiser (<jkeiser@chef.io>)
3
+ # Author:: Ho-Sheng Hsiao (<hosh@chef.io>)
4
+ # Copyright:: Copyright 2012-2016, Chef Software Inc.
5
+ # License:: Apache License, Version 2.0
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
18
+ #
19
+
20
+ require "chef/chef_fs/file_system/repository/node"
21
+ require "chef/chef_fs/file_system/repository/directory"
22
+ require "chef/chef_fs/file_system/exceptions"
23
+
24
+ class Chef
25
+ module ChefFS
26
+ module FileSystem
27
+ module Repository
28
+ class NodesDir < Repository::Directory
29
+
30
+ def can_have_child?(name, is_dir)
31
+ !is_dir && File.extname(name) == ".json"
32
+ end
33
+
34
+ def make_child_entry(child_name)
35
+ Node.new(child_name, self)
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -16,21 +16,25 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require "chef/chef_fs/file_system/repository/chef_repository_file_system_entry"
19
+ require "chef/chef_fs/file_system/repository/policy"
20
+ require "chef/chef_fs/file_system/repository/directory"
20
21
  require "chef/chef_fs/data_handler/policy_data_handler"
21
22
 
22
23
  class Chef
23
24
  module ChefFS
24
25
  module FileSystem
25
26
  module Repository
26
- class ChefRepositoryFileSystemPoliciesDir < ChefRepositoryFileSystemEntry
27
- def initialize(name, parent, path = nil)
28
- super(name, parent, path, Chef::ChefFS::DataHandler::PolicyDataHandler.new)
29
- end
27
+ class PoliciesDir < Repository::Directory
30
28
 
31
29
  def can_have_child?(name, is_dir)
32
30
  !is_dir && name.include?("-")
33
31
  end
32
+
33
+ protected
34
+
35
+ def make_child_entry(child_name)
36
+ Policy.new(child_name, self)
37
+ end
34
38
  end
35
39
  end
36
40
  end