diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2017-09-07 09:45:58 -0700 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2017-09-07 09:45:58 -0700 |
commit | a5b955c1612cbdf215bdfc0530903237025d0677 (patch) | |
tree | 71d1a626e9f10414f4cfa9f08ec2eb5ab4295383 | |
parent | 02b6ca209f91b3d2777c476b650dc95aa3044c02 (diff) | |
download | chef-lcg/rfc-045.tar.gz |
WIPlcg/rfc-045
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
6 files changed, 116 insertions, 5 deletions
diff --git a/lib/chef/chef_fs/chef_fs_data_store.rb b/lib/chef/chef_fs/chef_fs_data_store.rb index 6b3e830f8d..e8777c6303 100644 --- a/lib/chef/chef_fs/chef_fs_data_store.rb +++ b/lib/chef/chef_fs/chef_fs_data_store.rb @@ -720,6 +720,9 @@ class Chef # /acls/containers|nodes|... do NOT drop into the next elsif, and do # not get .json appended + # /nodes/current/x.json + elsif path[1] == "current" + path[-1] = "#{path[-1]}.json" # /nodes|clients|.../x.json elsif path.length == 2 path[-1] = "#{path[-1]}.json" diff --git a/lib/chef/chef_fs/data_handler/current_data_handler.rb b/lib/chef/chef_fs/data_handler/current_data_handler.rb new file mode 100644 index 0000000000..0e6fd6a29b --- /dev/null +++ b/lib/chef/chef_fs/data_handler/current_data_handler.rb @@ -0,0 +1,33 @@ +require "chef/chef_fs/data_handler/data_handler_base" +require "chef/node" + +class Chef + module ChefFS + module DataHandler + class CurrentDataHandler < DataHandlerBase + def normalize(node, entry) + result = normalize_hash(node, { + "name" => remove_dot_json(entry.name), + #"json_class" => "Chef::Node", + #"chef_type" => "node", + "override" => {}, + "default" => {}, + "automatic" => {}, + }) + result["run_list"] = normalize_run_list(result["run_list"]) + result + end + + def preserve_key?(key) + return key == "name" + end + + def chef_class + Chef::Node + end + + # Nodes do not support .rb files + end + end + end +end diff --git a/lib/chef/chef_fs/data_handler/node_data_handler.rb b/lib/chef/chef_fs/data_handler/node_data_handler.rb index 36a7bf545b..7629413eb5 100644 --- a/lib/chef/chef_fs/data_handler/node_data_handler.rb +++ b/lib/chef/chef_fs/data_handler/node_data_handler.rb @@ -11,10 +11,7 @@ class Chef "json_class" => "Chef::Node", "chef_type" => "node", "chef_environment" => "_default", - "override" => {}, "normal" => {}, - "default" => {}, - "automatic" => {}, "run_list" => [], }) result["run_list"] = normalize_run_list(result["run_list"]) diff --git a/lib/chef/chef_fs/file_system/repository/current.rb b/lib/chef/chef_fs/file_system/repository/current.rb new file mode 100644 index 0000000000..3d4580c1a4 --- /dev/null +++ b/lib/chef/chef_fs/file_system/repository/current.rb @@ -0,0 +1,38 @@ +# +# Author:: Thom May (<thom@chef.io>) +# Copyright:: Copyright 2013-2016, Chef Software Inc. +# License:: Apache License, Version 2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +require "chef/chef_fs/data_handler/current_data_handler" +require "chef/chef_fs/file_system/repository/base_file" + +class Chef + module ChefFS + module FileSystem + module Repository + + class Current < BaseFile + + def initialize(name, parent) + @data_handler = Chef::ChefFS::DataHandler::CurrentDataHandler.new + super + end + + end + end + end + end +end diff --git a/lib/chef/chef_fs/file_system/repository/current_dir.rb b/lib/chef/chef_fs/file_system/repository/current_dir.rb new file mode 100644 index 0000000000..3d7aaa41be --- /dev/null +++ b/lib/chef/chef_fs/file_system/repository/current_dir.rb @@ -0,0 +1,36 @@ +# +# Author:: John Keiser (<jkeiser@chef.io>) +# Author:: Ho-Sheng Hsiao (<hosh@chef.io>) +# Copyright:: Copyright 2012-2016, Chef Software Inc. +# License:: Apache License, Version 2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +require "chef/chef_fs/file_system/repository/current" +require "chef/chef_fs/file_system/repository/directory" + +class Chef + module ChefFS + module FileSystem + module Repository + class CurrentDir < Repository::Directory + + def make_child_entry(child_name) + Current.new(child_name, self) + end + end + end + end + end +end diff --git a/lib/chef/chef_fs/file_system/repository/nodes_dir.rb b/lib/chef/chef_fs/file_system/repository/nodes_dir.rb index 33ca7ca709..4e97c75d8c 100644 --- a/lib/chef/chef_fs/file_system/repository/nodes_dir.rb +++ b/lib/chef/chef_fs/file_system/repository/nodes_dir.rb @@ -18,8 +18,8 @@ # require "chef/chef_fs/file_system/repository/node" +require "chef/chef_fs/file_system/repository/current_dir" require "chef/chef_fs/file_system/repository/directory" -require "chef/chef_fs/file_system/exceptions" class Chef module ChefFS @@ -28,7 +28,11 @@ class Chef class NodesDir < Repository::Directory def make_child_entry(child_name) - Node.new(child_name, self) + if child_name == "current" + CurrentDir.new(child_name, self) + else + Node.new(child_name, self) + end end end end |