|
6 | 6 | from collections.abc import Iterable
|
7 | 7 | from typing import Callable, Optional
|
8 | 8 |
|
9 |
| -from ._version import __version__ |
| 9 | +from conda_forge_feedstock_ops.settings import FeedstockOpsSettings |
10 | 10 |
|
11 | 11 | logger = logging.getLogger(__name__)
|
12 | 12 |
|
13 | 13 | DEFAULT_CONTAINER_TMPFS_SIZE_MB = 6000
|
14 | 14 |
|
15 |
| -CONTAINER_PROXY_MODE = os.environ.get( |
16 |
| - "CF_FEEDSTOCK_OPS_CONTAINER_PROXY_MODE", "false" |
17 |
| -).lower() in ("yes", "true", "t", "1") |
18 |
| -""" |
19 |
| -Whether to use a proxy that is locally configured for all requests inside the container. |
20 |
| -Set the environment variable `CF_FEEDSTOCK_OPS_CONTAINER_PROXY_MODE` to 'true' to enable this feature. |
21 |
| -""" |
22 |
| - |
23 |
| -PROXY_IN_CONTAINER = os.environ.get( |
24 |
| - "CF_FEEDSTOCK_OPS_PROXY_IN_CONTAINER", "http://host.docker.internal:8080" |
25 |
| -) |
26 |
| -""" |
27 |
| -The hostname of the proxy to use in the container. |
28 |
| -The default value of 'http://host.docker.internal:8080' is the default value for Docker Desktop on Windows and macOS. |
29 |
| -It also works for OrbStack. |
30 |
| -
|
31 |
| -For podman, use http://host.containers.internal:8080. |
32 |
| -For GitHub Actions, use http://172.17.0.1:8080, see https://stackoverflow.com/a/65505308 |
33 |
| -""" |
34 |
| - |
35 | 15 |
|
36 | 16 | def get_default_container_name():
|
37 |
| - """Get the default container name for feedstock ops. |
38 |
| -
|
39 |
| - The image is stored at `condaforge/conda-forge-feedstock-ops`. |
40 |
| -
|
41 |
| - If the environment variable `CF_FEEDSTOCK_OPS_CONTAINER_NAME` is set, then that name is used. |
42 |
| -
|
43 |
| - If the environment variable `CF_FEEDSTOCK_OPS_CONTAINER_TAG` is set, then that tag is pulled. |
44 |
| - Otherwise, we pull the tag `__version__`. |
45 |
| - """ |
46 |
| - cname = ( |
47 |
| - f"{os.environ.get('CF_FEEDSTOCK_OPS_CONTAINER_NAME', 'condaforge/conda-forge-feedstock-ops')}" |
48 |
| - + f":{os.environ.get('CF_FEEDSTOCK_OPS_CONTAINER_TAG', __version__)}" |
49 |
| - ) |
50 |
| - |
51 |
| - return cname |
| 17 | + return FeedstockOpsSettings().container_full_name |
52 | 18 |
|
53 | 19 |
|
54 | 20 | class ContainerRuntimeError(RuntimeError):
|
@@ -118,14 +84,16 @@ def get_default_log_level_args(logger):
|
118 | 84 |
|
119 | 85 |
|
120 | 86 | def _get_proxy_mode_container_args():
|
121 |
| - if not CONTAINER_PROXY_MODE: |
| 87 | + settings = FeedstockOpsSettings() |
| 88 | + if not settings.container_proxy_mode: |
122 | 89 | return []
|
| 90 | + |
123 | 91 | assert os.environ["SSL_CERT_FILE"] == os.environ["REQUESTS_CA_BUNDLE"]
|
124 | 92 | return [
|
125 | 93 | "-e",
|
126 |
| - f"http_proxy={PROXY_IN_CONTAINER}", |
| 94 | + f"http_proxy={settings.proxy_in_container}", |
127 | 95 | "-e",
|
128 |
| - f"https_proxy={PROXY_IN_CONTAINER}", |
| 96 | + f"https_proxy={settings.proxy_in_container}", |
129 | 97 | "-e",
|
130 | 98 | f"no_proxy={os.environ.get('no_proxy', '')}",
|
131 | 99 | "-e",
|
@@ -290,9 +258,7 @@ def should_use_container(use_container: Optional[bool] = None):
|
290 | 258 | bool
|
291 | 259 | Whether to use a container.
|
292 | 260 | """
|
293 |
| - in_container = ( |
294 |
| - os.environ.get("CF_FEEDSTOCK_OPS_IN_CONTAINER", "false").lower() == "true" |
295 |
| - ) |
| 261 | + in_container = FeedstockOpsSettings().in_container |
296 | 262 | if use_container is None:
|
297 | 263 | use_container = not in_container
|
298 | 264 |
|
|
0 commit comments