dependabot-common 0.196.3 → 0.196.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 91ced21f05de60240ba836027a9b32fe4a407f3e483c34786dfd7648b0419778
4
- data.tar.gz: 109a5fa09899f3340a9b5ea91843132de68a9d29b3541fbba19619bb42dad42b
3
+ metadata.gz: 65a6aadb52a1ffeb970ec8aa0dc678042b7f8f3e9f17c9ee07903eddfc4e60ae
4
+ data.tar.gz: 6e0f03d4901b4cd3eac9938a223360be570e7074c1950ec4cfabfa7a227aefd3
5
5
  SHA512:
6
- metadata.gz: 627e8f515dd9e4a0f9dced689dba37cb7ec950668300e824d2f7a94f0d393370e1eb0f0ff035b3aa0adf4a015d5cde8a11f6de30d3e3b6e4c208787732b94a50
7
- data.tar.gz: '038efe37cf95aa0c3c6915532b98ac157658c3d694e790998feb44300eb86a64bd6f7b756272a63231da77d16fdfec94e0899c7495be667132cbf73c59284e94'
6
+ metadata.gz: 9bcd9a9fb225471bbbd316b3c1ab8f22be8a248cbba9bef03fca6dacc06ec99bad05f4b1fefa8b229abb91a8b72e8f264b1774f2698d432429fbd92d66e7d71b
7
+ data.tar.gz: 9a9aab3311523a0d164c27e04a5b6449046da108baa78a3908f0a3bd453c04c8704e2032d80fcf4dfa37574589510127ee165dede202f8f35fbf3d5f8ee1f0bf
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "dependabot/shared_helpers"
4
+
5
+ # This class provides a thin wrapper around our normal usage of Excon as a simple HTTP client in order to
6
+ # provide some minor caching functionality.
7
+ #
8
+ # This is not used to support full response caching currently, we just use it to ensure we detect unreachable
9
+ # hosts and fast-fail on any subsequent requests to them to avoid excessive use of retries and connect- or
10
+ # read-timeouts as some jobs tend to be sensitive to exceeding our overall 45 minute timeout.
11
+ module Dependabot
12
+ class RegistryClient
13
+ @cached_errors = {}
14
+
15
+ def self.get(url:, headers: {}, options: {})
16
+ raise cached_error_for(url) if cached_error_for(url)
17
+
18
+ Excon.get(
19
+ url,
20
+ idempotent: true,
21
+ **SharedHelpers.excon_defaults({ headers: headers }.merge(options))
22
+ )
23
+ rescue Excon::Error::Timeout => e
24
+ cache_error(url, e)
25
+ raise e
26
+ end
27
+
28
+ def self.head(url:, headers: {}, options: {})
29
+ raise cached_error_for(url) if cached_error_for(url)
30
+
31
+ Excon.head(
32
+ url,
33
+ idempotent: true,
34
+ **SharedHelpers.excon_defaults({ headers: headers }.merge(options))
35
+ )
36
+ rescue Excon::Error::Timeout => e
37
+ cache_error(url, e)
38
+ raise e
39
+ end
40
+
41
+ def self.clear_cache!
42
+ @cached_errors = {}
43
+ end
44
+
45
+ private_class_method def self.cache_error(url, error)
46
+ host = URI(url).host
47
+ @cached_errors[host] = error
48
+ end
49
+
50
+ private_class_method def self.cached_error_for(url)
51
+ host = URI(url).host
52
+ @cached_errors.fetch(host, nil)
53
+ end
54
+ end
55
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Dependabot
4
- VERSION = "0.196.3"
4
+ VERSION = "0.196.4"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dependabot-common
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.196.3
4
+ version: 0.196.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dependabot
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-07-12 00:00:00.000000000 Z
11
+ date: 2022-07-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -482,6 +482,7 @@ files:
482
482
  - lib/dependabot/pull_request_updater/azure.rb
483
483
  - lib/dependabot/pull_request_updater/github.rb
484
484
  - lib/dependabot/pull_request_updater/gitlab.rb
485
+ - lib/dependabot/registry_client.rb
485
486
  - lib/dependabot/security_advisory.rb
486
487
  - lib/dependabot/shared_helpers.rb
487
488
  - lib/dependabot/source.rb