Skip to content

Commit

Permalink
configuration of evp proxy in Components (untested)
Browse files Browse the repository at this point in the history
  • Loading branch information
anmarchenko committed Oct 17, 2023
1 parent 3093c0c commit 8328682
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 19 deletions.
53 changes: 35 additions & 18 deletions lib/datadog/ci/configuration/components.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,12 @@ def initialize(settings)

def activate_ci!(settings)
test_visibility_transport = nil
agent_settings = Datadog::Core::Configuration::AgentSettingsResolver.call(settings)

if settings.ci.agentless_mode_enabled
if settings.api_key.nil?
# agentless mode is requested but no API key is provided -
# we cannot continue and log an error
# Tests are running without CI visibility enabled

Datadog.logger.error(
"DATADOG CONFIGURATION - CI VISIBILITY - ATTENTION - " \
"Agentless mode was enabled but DD_API_KEY is not set: CI visibility is disabled. " \
"Please make sure to set valid api key in DD_API_KEY environment variable"
)

settings.ci.enabled = false
return
else
test_visibility_transport = build_test_visibility_transport(settings)
end
test_visibility_transport = build_agentless_transport(settings)
elsif can_use_evp_proxy?(settings, agent_settings)
test_visibility_transport = build_evp_proxy_transport(settings, agent_settings)
end

# Deactivate telemetry
Expand All @@ -61,9 +49,38 @@ def activate_ci!(settings)
settings.tracing.test_mode.writer_options = writer_options
end

def build_test_visibility_transport(settings)
def can_use_evp_proxy?(settings, agent_settings)
Datadog::Core::Remote::Negotiation.new(settings, agent_settings).endpoint?(
"#{Ext::Transport::EVP_PROXY_PATH_PREFIX}/"
)
end

def build_agentless_transport(settings)
if settings.api_key.nil?
# agentless mode is requested but no API key is provided -
# we cannot continue and log an error
# Tests are running without CI visibility enabled

Datadog.logger.error(
"DATADOG CONFIGURATION - CI VISIBILITY - ATTENTION - " \
"Agentless mode was enabled but DD_API_KEY is not set: CI visibility is disabled. " \
"Please make sure to set valid api key in DD_API_KEY environment variable"
)

settings.ci.enabled = false

nil
else
Datadog::CI::TestVisibility::Transport.new(
api: Transport::Api::Builder.build_ci_test_cycle_api(settings),
dd_env: settings.env
)
end
end

def build_evp_proxy_transport(settings, agent_settings)
Datadog::CI::TestVisibility::Transport.new(
api: Transport::Api::Builder.build_ci_test_cycle_api(settings),
api: Transport::Api::Builder.build_evp_proxy_api(agent_settings),
dd_env: settings.env
)
end
Expand Down
4 changes: 3 additions & 1 deletion sig/datadog/ci/configuration/components.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ module Datadog

def activate_ci!: (untyped settings) -> untyped

def build_test_visibility_transport: (untyped settings) -> Datadog::CI::TestVisibility::Transport
def build_agentless_transport: (untyped settings) -> Datadog::CI::TestVisibility::Transport?
def build_evp_proxy_transport: (untyped settings, untyped agent_settings) -> Datadog::CI::TestVisibility::Transport
def can_use_evp_proxy?: (untyped settings, untyped agent_settings) -> bool
end
end
end
Expand Down
1 change: 1 addition & 0 deletions sig/datadog/ci/transport/api/builder.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module Datadog
module Api
module Builder
def self.build_ci_test_cycle_api: (untyped settings) -> Datadog::CI::Transport::Api::CIIntake
def self.build_evp_proxy_api: (untyped agent_settings) -> Datadog::CI::Transport::Api::EVPProxy
end
end
end
Expand Down
18 changes: 18 additions & 0 deletions vendor/rbs/ddtrace/0/datadog/core/remote/negotiation.rbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module Datadog
module Core
module Remote
class Negotiation
@transport_root: Datadog::Core::Remote::Transport::Negotiation::Transport
@logged: ::Hash[::Symbol, bool]

def initialize: (Datadog::Core::Configuration::Settings _settings, Datadog::Core::Configuration::AgentSettingsResolver::AgentSettings agent_settings) -> void

def endpoint?: (::String path) -> bool

private

def network_error?: (::Exception error) -> bool
end
end
end
end
36 changes: 36 additions & 0 deletions vendor/rbs/ddtrace/0/datadog/core/remote/transport/negotiation.rbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
module Datadog
module Core
module Remote
module Transport
module Negotiation
class Request < Datadog::Core::Transport::Request
end

module Response
attr_reader version: untyped

attr_reader endpoints: untyped

attr_reader config: untyped
end

class Transport
attr_reader client: untyped

attr_reader apis: untyped

attr_reader default_api: untyped

attr_reader current_api_id: untyped

def initialize: (untyped apis, untyped default_api) -> void

def send_info: () -> untyped

def current_api: () -> untyped
end
end
end
end
end
end

0 comments on commit 8328682

Please sign in to comment.