Sha256: da937511f977888fe1cee46d47666220d1a088c79256a18a3ad712b00954a266

Contents?: true

Size: 1.83 KB

Versions: 20

Compression:

Stored size: 1.83 KB

Contents

# frozen_string_literal: true

require "datadog/core/configuration/agent_settings_resolver"
require "datadog/core/remote/negotiation"

require_relative "agentless"
require_relative "evp_proxy"
require_relative "../http"
require_relative "../../ext/transport"

module Datadog
  module CI
    module Transport
      module Api
        module Builder
          def self.build_agentless_api(settings)
            return nil if settings.api_key.nil?

            dd_site = settings.site || Ext::Transport::DEFAULT_DD_SITE

            citestcycle_url = settings.ci.agentless_url ||
              "https://#{Ext::Transport::TEST_VISIBILITY_INTAKE_HOST_PREFIX}.#{dd_site}:443"

            api_url = settings.ci.agentless_url ||
              "https://#{Ext::Transport::DD_API_HOST_PREFIX}.#{dd_site}:443"

            citestcov_url = settings.ci.agentless_url ||
              "https://#{Ext::Transport::TEST_COVERAGE_INTAKE_HOST_PREFIX}.#{dd_site}:443"

            Agentless.new(
              api_key: settings.api_key,
              citestcycle_url: citestcycle_url,
              api_url: api_url,
              citestcov_url: citestcov_url
            )
          end

          def self.build_evp_proxy_api(settings)
            agent_settings = Datadog::Core::Configuration::AgentSettingsResolver.call(settings)
            negotiation = Datadog::Core::Remote::Negotiation.new(
              settings,
              agent_settings,
              suppress_logging: {no_config_endpoint: true}
            )

            evp_proxy_path_prefix = Ext::Transport::EVP_PROXY_PATH_PREFIXES.find do |path_prefix|
              negotiation.endpoint?(path_prefix)
            end

            return nil if evp_proxy_path_prefix.nil?

            EvpProxy.new(agent_settings: agent_settings, path_prefix: evp_proxy_path_prefix)
          end
        end
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
datadog-ci-1.12.0 lib/datadog/ci/transport/api/builder.rb
datadog-ci-1.11.0 lib/datadog/ci/transport/api/builder.rb
datadog-ci-1.10.0 lib/datadog/ci/transport/api/builder.rb
datadog-ci-1.9.0 lib/datadog/ci/transport/api/builder.rb
datadog-ci-1.8.1 lib/datadog/ci/transport/api/builder.rb
datadog-ci-1.8.0 lib/datadog/ci/transport/api/builder.rb
datadog-ci-1.7.0 lib/datadog/ci/transport/api/builder.rb
datadog-ci-1.6.0 lib/datadog/ci/transport/api/builder.rb
datadog-ci-1.5.0 lib/datadog/ci/transport/api/builder.rb
datadog-ci-1.4.1 lib/datadog/ci/transport/api/builder.rb
datadog-ci-1.4.0 lib/datadog/ci/transport/api/builder.rb
datadog-ci-1.3.0 lib/datadog/ci/transport/api/builder.rb
datadog-ci-1.2.0 lib/datadog/ci/transport/api/builder.rb
datadog-ci-1.1.0 lib/datadog/ci/transport/api/builder.rb
datadog-ci-1.0.1 lib/datadog/ci/transport/api/builder.rb
datadog-ci-1.0.0 lib/datadog/ci/transport/api/builder.rb
datadog-ci-1.0.0.beta6 lib/datadog/ci/transport/api/builder.rb
datadog-ci-1.0.0.beta3 lib/datadog/ci/transport/api/builder.rb
datadog-ci-1.0.0.beta2 lib/datadog/ci/transport/api/builder.rb
datadog-ci-1.0.0.beta1 lib/datadog/ci/transport/api/builder.rb