-
Notifications
You must be signed in to change notification settings - Fork 0
/
estimate_repo_size.rb
30 lines (24 loc) · 970 Bytes
/
estimate_repo_size.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
require 'artifactory'
Artifactory.configure do |config|
config.endpoint = 'http://artifactory-preprod.chef.co'
config.username = '[email protected]'
config.password = ENV['ARTIFACTORY_PASSWORD']
end
%w[ current stable ].each do |channel|
query = <<-QUERY
items.find(
{ "repo": "omnibus-#{channel}-local" }
).include("path", "name", "size")
QUERY
results = Artifactory.post('/api/search/aql', query, 'Content-Type' => 'text/plain')
packages = Hash.new
size = Hash.new
%w[ el ubuntu debian ].each do |os|
total = 0
stuff = results['results'].find_all { |result| result["path"].include?("\/#{os}\/") }
packages[os] = stuff.size
size[os] = stuff.inject(0) { |sum, result| sum + Integer(result['size']) }
end
puts "#{channel} yum repo size (bytes) = #{size['el']} (#{packages['el']} packages)"
puts "#{channel} apt repo size (bytes) = #{size['debian'] + size['ubuntu']} (#{packages['debian'] + packages['ubuntu']} packages)"
end