portforward 0.6.1__cp312-none-win_amd64.whl → 0.6.2__cp312-none-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of portforward might be problematic. Click here for more details.
- portforward/__init__.py +26 -4
- portforward/_portforward.cp312-win_amd64.pyd +0 -0
- portforward/_portforward.pyi +1 -1
- {portforward-0.6.1.dist-info → portforward-0.6.2.dist-info}/METADATA +5 -10
- portforward-0.6.2.dist-info/RECORD +9 -0
- portforward-0.6.1.dist-info/RECORD +0 -9
- {portforward-0.6.1.dist-info → portforward-0.6.2.dist-info}/WHEEL +0 -0
- {portforward-0.6.1.dist-info → portforward-0.6.2.dist-info}/license_files/AUTHORS.rst +0 -0
- {portforward-0.6.1.dist-info → portforward-0.6.2.dist-info}/license_files/LICENSE +0 -0
portforward/__init__.py
CHANGED
|
@@ -2,14 +2,15 @@
|
|
|
2
2
|
Easy Kubernetes Port-Forward For Python
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
|
-
__version__ = "0.6.
|
|
5
|
+
__version__ = "0.6.2"
|
|
6
6
|
|
|
7
7
|
import asyncio
|
|
8
8
|
import contextlib
|
|
9
|
+
import ipaddress
|
|
9
10
|
import os
|
|
10
11
|
from enum import Enum
|
|
11
12
|
from pathlib import Path
|
|
12
|
-
from typing import Generator, Optional
|
|
13
|
+
from typing import Generator, Optional, Union
|
|
13
14
|
|
|
14
15
|
from portforward import _portforward
|
|
15
16
|
|
|
@@ -36,6 +37,7 @@ def forward(
|
|
|
36
37
|
waiting: float = 0.1,
|
|
37
38
|
log_level: LogLevel = LogLevel.INFO,
|
|
38
39
|
kube_context: str = "",
|
|
40
|
+
bind_ip: Union[ipaddress.IPv4Address, ipaddress.IPv6Address, str, None] = None,
|
|
39
41
|
) -> Generator["PortForwarder", None, None]:
|
|
40
42
|
"""
|
|
41
43
|
Connects to a **pod or service** and tunnels traffic from a local port to
|
|
@@ -61,6 +63,7 @@ def forward(
|
|
|
61
63
|
:param waiting: Delay in seconds
|
|
62
64
|
:param log_level: Level of logging
|
|
63
65
|
:param kube_context: Target kubernetes context (fallback is current context)
|
|
66
|
+
:param bind_ip: To which IP shall the portforward be bind
|
|
64
67
|
:return: forwarder to manual stop the forwarding
|
|
65
68
|
"""
|
|
66
69
|
|
|
@@ -73,6 +76,7 @@ def forward(
|
|
|
73
76
|
waiting,
|
|
74
77
|
log_level,
|
|
75
78
|
kube_context,
|
|
79
|
+
bind_ip,
|
|
76
80
|
)
|
|
77
81
|
|
|
78
82
|
try:
|
|
@@ -101,6 +105,7 @@ class PortForwarder:
|
|
|
101
105
|
waiting: float = 0.1,
|
|
102
106
|
log_level: LogLevel = LogLevel.INFO,
|
|
103
107
|
kube_context: str = "",
|
|
108
|
+
bind_ip: Union[ipaddress.IPv4Address, ipaddress.IPv6Address, str, None] = None,
|
|
104
109
|
) -> None:
|
|
105
110
|
self._async_forwarder = AsyncPortForwarder(
|
|
106
111
|
namespace,
|
|
@@ -111,6 +116,7 @@ class PortForwarder:
|
|
|
111
116
|
waiting,
|
|
112
117
|
log_level,
|
|
113
118
|
kube_context,
|
|
119
|
+
bind_ip,
|
|
114
120
|
)
|
|
115
121
|
|
|
116
122
|
def forward(self):
|
|
@@ -137,10 +143,10 @@ class AsyncPortForwarder:
|
|
|
137
143
|
waiting: float = 0.1,
|
|
138
144
|
log_level: LogLevel = LogLevel.INFO,
|
|
139
145
|
kube_context: str = "",
|
|
146
|
+
bind_ip: Union[ipaddress.IPv4Address, ipaddress.IPv6Address, str, None] = None,
|
|
140
147
|
) -> None:
|
|
141
148
|
self.namespace: str = _validate_str("namespace", namespace)
|
|
142
149
|
self.pod_or_service: str = _validate_str("pod_or_service", pod_or_service)
|
|
143
|
-
self.from_port: int = _validate_port("from_port", from_port)
|
|
144
150
|
self.to_port: int = _validate_port("to_port", to_port)
|
|
145
151
|
self.log_level: LogLevel = _validate_log(log_level)
|
|
146
152
|
self.waiting: float = waiting
|
|
@@ -148,14 +154,18 @@ class AsyncPortForwarder:
|
|
|
148
154
|
self.config_path: str = _config_path(config_path)
|
|
149
155
|
self.kube_context: str = _kube_context(kube_context)
|
|
150
156
|
|
|
157
|
+
_validate_port("from_port", from_port)
|
|
158
|
+
bind_ip = _validate_ip_address(bind_ip)
|
|
159
|
+
|
|
151
160
|
self.actual_pod_name: str = ""
|
|
152
161
|
self._is_stopped: bool = False
|
|
162
|
+
self.bind_address: str = f"{bind_ip}:{from_port}"
|
|
153
163
|
|
|
154
164
|
async def forward(self):
|
|
155
165
|
self.actual_pod_name = await _portforward.forward(
|
|
156
166
|
self.namespace,
|
|
157
167
|
self.pod_or_service,
|
|
158
|
-
self.
|
|
168
|
+
self.bind_address,
|
|
159
169
|
self.to_port,
|
|
160
170
|
self.config_path,
|
|
161
171
|
self.log_level.value,
|
|
@@ -204,6 +214,18 @@ def _validate_log(log_level):
|
|
|
204
214
|
return log_level
|
|
205
215
|
|
|
206
216
|
|
|
217
|
+
def _validate_ip_address(ip_address):
|
|
218
|
+
if not ip_address:
|
|
219
|
+
return "127.0.0.1"
|
|
220
|
+
|
|
221
|
+
if isinstance(ip_address, ipaddress.IPv4Address) or isinstance(
|
|
222
|
+
ip_address, ipaddress.IPv4Address
|
|
223
|
+
):
|
|
224
|
+
return str(ip_address)
|
|
225
|
+
|
|
226
|
+
return str(ipaddress.ip_address(ip_address))
|
|
227
|
+
|
|
228
|
+
|
|
207
229
|
def _config_path(config_path_arg) -> str:
|
|
208
230
|
if config_path_arg and not isinstance(config_path_arg, str):
|
|
209
231
|
raise ValueError(f"config_path={config_path_arg} is not a valid str")
|
|
Binary file
|
portforward/_portforward.pyi
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: portforward
|
|
3
|
-
Version: 0.6.
|
|
3
|
+
Version: 0.6.2
|
|
4
4
|
Classifier: Programming Language :: Rust
|
|
5
5
|
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
6
6
|
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
@@ -18,9 +18,9 @@ Author-email: Sebastian Ziemann <corka149@mailbox.org>
|
|
|
18
18
|
License: MIT License
|
|
19
19
|
Requires-Python: >=3.7
|
|
20
20
|
Description-Content-Type: text/x-rst; charset=UTF-8
|
|
21
|
-
Project-URL: Repository, https://github.com/pytogo/portforward.git
|
|
22
21
|
Project-URL: Documentation, https://portforward.readthedocs.io
|
|
23
22
|
Project-URL: Changelog, https://github.com/pytogo/portforward/blob/main/HISTORY.rst
|
|
23
|
+
Project-URL: Repository, https://github.com/pytogo/portforward.git
|
|
24
24
|
|
|
25
25
|
===========
|
|
26
26
|
portforward
|
|
@@ -58,9 +58,9 @@ Installation
|
|
|
58
58
|
|
|
59
59
|
Wheels are available for:
|
|
60
60
|
|
|
61
|
-
* Windows
|
|
62
|
-
* MacOS X
|
|
63
|
-
* Linux
|
|
61
|
+
* Windows (architectures: x64, x86)
|
|
62
|
+
* MacOS X (architectures: x86_64, aarch64)
|
|
63
|
+
* Linux (architectures: x86_64, x86, aarch64)
|
|
64
64
|
|
|
65
65
|
with Python versions:
|
|
66
66
|
|
|
@@ -70,11 +70,6 @@ with Python versions:
|
|
|
70
70
|
* 3.11
|
|
71
71
|
* 3.12
|
|
72
72
|
|
|
73
|
-
and architectures:
|
|
74
|
-
|
|
75
|
-
* x84_64
|
|
76
|
-
* arm64 (known as M1/Apple Chip - MacOS only)
|
|
77
|
-
|
|
78
73
|
**Requirements for installation from source**
|
|
79
74
|
|
|
80
75
|
The following things are required when there is no wheel available for the target system.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
portforward-0.6.2.dist-info/METADATA,sha256=lW-CLvKGfnT_0yuV9DmXdycKGqRMuZN7Np9H9jjoU3M,3844
|
|
2
|
+
portforward-0.6.2.dist-info/WHEEL,sha256=ZTY_kOhWGECXxDmzhXy-zxezgT1DhbmPVnjnbRdLmy8,97
|
|
3
|
+
portforward-0.6.2.dist-info/license_files/LICENSE,sha256=_-nf_xCZIwUkKBXXiYR-fjbXGhmx6V-7b3jSKoolnO4,1096
|
|
4
|
+
portforward-0.6.2.dist-info/license_files/AUTHORS.rst,sha256=mskf9O-AvJL9NxWUYX0nJRuLfBw7SH-T-H-pPYLW-xI,176
|
|
5
|
+
portforward/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
+
portforward/_portforward.pyi,sha256=UDGuRjzq4fFH2vyVMKGpsBQvYq8MK0LfFsM1FxljTX4,353
|
|
7
|
+
portforward/__init__.py,sha256=j6RtAqZa6JIEgWbl5n1Tudc-HeewIJAqcsoVBukqBDg,7062
|
|
8
|
+
portforward/_portforward.cp312-win_amd64.pyd,sha256=LXfC9FgfjANiCEwWaj2i8Cv_FVRsAohSH7F6zYzf-yY,8211456
|
|
9
|
+
portforward-0.6.2.dist-info/RECORD,,
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
portforward-0.6.1.dist-info/METADATA,sha256=FMxTOMp1qaX0TbENQtjpWLV8Yk9jGJRnut8Go5VF0fg,3828
|
|
2
|
-
portforward-0.6.1.dist-info/WHEEL,sha256=ZTY_kOhWGECXxDmzhXy-zxezgT1DhbmPVnjnbRdLmy8,97
|
|
3
|
-
portforward-0.6.1.dist-info/license_files/LICENSE,sha256=_-nf_xCZIwUkKBXXiYR-fjbXGhmx6V-7b3jSKoolnO4,1096
|
|
4
|
-
portforward-0.6.1.dist-info/license_files/AUTHORS.rst,sha256=mskf9O-AvJL9NxWUYX0nJRuLfBw7SH-T-H-pPYLW-xI,176
|
|
5
|
-
portforward/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
-
portforward/_portforward.pyi,sha256=iZTDdh3rwEtEfNOcVV69xgiqyPOV7n6LUNAiKPSAbII,350
|
|
7
|
-
portforward/__init__.py,sha256=o4WIA6da3jj768ZkjHMTIzieHVjfRf1-uyAH84xoTfI,6279
|
|
8
|
-
portforward/_portforward.cp312-win_amd64.pyd,sha256=tD9UY-awiAkrMaJw5R9zqvsz2QvncBIF7wGQTrN2Lyg,10798592
|
|
9
|
-
portforward-0.6.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|