Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rework forge API handling #527

Merged
merged 2 commits into from
Dec 27, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions bin/get_all_the_diffs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
require 'json'
require 'open-uri'
require 'yaml'
require 'puppet_forge'

# we removed the following modules from our modulesync_config / hide it because they are not Puppet modules but match the puppet- pattern
# The modules in the list are broken, unfinished or got migrated (yes, that really happens from time to time)
Expand Down Expand Up @@ -43,8 +44,17 @@ not_synced_repos = repos.select{|repo| !modulesync_repos.include?(repo)}

# get all forge releases
puts "get data from the forge API" if DEBUG
forge_response = JSON.load(open('https://forgeapi.puppetlabs.com:443/v3/modules?owner=puppet&limit=200'))
forge_releases = forge_response['results'].map{|release| release['slug']}
PuppetForge.user_agent = "VoxPupuli/0.1 get_all_diffs script"

vp = PuppetForge::User.find('puppet')
mods = vp.modules
forge_releases = mods
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/puppetlabs/forge-ruby#paginated-collections suggests you can also iterate automatically:

forge_releases = vp.modules.unpaginated.map(&:slug)

while not mods.next_url.nil?
mods = mods.next
puts "we discovered another #{mods.count} modules on the forge" if DEBUG
forge_releases.concat(mods.map{|mod| "puppet-#{mod}" })
puts "we are now at #{forge_releases.count} modules from the forge" if DEBUG
end

# get all modules that are in modulesync_config but not released
unreleased_modules = modulesync_repos.reject{|repo| forge_releases.include?(repo)}
Expand Down