Method: Chef::CookbookVersion.available_versions

Defined in:
lib/chef/cookbook_version.rb

.available_versions(cookbook_name) ⇒ Object

Given a cookbook_name, get a list of all versions that exist on the server.

Returns

[String]

Array of cookbook versions, which are strings like ‘x.y.z’

nil

if the cookbook doesn’t exist. an error will also be logged.



557
558
559
560
561
562
563
564
565
566
567
568
# File 'lib/chef/cookbook_version.rb', line 557

def self.available_versions(cookbook_name)
  chef_server_rest.get("cookbooks/#{cookbook_name}")[cookbook_name]["versions"].map do |cb|
    cb["version"]
  end
rescue Net::HTTPClientException => e
  if /^404/.match?(e.to_s)
    Chef::Log.error("Cannot find a cookbook named #{cookbook_name}")
    nil
  else
    raise
  end
end