Skip to content

Commit

Permalink
Transport::Api::Base accepts HTTP client in intializer
Browse files Browse the repository at this point in the history
  • Loading branch information
anmarchenko committed Oct 24, 2023
1 parent 2bfd58e commit 52b3a07
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 11 deletions.
4 changes: 4 additions & 0 deletions lib/datadog/ci/transport/api/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ module Api
class Base
attr_reader :http

def initialize(http:)
@http = http
end

def request(path:, payload:, verb: "post")
http.request(
path: path,
Expand Down
12 changes: 7 additions & 5 deletions lib/datadog/ci/transport/api/ci_test_cycle.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ def initialize(api_key:, url:)
uri = URI.parse(url)
raise "Invalid agentless mode URL: #{url}" if uri.host.nil?

@http = Datadog::CI::Transport::HTTP.new(
host: uri.host,
port: uri.port,
ssl: uri.scheme == "https" || uri.port == 443,
compress: true
super(
http: Datadog::CI::Transport::HTTP.new(
host: uri.host,
port: uri.port,
ssl: uri.scheme == "https" || uri.port == 443,
compress: true
)
)
end

Expand Down
14 changes: 8 additions & 6 deletions lib/datadog/ci/transport/api/evp_proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ module Transport
module Api
class EvpProxy < Base
def initialize(host:, port:, ssl:, timeout:)
@http = Datadog::CI::Transport::HTTP.new(
host: host,
port: port,
ssl: ssl,
timeout: timeout,
compress: false
super(
http: Datadog::CI::Transport::HTTP.new(
host: host,
port: port,
ssl: ssl,
timeout: timeout,
compress: false
)
)
end

Expand Down
2 changes: 2 additions & 0 deletions sig/datadog/ci/transport/api/base.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ module Datadog
class Base
attr_reader http: Datadog::CI::Transport::HTTP

def initialize: (http: Datadog::CI::Transport::HTTP) -> void

def request: (path: String, payload: String, ?verb: ::String) -> untyped

private
Expand Down

0 comments on commit 52b3a07

Please sign in to comment.