diff options
author | Dan Webb <dan.webb@damacus.io> | 2020-04-18 17:03:39 +0100 |
---|---|---|
committer | Dan Webb <dan.webb@damacus.io> | 2020-04-20 15:52:34 +0100 |
commit | d22ae13fc4d51fd024d0c5e85ef8845215a27ce3 (patch) | |
tree | eb7777f6363a03cda87e69a75655091d494ee0ca /lib/chef/cookbook/metadata.rb | |
parent | fb43c19e2c827cae458578386349651ec8b5588a (diff) | |
download | chef-d22ae13fc4d51fd024d0c5e85ef8845215a27ce3.tar.gz |
Stop handling the deprecated Chef version constraints
handle_deprecated_constraints has been a work around since Chef 10
Remove old specs that checked that the metadata was transformed correctly
Signed-off-by: Daniel Webb <dan.webb@damacus.io>
Diffstat (limited to 'lib/chef/cookbook/metadata.rb')
-rw-r--r-- | lib/chef/cookbook/metadata.rb | 41 |
1 files changed, 20 insertions, 21 deletions
diff --git a/lib/chef/cookbook/metadata.rb b/lib/chef/cookbook/metadata.rb index 2ca769379c..ef0b920b5f 100644 --- a/lib/chef/cookbook/metadata.rb +++ b/lib/chef/cookbook/metadata.rb @@ -481,7 +481,7 @@ class Chef @maintainer_email = o[MAINTAINER_EMAIL] if o.key?(MAINTAINER_EMAIL) @license = o[LICENSE] if o.key?(LICENSE) @platforms = o[PLATFORMS] if o.key?(PLATFORMS) - @dependencies = handle_deprecated_constraints(o[DEPENDENCIES]) if o.key?(DEPENDENCIES) + @dependencies = handle_incorrect_constraints(o[DEPENDENCIES]) if o.key?(DEPENDENCIES) @providing = o[PROVIDING] if o.key?(PROVIDING) @recipes = o[RECIPES] if o.key?(RECIPES) @version = o[VERSION] if o.key?(VERSION) @@ -535,6 +535,25 @@ class Chef ) end + # This method translates version constraint strings from + # cookbooks with the old format. + # + # Before we began respecting version constraints, we allowed + # multiple constraints to be placed on cookbooks, as well as the + # << and >> operators, which are now just < and >. For + # specifications with more than one constraint, we return an + # empty array (otherwise, we're silently abiding only part of + # the contract they have specified to us). If there is only one + # constraint, we are replacing the old << and >> with the new < + # and >. + def handle_incorrect_constraints(specification) + specification.inject(Mash.new) do |acc, (cb, constraints)| + constraints = Array(constraints) + acc[cb] = (constraints.empty? || constraints.size > 1) ? [] : constraints.first + acc + end + end + # Sets the cookbook's issues URL, or returns it. # # === Parameters @@ -738,26 +757,6 @@ class Chef end end end - - # This method translates version constraint strings from - # cookbooks with the old format. - # - # Before we began respecting version constraints, we allowed - # multiple constraints to be placed on cookbooks, as well as the - # << and >> operators, which are now just < and >. For - # specifications with more than one constraint, we return an - # empty array (otherwise, we're silently abiding only part of - # the contract they have specified to us). If there is only one - # constraint, we are replacing the old << and >> with the new < - # and >. - def handle_deprecated_constraints(specification) - specification.inject(Mash.new) do |acc, (cb, constraints)| - constraints = Array(constraints) - acc[cb] = (constraints.empty? || constraints.size > 1) ? [] : constraints.first.gsub(/>>/, ">").gsub(/<</, "<") - acc - end - end - end #== Chef::Cookbook::MinimalMetadata |