(self, base_url=None, version=None,
timeout=DEFAULT_TIMEOUT_SECONDS, tls=False,
user_agent=DEFAULT_USER_AGENT, num_pools=None,
credstore_env=None, use_ssh_client=False,
max_pool_size=DEFAULT_MAX_POOL_SIZE)
| 113 | 'timeout'] |
| 114 | |
| 115 | def __init__(self, base_url=None, version=None, |
| 116 | timeout=DEFAULT_TIMEOUT_SECONDS, tls=False, |
| 117 | user_agent=DEFAULT_USER_AGENT, num_pools=None, |
| 118 | credstore_env=None, use_ssh_client=False, |
| 119 | max_pool_size=DEFAULT_MAX_POOL_SIZE): |
| 120 | super().__init__() |
| 121 | |
| 122 | if tls and not base_url: |
| 123 | raise TLSParameterError( |
| 124 | 'If using TLS, the base_url argument must be provided.' |
| 125 | ) |
| 126 | |
| 127 | self.base_url = base_url |
| 128 | self.timeout = timeout |
| 129 | self.headers['User-Agent'] = user_agent |
| 130 | |
| 131 | self._general_configs = config.load_general_config() |
| 132 | |
| 133 | proxy_config = self._general_configs.get('proxies', {}) |
| 134 | try: |
| 135 | proxies = proxy_config[base_url] |
| 136 | except KeyError: |
| 137 | proxies = proxy_config.get('default', {}) |
| 138 | |
| 139 | self._proxy_configs = ProxyConfig.from_dict(proxies) |
| 140 | |
| 141 | self._auth_configs = auth.load_config( |
| 142 | config_dict=self._general_configs, credstore_env=credstore_env, |
| 143 | ) |
| 144 | self.credstore_env = credstore_env |
| 145 | |
| 146 | base_url = utils.parse_host( |
| 147 | base_url, IS_WINDOWS_PLATFORM, tls=bool(tls) |
| 148 | ) |
| 149 | # SSH has a different default for num_pools to all other adapters |
| 150 | num_pools = num_pools or DEFAULT_NUM_POOLS_SSH if \ |
| 151 | base_url.startswith('ssh://') else DEFAULT_NUM_POOLS |
| 152 | |
| 153 | if base_url.startswith('http+unix://'): |
| 154 | self._custom_adapter = UnixHTTPAdapter( |
| 155 | base_url, timeout, pool_connections=num_pools, |
| 156 | max_pool_size=max_pool_size |
| 157 | ) |
| 158 | self.mount('http+docker://', self._custom_adapter) |
| 159 | self._unmount('http://', 'https://') |
| 160 | # host part of URL should be unused, but is resolved by requests |
| 161 | # module in proxy_bypass_macosx_sysconf() |
| 162 | self.base_url = 'http+docker://localhost' |
| 163 | elif base_url.startswith('npipe://'): |
| 164 | if not IS_WINDOWS_PLATFORM: |
| 165 | raise DockerException( |
| 166 | 'The npipe:// protocol is only supported on Windows' |
| 167 | ) |
| 168 | try: |
| 169 | self._custom_adapter = NpipeHTTPAdapter( |
| 170 | base_url, timeout, pool_connections=num_pools, |
| 171 | max_pool_size=max_pool_size |
| 172 | ) |
nothing calls this directly
no test coverage detected