Class: ChefCLI::Policyfile::ReadCookbookForCompatModeUpload
- Inherits:
-
Object
- Object
- ChefCLI::Policyfile::ReadCookbookForCompatModeUpload
- Defined in:
- lib/chef-cli/policyfile/read_cookbook_for_compat_mode_upload.rb
Overview
TODO: when compat mode is removed, this class should be removed and the file should be renamed
Instance Attribute Summary collapse
-
#cookbook_name ⇒ Object
readonly
Returns the value of attribute cookbook_name.
-
#directory_path ⇒ Object
readonly
Returns the value of attribute directory_path.
-
#version_override ⇒ Object
readonly
Returns the value of attribute version_override.
Class Method Summary collapse
-
.load(name, version_override, directory_path) ⇒ Object
Convenience method to load a cookbook, set up name and version overrides as necessary, and return a Chef::CookbookVersion object.
Instance Method Summary collapse
- #chefignore ⇒ Object
- #cookbook_version ⇒ Object
-
#initialize(cookbook_name, version_override, directory_path) ⇒ ReadCookbookForCompatModeUpload
constructor
A new instance of ReadCookbookForCompatModeUpload.
- #loader ⇒ Object
Constructor Details
#initialize(cookbook_name, version_override, directory_path) ⇒ ReadCookbookForCompatModeUpload
Returns a new instance of ReadCookbookForCompatModeUpload.
79 80 81 82 83 84 85 86 |
# File 'lib/chef-cli/policyfile/read_cookbook_for_compat_mode_upload.rb', line 79 def initialize(cookbook_name, version_override, directory_path) @cookbook_name = cookbook_name @version_override = version_override @directory_path = directory_path @cookbook_version = nil @loader = nil end |
Instance Attribute Details
#cookbook_name ⇒ Object (readonly)
Returns the value of attribute cookbook_name.
75 76 77 |
# File 'lib/chef-cli/policyfile/read_cookbook_for_compat_mode_upload.rb', line 75 def cookbook_name @cookbook_name end |
#directory_path ⇒ Object (readonly)
Returns the value of attribute directory_path.
76 77 78 |
# File 'lib/chef-cli/policyfile/read_cookbook_for_compat_mode_upload.rb', line 76 def directory_path @directory_path end |
#version_override ⇒ Object (readonly)
Returns the value of attribute version_override.
77 78 79 |
# File 'lib/chef-cli/policyfile/read_cookbook_for_compat_mode_upload.rb', line 77 def version_override @version_override end |
Class Method Details
.load(name, version_override, directory_path) ⇒ Object
Convenience method to load a cookbook, set up name and version overrides as necessary, and return a Chef::CookbookVersion object.
71 72 73 |
# File 'lib/chef-cli/policyfile/read_cookbook_for_compat_mode_upload.rb', line 71 def self.load(name, version_override, directory_path) new(name, version_override, directory_path).cookbook_version end |
Instance Method Details
#chefignore ⇒ Object
118 119 120 |
# File 'lib/chef-cli/policyfile/read_cookbook_for_compat_mode_upload.rb', line 118 def chefignore @chefignore ||= Chef::Cookbook::Chefignore.new(File.join(directory_path, "chefignore")) end |
#cookbook_version ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/chef-cli/policyfile/read_cookbook_for_compat_mode_upload.rb', line 88 def cookbook_version @cookbook_version ||= begin cookbook_version = loader.cookbook_version # TODO: don't do this for non-compat mode cookbook_version.version = version_override # TODO: don't do this either # 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 end |
#loader ⇒ Object
109 110 111 112 113 114 115 116 |
# File 'lib/chef-cli/policyfile/read_cookbook_for_compat_mode_upload.rb', line 109 def loader @loader ||= begin cbvl = Chef::Cookbook::CookbookVersionLoader.new(directory_path, chefignore) cbvl.load! cbvl end end |