Class: Chef::Knife::SupermarketList
- Inherits:
-
Knife
- Object
- Knife
- Chef::Knife::SupermarketList
- Defined in:
- lib/chef/knife/supermarket_list.rb
Instance Method Summary collapse
-
#get_cookbook_list(items = 9999999, start = 0, cookbook_collection = {}) ⇒ Object
In order to avoid pagination items limit set to 9999999.
- #run ⇒ Object
Instance Method Details
#get_cookbook_list(items = 9999999, start = 0, cookbook_collection = {}) ⇒ Object
In order to avoid pagination items limit set to 9999999
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/chef/knife/supermarket_list.rb', line 58 def get_cookbook_list(items = 9999999, start = 0, cookbook_collection = {}) cookbooks_url = "#{config[:supermarket_site]}/api/v1/cookbooks?items=#{items}&start=#{start}" cookbooks_url << "&order=#{config[:sort_by]}" if config[:sort_by] cookbooks_url << "&user=#{config[:owned_by]}" if config[:owned_by] cr = noauth_rest.get(cookbooks_url) cr["items"].each do |cookbook| cookbook_collection[cookbook["cookbook_name"]] = cookbook["cookbook"] end new_start = start + items if new_start < cr["total"] get_cookbook_list(items, new_start, cookbook_collection) else cookbook_collection end end |
#run ⇒ Object
49 50 51 52 53 54 55 |
# File 'lib/chef/knife/supermarket_list.rb', line 49 def run if config[:with_uri] ui.output(format_for_display(get_cookbook_list)) else ui.msg(ui.list(get_cookbook_list.keys, :columns_down)) end end |