Skip to content
This repository has been archived by the owner on Jul 14, 2021. It is now read-only.

Commit

Permalink
Fix incorrect version in cookbook manifest
Browse files Browse the repository at this point in the history
CookbookVersion does not clear its memoized manifest data when input
data is mutated; this results in an invalid `name` field when ChefDK
updates the version number.
  • Loading branch information
danielsdeleo committed Oct 31, 2014
1 parent 0bbb4c3 commit 9e47215
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/chef-dk/policyfile/read_cookbook_for_compat_mode_upload.rb
Expand Up @@ -15,8 +15,9 @@
# limitations under the License.
#

# This fixes a missing require in chef/digester:
require 'singleton'
require 'chef/cookbook/cookbook_version_loader'

require 'chef/cookbook/chefignore'

module ChefDK
Expand Down Expand Up @@ -47,6 +48,15 @@ def cookbook_version
begin
cookbook_version = loader.cookbook_version
cookbook_version.version = version_override

# Fixup manifest.
# What happens is, the 'manifest' representation of cookbook
# version is created, it has a "name" field like foo-1.0.0, then we
# change the version to 1234.5678.9876 but the manifest is not
# regenerated so erchef rejects our upload b/c the name field
# doesn't match the expected `$cookbook_name-$version` based on the
# other fields.
cookbook_version.manifest[:name] = "#{cookbook_version.name}-#{version_override}"
cookbook_version.freeze_version
cookbook_version
end
Expand Down
Expand Up @@ -56,6 +56,10 @@
expect(reader.cookbook_version.frozen_version?).to be true
end

it "fixes up the cookbook manifest name" do
expect(reader.cookbook_version.manifest["name"]).to eq("noignore-#{version_override}")
end

context "when a cookbook has a chefignore file" do

let(:directory_path) { File.join(fixtures_path, "cookbook_cache/baz-f59ee7a5bca6a4e606b67f7f856b768d847c39bb") }
Expand Down

0 comments on commit 9e47215

Please sign in to comment.