Class: DefaultProxyProxySelector

Inherits:
RemoteExecutionProxySelector show all
Defined in:
app/services/default_proxy_proxy_selector.rb

Constant Summary

Constants inherited from RemoteExecutionProxySelector

RemoteExecutionProxySelector::INTERNAL_PROXY

Instance Method Summary collapse

Constructor Details

#initializeDefaultProxyProxySelector

Returns a new instance of DefaultProxyProxySelector.



2
3
4
5
6
7
8
# File 'app/services/default_proxy_proxy_selector.rb', line 2

def initialize
  # TODO: Remove this once we have a reliable way of determining the internal proxy without katello
  # Tracked as https://projects.theforeman.org/issues/29840
  raise _('Internal proxy selector can only be used if Katello is enabled') unless defined?(::Katello)

  super
end

Instance Method Details

#available_proxies(host, provider, capability: nil) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'app/services/default_proxy_proxy_selector.rb', line 10

def available_proxies(host, provider, capability: nil)
  # TODO: Once we have a internal proxy marker/feature on the proxy, we can
  # swap the implementation
  raise _('default_capsule method missing from SmartProxy') unless ::SmartProxy.respond_to?(:default_capsule)

  internal_proxy = ::SmartProxy.default_capsule
  super.reduce({}) do |acc, (key, proxies)|
    acc.merge(key => proxies.select { |proxy| proxy == internal_proxy })
  end
end