summaryrefslogtreecommitdiff
path: root/lib/chef
diff options
context:
space:
mode:
authorJohn Keiser <john@johnkeiser.com>2016-01-13 15:08:48 -0800
committerJohn Keiser <john@johnkeiser.com>2016-01-15 09:37:43 -0800
commit15eeec09c22da15370152a40311f085f0aced9e2 (patch)
treefb4aea0b7252b296294f493ddbaa8328a10c390e /lib/chef
parent7fd174277679739fb2c7aa628a26fade406655df (diff)
downloadchef-15eeec09c22da15370152a40311f085f0aced9e2.tar.gz
Make upload cookbook_artifacts work
Diffstat (limited to 'lib/chef')
-rw-r--r--lib/chef/chef_fs/file_system/chef_server/chef_server_root_dir.rb2
-rw-r--r--lib/chef/chef_fs/file_system/chef_server/cookbook_artifact_dir.rb4
-rw-r--r--lib/chef/chef_fs/file_system/chef_server/cookbook_artifacts_dir.rb5
3 files changed, 9 insertions, 2 deletions
diff --git a/lib/chef/chef_fs/file_system/chef_server/chef_server_root_dir.rb b/lib/chef/chef_fs/file_system/chef_server/chef_server_root_dir.rb
index 969cea876e..9c9a0d1001 100644
--- a/lib/chef/chef_fs/file_system/chef_server/chef_server_root_dir.rb
+++ b/lib/chef/chef_fs/file_system/chef_server/chef_server_root_dir.rb
@@ -82,6 +82,7 @@ class Chef
@environment = chef_config[:environment]
@repo_mode = chef_config[:repo_mode]
@versioned_cookbooks = chef_config[:versioned_cookbooks]
+ @policy_document_native_api = chef_config[:policy_document_native_api]
@root_name = root_name
@cookbook_version = options[:cookbook_version] # Used in knife diff and download for server cookbook version
end
@@ -93,6 +94,7 @@ class Chef
attr_reader :repo_mode
attr_reader :cookbook_version
attr_reader :versioned_cookbooks
+ attr_reader :policy_document_native_api
def fs_description
"Chef server at #{chef_server_url} (user #{chef_username}), repo_mode = #{repo_mode}"
diff --git a/lib/chef/chef_fs/file_system/chef_server/cookbook_artifact_dir.rb b/lib/chef/chef_fs/file_system/chef_server/cookbook_artifact_dir.rb
index ad22b6a64c..ff3cde51a8 100644
--- a/lib/chef/chef_fs/file_system/chef_server/cookbook_artifact_dir.rb
+++ b/lib/chef/chef_fs/file_system/chef_server/cookbook_artifact_dir.rb
@@ -27,6 +27,10 @@ class Chef
super(name, parent)
@cookbook_name, dash, @version = name.rpartition('-')
end
+
+ def copy_from(other, options = {})
+ raise OperationNotAllowedError.new(:write, self, nil, "cannot be updated: cookbook artifacts are immutable once uploaded")
+ end
end
end
end
diff --git a/lib/chef/chef_fs/file_system/chef_server/cookbook_artifacts_dir.rb b/lib/chef/chef_fs/file_system/chef_server/cookbook_artifacts_dir.rb
index adc7003013..b001c28dc4 100644
--- a/lib/chef/chef_fs/file_system/chef_server/cookbook_artifacts_dir.rb
+++ b/lib/chef/chef_fs/file_system/chef_server/cookbook_artifacts_dir.rb
@@ -56,7 +56,7 @@ class Chef
# to make this work. So instead, we make a temporary cookbook
# symlinking back to real cookbook, and upload the proxy.
def upload_cookbook(other, options)
- cookbook_name = Chef::ChefFS::FileSystem::Repository::ChefRepositoryFileSystemCookbookDir.canonical_cookbook_name(other.name)
+ cookbook_name, dash, identifier = other.name.rpartition('-')
Dir.mktmpdir do |temp_cookbooks_path|
proxy_cookbook_path = "#{temp_cookbooks_path}/#{cookbook_name}"
@@ -69,10 +69,11 @@ class Chef
proxy_loader.load_cookbooks
cookbook_to_upload = proxy_loader.cookbook_version
+ cookbook_to_upload.identifier = identifier
cookbook_to_upload.freeze_version if options[:freeze]
# Instantiate a new uploader based on the proxy loader
- uploader = Chef::CookbookUploader.new(cookbook_to_upload, :force => options[:force], :rest => root.chef_rest)
+ uploader = Chef::CookbookUploader.new(cookbook_to_upload, force: options[:force], rest: root.chef_rest, policy_mode: true)
with_actual_cookbooks_dir(temp_cookbooks_path) do
uploader.upload_cookbooks