You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, attempting to iterate (.all, .each) over all the cookbooks the same way fails. It seems like chef-api is trying to process the JSON response as if it is a URL.
Cookbook.each do |cookbook|
pp cookbook
end
/opt/chefdk/embedded/bin/ruby -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) /Users/rhornsby/projects/git/cookbook_version_check/analyze.rb
ChefAPI::Connection | ===> GET cookbooks...
ChefAPI::Connection | Chef flavor: :open_source
ChefAPI::Connection | ===> Building URI...
ChefAPI::Connection | Detected URI is relative
ChefAPI::Connection | Appending cookbooks to https://chef.ourdomain.org/organizations/our_org
ChefAPI::Connection | ===> Adding request headers...
...
ChefAPI::Connection | Raw response:
/opt/chefdk/embedded/lib/ruby/2.5.0/uri/rfc3986_parser.rb:18:in `rescue in split': bad URI(is not URI?): {"url"=>"https://chef.ourdomain.org/organizations/our_org/cookbooks/vagrant", "versions"=>[{"version"=>"0.8.0", "url"=>"https://chef.ourdomain.org/organizations/our_org/cookbooks/vagrant/0.8.0"}]} (URI::InvalidURIError)
from /opt/chefdk/embedded/lib/ruby/2.5.0/uri/rfc3986_parser.rb:15:in `split'
from /opt/chefdk/embedded/lib/ruby/2.5.0/uri/rfc3986_parser.rb:73:in `parse'
from /opt/chefdk/embedded/lib/ruby/2.5.0/uri/common.rb:237:in `parse'
from /opt/chefdk/embedded/lib/ruby/gems/2.5.0/gems/chef-api-0.8.0/lib/chef-api/connection.rb:340:in `build_uri'
from /opt/chefdk/embedded/lib/ruby/gems/2.5.0/gems/chef-api-0.8.0/lib/chef-api/connection.rb:204:in `request'
from /opt/chefdk/embedded/lib/ruby/gems/2.5.0/gems/chef-api-0.8.0/lib/chef-api/connection.rb:108:in `get'
from /opt/chefdk/embedded/lib/ruby/gems/2.5.0/gems/chef-api-0.8.0/lib/chef-api/resources/base.rb:366:in `block in each'
from /opt/chefdk/embedded/lib/ruby/gems/2.5.0/gems/chef-api-0.8.0/lib/chef-api/resources/base.rb:365:in `each'
from /opt/chefdk/embedded/lib/ruby/gems/2.5.0/gems/chef-api-0.8.0/lib/chef-api/resources/base.rb:365:in `each'
from /Users/rhornsby/projects/git/cookbook_version_check/analyze.rb:24:in `<top (required)>'
from -e:1:in `load'
from -e:1:in `<main>'
ChefAPI::Connection |
### ***** JSON object containing entire(?) cookbook list **** ###
ChefAPI::Connection | ===> Parsing response as success...
ChefAPI::Connection | Detected response as JSON
ChefAPI::Connection | Parsing response body as JSON
ChefAPI::Connection | ===> GET {"url"=>"https://chef.ourdomain.org/organizations/our_org/cookbooks/vagrant", "versions"=>[{"version"=>"0.8.0", "url"=>"https://chef.ourdomain.org/organizations/our_org/cookbooks/vagrant/0.8.0"}]}...
ChefAPI::Connection | Chef flavor: :open_source
ChefAPI::Connection | ===> Building URI...
Process finished with exit code 1
The intermediate workaround is to a two step process. Use .list, which gives back just the cookbook names, and then iterate over those names calling Cookbook.fetch. In terms of workarounds, it's not horrible.
The text was updated successfully, but these errors were encountered:
rjhornsby
changed the title
Cookbook enumerator methods all, each fail
Cookbook enumerator methods 'all', 'each' fail
Jul 20, 2018
Iterating over all the clients works fine:
However, attempting to iterate (
.all
,.each
) over all the cookbooks the same way fails. It seems likechef-api
is trying to process the JSON response as if it is a URL.The intermediate workaround is to a two step process. Use
.list
, which gives back just the cookbook names, and then iterate over those names callingCookbook.fetch
. In terms of workarounds, it's not horrible.The text was updated successfully, but these errors were encountered: