From eb0bea3f91d5b189e39e679389265701cd6084e6 Mon Sep 17 00:00:00 2001 From: John Keiser Date: Fri, 15 Jan 2016 08:51:15 -0800 Subject: Make local cookbook artifacts load correctly --- ...repository_file_system_cookbook_artifact_dir.rb | 41 ++++++++++++++++++++++ ...epository_file_system_cookbook_artifacts_dir.rb | 34 ++++++++++++++++++ .../chef_repository_file_system_root_dir.rb | 3 +- 3 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_artifact_dir.rb create mode 100644 lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_artifacts_dir.rb (limited to 'lib') diff --git a/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_artifact_dir.rb b/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_artifact_dir.rb new file mode 100644 index 0000000000..da9d74a1df --- /dev/null +++ b/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_artifact_dir.rb @@ -0,0 +1,41 @@ +# +# Author:: John Keiser () +# Copyright:: Copyright (c) 2013 Opscode, 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/chef_repository_file_system_cookbook_dir" + +class Chef + module ChefFS + module FileSystem + module Repository + class ChefRepositoryFileSystemCookbookArtifactDir < ChefRepositoryFileSystemCookbookDir + # Override from parent + def cookbook_version + loader = Chef::Cookbook::CookbookVersionLoader.new(file_path, parent.chefignore) + cookbook_name, dash, identifier = name.rpartition('-') + # KLUDGE: We shouldn't have to use instance_variable_set + loader.instance_variable_set(:@cookbook_name, cookbook_name) + loader.load_cookbooks + cookbook_version = loader.cookbook_version + cookbook_version.identifier = identifier + cookbook_version + end + end + end + end + end +end diff --git a/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_artifacts_dir.rb b/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_artifacts_dir.rb new file mode 100644 index 0000000000..a7f83b6d4e --- /dev/null +++ b/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_artifacts_dir.rb @@ -0,0 +1,34 @@ +# +# Author:: John Keiser () +# Copyright:: Copyright (c) 2013 Opscode, 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/chef_repository_file_system_cookbooks_dir" +require "chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_artifact_dir" + +class Chef + module ChefFS + module FileSystem + module Repository + class ChefRepositoryFileSystemCookbookArtifactsDir < ChefRepositoryFileSystemCookbooksDir + def make_child_entry(child_name) + ChefRepositoryFileSystemCookbookArtifactDir.new(child_name, self) + end + end + end + end + end +end diff --git a/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb b/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb index 8d9f2c21ad..a3a3dfc6b9 100644 --- a/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb +++ b/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb @@ -19,6 +19,7 @@ require "chef/chef_fs/file_system/base_fs_dir" require "chef/chef_fs/file_system/repository/chef_repository_file_system_acls_dir" require "chef/chef_fs/file_system/repository/chef_repository_file_system_cookbooks_dir" +require "chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_artifacts_dir" require "chef/chef_fs/file_system/repository/chef_repository_file_system_data_bags_dir" require "chef/chef_fs/file_system/repository/chef_repository_file_system_entry" require "chef/chef_fs/file_system/repository/chef_repository_file_system_policies_dir" @@ -170,7 +171,7 @@ class Chef dirs = paths.map { |path| ChefRepositoryFileSystemCookbooksDir.new(name, self, path) } end when 'cookbook_artifacts' - dirs = paths.map { |path| ChefRepositoryFileSystemVersionedCookbooksDir.new(name, self, path) } + dirs = paths.map { |path| ChefRepositoryFileSystemCookbookArtifactsDir.new(name, self, path) } when "policies" dirs = paths.map { |path| ChefRepositoryFileSystemPoliciesDir.new(name, self, path) } when "data_bags" -- cgit v1.2.1