File tree Expand file tree Collapse file tree 6 files changed +100
-2
lines changed
Expand file tree Collapse file tree 6 files changed +100
-2
lines changed Original file line number Diff line number Diff line change 11.dockerignore
22.DS_Store
3+ .env
34.git *
45.gitignore
56docker-compose *
Original file line number Diff line number Diff line change 11.DS_STORE
2+ .env
3+ app.rb
Original file line number Diff line number Diff line change 22
33source "https://rubygems.org"
44
5+ gem "octokit" , "~> 10.0"
56gem "puma"
67gem "rack-test"
78gem "rackup"
89gem "rspec"
10+ gem "sinatra-contrib" , "~> 4.1"
911gem "sinatra"
12+
13+ gem "pry" , "~> 0.15.2" , :group => :development
Original file line number Diff line number Diff line change 11GEM
22 remote: https://rubygems.org/
33 specs:
4+ addressable (2.8.7 )
5+ public_suffix (>= 2.0.2 , < 7.0 )
46 base64 (0.3.0 )
7+ coderay (1.1.3 )
58 diff-lcs (1.6.2 )
9+ faraday (2.13.4 )
10+ faraday-net_http (>= 2.0 , < 3.5 )
11+ json
12+ logger
13+ faraday-net_http (3.4.1 )
14+ net-http (>= 0.5.0 )
15+ json (2.13.2 )
616 logger (1.7.0 )
17+ method_source (1.1.0 )
18+ multi_json (1.17.0 )
719 mustermann (3.0.4 )
820 ruby2_keywords (~> 0.0.1 )
21+ net-http (0.6.0 )
22+ uri
923 nio4r (2.7.4 )
24+ octokit (10.0.0 )
25+ faraday (>= 1 , < 3 )
26+ sawyer (~> 0.9 )
27+ pry (0.15.2 )
28+ coderay (~> 1.1 )
29+ method_source (~> 1.0 )
30+ public_suffix (6.0.2 )
1031 puma (6.6.1 )
1132 nio4r (~> 2.0 )
1233 rack (3.2.0 )
3556 rspec-support (~> 3.13.0 )
3657 rspec-support (3.13.5 )
3758 ruby2_keywords (0.0.5 )
59+ sawyer (0.9.2 )
60+ addressable (>= 2.3.5 )
61+ faraday (>= 0.17.3 , < 3 )
3862 sinatra (4.1.1 )
3963 logger (>= 1.6.0 )
4064 mustermann (~> 3.0 )
4165 rack (>= 3.0.0 , < 4 )
4266 rack-protection (= 4.1.1 )
4367 rack-session (>= 2.0.0 , < 3 )
4468 tilt (~> 2.0 )
69+ sinatra-contrib (4.1.1 )
70+ multi_json (>= 0.0.2 )
71+ mustermann (~> 3.0 )
72+ rack-protection (= 4.1.1 )
73+ sinatra (= 4.1.1 )
74+ tilt (~> 2.0 )
4575 tilt (2.6.1 )
76+ uri (1.0.3 )
4677
4778PLATFORMS
4879 aarch64-linux
4980 ruby
5081
5182DEPENDENCIES
83+ octokit (~> 10.0 )
84+ pry (~> 0.15.2 )
5285 puma
5386 rack-test
5487 rackup
5588 rspec
5689 sinatra
90+ sinatra-contrib (~> 4.1 )
5791
5892BUNDLED WITH
59- 2.6.9
93+ 2.6.5
Original file line number Diff line number Diff line change 1+ require 'date'
2+ require 'octokit'
13require 'sinatra'
4+ require 'sinatra/json'
5+
6+ configure :development do
7+ set :logging , Logger ::DEBUG
8+ set :server_settings , timeout : 60
9+ end
10+
11+ def has_permatag? ( version , permatags )
12+ ( version [ 'metadata' ] [ 'container' ] [ 'tags' ] & permatags ) . any?
13+ end
14+
15+ def younger_than? ( version , days_old )
16+ cutoff = Time . now - 60 *60 *24 *days_old
17+ version [ 'created_at' ] > cutoff
18+ end
19+
20+ github = Octokit ::Client . new ( per_page : 100 , auto_paginate : true )
221
322get '/' do
4- "Hello, world!"
23+ 'Hello, world!'
24+ end
25+
26+ get '/prunables' do
27+ packages = github . get ( 'orgs/BerkeleyLibrary/packages' , { package_type : :container } )
28+ logger . info "Scanning #{ packages . size } packages for prunable images: #{ packages . collect ( &:name ) . sort } "
29+
30+ packages . each do |pkg |
31+ logger . info "Determining prunable images for #{ pkg . name } "
32+
33+ next unless pkg . repository
34+
35+ permatags = %w( latest edge )
36+ permatags += github . branches ( pkg . repository . full_name ) . collect ( &:name )
37+ permatags += github . tags ( pkg . repository . full_name ) . collect ( &:name )
38+
39+ images = github . get ( "orgs/#{ pkg . owner . login } /packages/#{ pkg . package_type } /#{ pkg . name } /versions" ) . collect do |image |
40+ if has_permatag? image , permatags
41+ verdict = :permatagged
42+ elsif younger_than? image , 7
43+ verdict = :recent
44+ else
45+ verdict = :prunable
46+ end
47+ # { image:, verdict: }
48+ end
49+
50+ json ( {
51+ repo : pkg . repository . full_name ,
52+ package : pkg . name ,
53+ images :,
54+ } )
55+ end
556end
Original file line number Diff line number Diff line change 33services :
44 app :
55 build : .
6+ env_file :
7+ - .env
68 ports :
79 - 4567:4567
810 volumes :
911 - ./:/opt/app
12+ develop :
13+ watch :
14+ - action : rebuild
15+ path : .
You can’t perform that action at this time.
0 commit comments