berkshelf-api 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +17 -0
- data/berkshelf-api.gemspec +1 -1
- data/lib/berkshelf/api/application.rb +2 -0
- data/lib/berkshelf/api/cache_builder/worker/github.rb +1 -1
- data/lib/berkshelf/api/endpoint/v1.rb +10 -0
- data/lib/berkshelf/api/version.rb +1 -1
- data/spec/unit/berkshelf/api/endpoint/v1_spec.rb +32 -10
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ce86ff18c66c5969773219d3ca52057c3a26f7e9
|
4
|
+
data.tar.gz: bc4ec3d58c036d345bcd87a2ecc0e884b9747137
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9843ba1124acbebff0cdf228974e21b92737396dc5bcd7e91dd5cae4b40a915f551970ccadd3555ae49b5c36c4827a283011329b7a7adc56fdac5a2ebd48faae
|
7
|
+
data.tar.gz: 45e259721177024b33d2a80fc74c289ac2082ac1f19c1c79922cac06741880dc6c6400e171cd3a216124e3d5945b03e6fb06ad1401960b01a28b33b3fa13eab8
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,20 @@
|
|
1
|
+
# master
|
2
|
+
|
3
|
+
* Enhancements
|
4
|
+
*
|
5
|
+
|
6
|
+
* Bug Fixes
|
7
|
+
*
|
8
|
+
|
9
|
+
# 1.1.1
|
10
|
+
|
11
|
+
* Enhancements
|
12
|
+
* Added /status endpoint to REST API
|
13
|
+
|
14
|
+
* Bug Fixes
|
15
|
+
* Github cache builder will autopaginate to get all repos
|
16
|
+
* Fix dependency issues with Faraday
|
17
|
+
|
1
18
|
# 1.1.0
|
2
19
|
|
3
20
|
* Enhancements
|
data/berkshelf-api.gemspec
CHANGED
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.add_dependency 'reel', '>= 0.4.0'
|
25
25
|
spec.add_dependency 'grape', '~> 0.5.0'
|
26
26
|
spec.add_dependency 'hashie', '>= 2.0.4'
|
27
|
-
spec.add_dependency 'faraday'
|
27
|
+
spec.add_dependency 'faraday', '~> 0.8.0'
|
28
28
|
spec.add_dependency 'retryable', '~> 1.3.3'
|
29
29
|
spec.add_dependency 'archive', '= 0.0.2'
|
30
30
|
spec.add_dependency 'buff-config', '~> 0.1'
|
@@ -28,6 +28,7 @@ module Berkshelf::API
|
|
28
28
|
include Berkshelf::API::Logging
|
29
29
|
include Berkshelf::API::Mixin::Services
|
30
30
|
|
31
|
+
attr_reader :start_time
|
31
32
|
def_delegators :registry, :[], :[]=
|
32
33
|
|
33
34
|
# @return [Berkshelf::API::Config]
|
@@ -113,6 +114,7 @@ module Berkshelf::API
|
|
113
114
|
# @option options [Boolean] :disable_http (false)
|
114
115
|
# run the application without the rest gateway
|
115
116
|
def run(options = {})
|
117
|
+
@start_time = Time.now.utc
|
116
118
|
loop do
|
117
119
|
supervisor = run!(options)
|
118
120
|
|
@@ -17,7 +17,7 @@ module Berkshelf::API
|
|
17
17
|
# authentication token for accessing the Github organization. This is necessary
|
18
18
|
# since Github throttles unauthenticated API requests
|
19
19
|
def initialize(options = {})
|
20
|
-
@connection = Octokit::Client.new(access_token: options[:access_token])
|
20
|
+
@connection = Octokit::Client.new(access_token: options[:access_token], auto_paginate: true)
|
21
21
|
@organization = options[:organization]
|
22
22
|
super(options)
|
23
23
|
end
|
@@ -19,6 +19,16 @@ module Berkshelf::API
|
|
19
19
|
status 503
|
20
20
|
end
|
21
21
|
end
|
22
|
+
|
23
|
+
desc "health check"
|
24
|
+
get 'status' do
|
25
|
+
{
|
26
|
+
status: 'ok',
|
27
|
+
version: Berkshelf::API::VERSION,
|
28
|
+
cache_status: cache_manager.warmed? ? 'ok' : 'warming',
|
29
|
+
uptime: Time.now.utc - Application.start_time,
|
30
|
+
}
|
31
|
+
end
|
22
32
|
end
|
23
33
|
end
|
24
34
|
end
|
@@ -4,28 +4,50 @@ describe Berkshelf::API::Endpoint::V1 do
|
|
4
4
|
include Rack::Test::Methods
|
5
5
|
include Berkshelf::API::Mixin::Services
|
6
6
|
|
7
|
-
before { Berkshelf::API::CacheManager.start }
|
8
7
|
let(:app) { described_class.new }
|
8
|
+
let(:cache_warm) { false }
|
9
|
+
|
10
|
+
before do
|
11
|
+
Berkshelf::API::CacheManager.start
|
12
|
+
cache_manager.set_warmed if cache_warm
|
13
|
+
end
|
14
|
+
|
15
|
+
subject { last_response }
|
9
16
|
|
10
17
|
describe "GET /universe" do
|
11
|
-
|
12
|
-
|
18
|
+
before { get '/universe' }
|
19
|
+
let(:app_cache) { cache_manager.cache }
|
13
20
|
|
14
|
-
|
15
|
-
let(:
|
21
|
+
context "the cache has been warmed" do
|
22
|
+
let(:cache_warm) { true }
|
16
23
|
|
17
24
|
its(:status) { should be(200) }
|
18
25
|
its(:body) { should eq(app_cache.to_json) }
|
19
26
|
end
|
20
27
|
|
21
28
|
context "the cache is still warming" do
|
22
|
-
before { get '/universe' }
|
23
|
-
|
24
|
-
subject { last_response }
|
25
|
-
let(:app_cache) { cache_manager.cache }
|
26
|
-
|
27
29
|
its(:status) { should be(503) }
|
28
30
|
its(:headers) { should have_key("Retry-After") }
|
29
31
|
end
|
30
32
|
end
|
33
|
+
|
34
|
+
describe "GET /status" do
|
35
|
+
before do
|
36
|
+
Berkshelf::API::Application.stub(:start_time) { Time.at(0) }
|
37
|
+
Time.stub(:now) { Time.at(100) }
|
38
|
+
get '/status'
|
39
|
+
end
|
40
|
+
|
41
|
+
context "the cache has been warmed" do
|
42
|
+
let(:cache_warm) { true }
|
43
|
+
|
44
|
+
its(:status) { should be(200) }
|
45
|
+
its(:body) { should eq({status: 'ok', version: Berkshelf::API::VERSION, cache_status: 'ok', uptime: 100.0}.to_json) }
|
46
|
+
end
|
47
|
+
|
48
|
+
context "the cache is still warming" do
|
49
|
+
its(:status) { should be(200) }
|
50
|
+
its(:body) { should eq({status: 'ok', version: Berkshelf::API::VERSION, cache_status: 'warming', uptime: 100.0}.to_json) }
|
51
|
+
end
|
52
|
+
end
|
31
53
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: berkshelf-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jamie Winsor
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2014-02-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ridley
|
@@ -85,16 +85,16 @@ dependencies:
|
|
85
85
|
name: faraday
|
86
86
|
requirement: !ruby/object:Gem::Requirement
|
87
87
|
requirements:
|
88
|
-
- -
|
88
|
+
- - ~>
|
89
89
|
- !ruby/object:Gem::Version
|
90
|
-
version:
|
90
|
+
version: 0.8.0
|
91
91
|
type: :runtime
|
92
92
|
prerelease: false
|
93
93
|
version_requirements: !ruby/object:Gem::Requirement
|
94
94
|
requirements:
|
95
|
-
- -
|
95
|
+
- - ~>
|
96
96
|
- !ruby/object:Gem::Version
|
97
|
-
version:
|
97
|
+
version: 0.8.0
|
98
98
|
- !ruby/object:Gem::Dependency
|
99
99
|
name: retryable
|
100
100
|
requirement: !ruby/object:Gem::Requirement
|