portforward 0.6.2__cp39-none-win32.whl → 0.7.1__cp39-none-win32.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 CHANGED
@@ -2,7 +2,7 @@
2
2
  Easy Kubernetes Port-Forward For Python
3
3
  """
4
4
 
5
- __version__ = "0.6.2"
5
+ __version__ = "0.7.1"
6
6
 
7
7
  import asyncio
8
8
  import contextlib
@@ -57,7 +57,7 @@ def forward(
57
57
 
58
58
  :param namespace: Target namespace
59
59
  :param pod_or_service: Name of target Pod or service
60
- :param from_port: Local port
60
+ :param from_port: Local port, or 0 to use any free port
61
61
  :param to_port: Port inside the pod
62
62
  :param config_path: Path for loading kube config
63
63
  :param waiting: Delay in seconds
@@ -129,6 +129,11 @@ class PortForwarder:
129
129
  def is_stopped(self):
130
130
  return self._async_forwarder.is_stopped
131
131
 
132
+ @property
133
+ def from_port(self):
134
+ """The local port that was actually used for the portforward."""
135
+ return self._async_forwarder.from_port
136
+
132
137
 
133
138
  class AsyncPortForwarder:
134
139
  """Use the same args as the `portforward.forward` method."""
@@ -158,11 +163,12 @@ class AsyncPortForwarder:
158
163
  bind_ip = _validate_ip_address(bind_ip)
159
164
 
160
165
  self.actual_pod_name: str = ""
166
+ self.from_port: int = 0
161
167
  self._is_stopped: bool = False
162
168
  self.bind_address: str = f"{bind_ip}:{from_port}"
163
169
 
164
170
  async def forward(self):
165
- self.actual_pod_name = await _portforward.forward(
171
+ (self.actual_pod_name, self.from_port) = await _portforward.forward(
166
172
  self.namespace,
167
173
  self.pod_or_service,
168
174
  self.bind_address,
@@ -193,14 +199,11 @@ def _validate_str(arg_name, arg) -> str:
193
199
  if len(arg) == 0:
194
200
  raise ValueError(f"{arg_name} cannot be an empty str")
195
201
 
196
- if "/" in arg:
197
- raise ValueError(f"{arg_name} contains illegal character '/'")
198
-
199
202
  return arg
200
203
 
201
204
 
202
205
  def _validate_port(arg_name, arg) -> int:
203
- in_range = arg and 0 < arg < 65536
206
+ in_range = arg is not None and 0 <= arg < 65536
204
207
  if arg is None or not isinstance(arg, int) or not in_range:
205
208
  raise ValueError(f"{arg_name}={arg} is not a valid port")
206
209
 
@@ -247,7 +250,4 @@ def _kube_context(context):
247
250
  if not isinstance(context, str):
248
251
  raise ValueError(f"kube_context={context} is not a valid str")
249
252
 
250
- if "/" in context:
251
- raise ValueError("kube_context contains illegal character '/'")
252
-
253
253
  return context
Binary file
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: portforward
3
- Version: 0.6.2
3
+ Version: 0.7.1
4
4
  Classifier: Programming Language :: Rust
5
5
  Classifier: Programming Language :: Python :: Implementation :: CPython
6
6
  Classifier: Programming Language :: Python :: Implementation :: PyPy
@@ -19,8 +19,8 @@ License: MIT License
19
19
  Requires-Python: >=3.7
20
20
  Description-Content-Type: text/x-rst; charset=UTF-8
21
21
  Project-URL: Changelog, https://github.com/pytogo/portforward/blob/main/HISTORY.rst
22
- Project-URL: Documentation, https://portforward.readthedocs.io
23
22
  Project-URL: Repository, https://github.com/pytogo/portforward.git
23
+ Project-URL: Documentation, https://portforward.readthedocs.io
24
24
 
25
25
  ===========
26
26
  portforward
@@ -64,11 +64,11 @@ Wheels are available for:
64
64
 
65
65
  with Python versions:
66
66
 
67
- * 3.8
68
67
  * 3.9
69
68
  * 3.10
70
69
  * 3.11
71
70
  * 3.12
71
+ * 3.13
72
72
 
73
73
  **Requirements for installation from source**
74
74
 
@@ -0,0 +1,9 @@
1
+ portforward-0.7.1.dist-info/METADATA,sha256=XYy4LPpLRtncTbRmH4lPc9pX6WPUmGa_R4sO3g9b05I,3845
2
+ portforward-0.7.1.dist-info/WHEEL,sha256=-pOKL-1cllc2H3p_NoLr-36gcqPykwR8M9OfdKqys-Q,92
3
+ portforward-0.7.1.dist-info/license_files/LICENSE,sha256=_-nf_xCZIwUkKBXXiYR-fjbXGhmx6V-7b3jSKoolnO4,1096
4
+ portforward-0.7.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=UDGuRjzq4fFH2vyVMKGpsBQvYq8MK0LfFsM1FxljTX4,353
7
+ portforward/__init__.py,sha256=XvIOYJ8iCV9tgefojXHItQ_-doS9bFhVpbsXJ_9XLH0,7125
8
+ portforward/_portforward.cp39-win32.pyd,sha256=vLtrf8tDlA0rKiBhugySd_GOKm0VABOXrFXXRcd99s8,6594048
9
+ portforward-0.7.1.dist-info/RECORD,,
@@ -1,9 +0,0 @@
1
- portforward-0.6.2.dist-info/METADATA,sha256=70RzsEV8M2YzoV5uVGymAm-y_Ntm1mg91AYrFio6hmE,3844
2
- portforward-0.6.2.dist-info/WHEEL,sha256=-pOKL-1cllc2H3p_NoLr-36gcqPykwR8M9OfdKqys-Q,92
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.cp39-win32.pyd,sha256=lP0NIIpLXBVkjYhIJ9HpVYXpXqimm9FX8Qi1vaAkEKY,6651392
9
- portforward-0.6.2.dist-info/RECORD,,