portforward 0.5.0__cp310-cp310-win_amd64.whl → 0.7.3__cp310-cp310-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.py → portforward/__init__.py +128 -71
- portforward/_portforward.cp310-win_amd64.pyd +0 -0
- portforward/_portforward.pyi +17 -0
- portforward/py.typed +0 -0
- portforward-0.7.3.dist-info/METADATA +138 -0
- portforward-0.7.3.dist-info/RECORD +9 -0
- {portforward-0.5.0.dist-info → portforward-0.7.3.dist-info}/WHEEL +1 -2
- _portforward.h +0 -83
- _portforward.pyd +0 -0
- portforward-0.5.0.dist-info/METADATA +0 -256
- portforward-0.5.0.dist-info/RECORD +0 -9
- portforward-0.5.0.dist-info/top_level.txt +0 -2
- {portforward-0.5.0.dist-info → portforward-0.7.3.dist-info/licenses}/AUTHORS.rst +0 -0
- {portforward-0.5.0.dist-info → portforward-0.7.3.dist-info/licenses}/LICENSE +0 -0
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
"""
|
|
2
|
-
Kubernetes Port-Forward
|
|
2
|
+
Easy Kubernetes Port-Forward For Python
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
|
-
__version__ = "0.
|
|
5
|
+
__version__ = "0.7.3"
|
|
6
6
|
|
|
7
|
+
import asyncio
|
|
7
8
|
import contextlib
|
|
9
|
+
import ipaddress
|
|
8
10
|
import os
|
|
9
11
|
from enum import Enum
|
|
10
12
|
from pathlib import Path
|
|
11
|
-
from typing import
|
|
13
|
+
from typing import Generator, Optional, Union
|
|
12
14
|
|
|
13
|
-
import _portforward
|
|
15
|
+
from portforward import _portforward
|
|
14
16
|
|
|
15
17
|
|
|
16
18
|
class PortforwardError(Exception):
|
|
@@ -25,53 +27,6 @@ class LogLevel(Enum):
|
|
|
25
27
|
OFF = 4
|
|
26
28
|
|
|
27
29
|
|
|
28
|
-
class PortForwarder:
|
|
29
|
-
def __init__(
|
|
30
|
-
self,
|
|
31
|
-
namespace: str,
|
|
32
|
-
pod_or_service: str,
|
|
33
|
-
from_port: int,
|
|
34
|
-
to_port: int,
|
|
35
|
-
config_path: Optional[str] = None,
|
|
36
|
-
waiting: float = 0.1,
|
|
37
|
-
log_level: LogLevel = LogLevel.INFO,
|
|
38
|
-
kube_context: str = "",
|
|
39
|
-
) -> None:
|
|
40
|
-
self.namespace: str = _validate_str("namespace", namespace)
|
|
41
|
-
self.pod_or_service: str = _validate_str("pod_or_service", pod_or_service)
|
|
42
|
-
self.from_port: int = _validate_port("from_port", from_port)
|
|
43
|
-
self.to_port: int = _validate_port("to_port", to_port)
|
|
44
|
-
self.log_level: LogLevel = _validate_log(log_level)
|
|
45
|
-
self.waiting: float = waiting
|
|
46
|
-
|
|
47
|
-
self.config_path: str = _config_path(config_path)
|
|
48
|
-
self.kube_context: str = kube_context if kube_context else ""
|
|
49
|
-
|
|
50
|
-
_kube_context(kube_context)
|
|
51
|
-
|
|
52
|
-
self.actual_pod_name: str = ""
|
|
53
|
-
self._is_stopped: bool = False
|
|
54
|
-
|
|
55
|
-
def forward(self):
|
|
56
|
-
_portforward.forward(
|
|
57
|
-
self.namespace,
|
|
58
|
-
self.pod_or_service,
|
|
59
|
-
self.from_port,
|
|
60
|
-
self.to_port,
|
|
61
|
-
self.config_path,
|
|
62
|
-
self.log_level.value,
|
|
63
|
-
self.kube_context,
|
|
64
|
-
)
|
|
65
|
-
self._is_stopped = False
|
|
66
|
-
|
|
67
|
-
def stop(self):
|
|
68
|
-
_portforward.stop(self.namespace, self.pod_or_service, self.to_port)
|
|
69
|
-
self._is_stopped = True
|
|
70
|
-
|
|
71
|
-
def is_stopped(self):
|
|
72
|
-
return self._is_stopped
|
|
73
|
-
|
|
74
|
-
|
|
75
30
|
@contextlib.contextmanager
|
|
76
31
|
def forward(
|
|
77
32
|
namespace: str,
|
|
@@ -82,7 +37,8 @@ def forward(
|
|
|
82
37
|
waiting: float = 0.1,
|
|
83
38
|
log_level: LogLevel = LogLevel.INFO,
|
|
84
39
|
kube_context: str = "",
|
|
85
|
-
|
|
40
|
+
bind_ip: Union[ipaddress.IPv4Address, ipaddress.IPv6Address, str, None] = None,
|
|
41
|
+
) -> Generator["PortForwarder", None, None]:
|
|
86
42
|
"""
|
|
87
43
|
Connects to a **pod or service** and tunnels traffic from a local port to
|
|
88
44
|
this target. It uses the kubectl kube config from the home dir if no path
|
|
@@ -92,30 +48,22 @@ def forward(
|
|
|
92
48
|
|
|
93
49
|
It will fall back to in-cluster-config in case no kube config file exists.
|
|
94
50
|
|
|
95
|
-
Caution: Go and the port-forwarding needs some ms to be ready. ``waiting``
|
|
96
|
-
can be used to wait until the port-forward is ready.
|
|
97
|
-
|
|
98
51
|
(Best consumed as context manager.)
|
|
99
52
|
|
|
100
53
|
Example:
|
|
101
54
|
>>> import portforward
|
|
102
55
|
>>> with portforward.forward("test", "web-svc", 9000, 80):
|
|
103
56
|
>>> # Do work
|
|
104
|
-
>>>
|
|
105
|
-
>>> # Or without context manager
|
|
106
|
-
>>>
|
|
107
|
-
>>> forwarder = portforward.forward("test", "some-pod", 9000, 80)
|
|
108
|
-
>>> # Do work
|
|
109
|
-
>>> forwarder.stop()
|
|
110
57
|
|
|
111
58
|
:param namespace: Target namespace
|
|
112
59
|
:param pod_or_service: Name of target Pod or service
|
|
113
|
-
:param from_port: Local port
|
|
60
|
+
:param from_port: Local port, or 0 to use any free port
|
|
114
61
|
:param to_port: Port inside the pod
|
|
115
62
|
:param config_path: Path for loading kube config
|
|
116
63
|
:param waiting: Delay in seconds
|
|
117
64
|
:param log_level: Level of logging
|
|
118
65
|
:param kube_context: Target kubernetes context (fallback is current context)
|
|
66
|
+
:param bind_ip: To which IP shall the portforward be bind
|
|
119
67
|
:return: forwarder to manual stop the forwarding
|
|
120
68
|
"""
|
|
121
69
|
|
|
@@ -128,6 +76,7 @@ def forward(
|
|
|
128
76
|
waiting,
|
|
129
77
|
log_level,
|
|
130
78
|
kube_context,
|
|
79
|
+
bind_ip,
|
|
131
80
|
)
|
|
132
81
|
|
|
133
82
|
try:
|
|
@@ -143,6 +92,103 @@ def forward(
|
|
|
143
92
|
forwarder.stop()
|
|
144
93
|
|
|
145
94
|
|
|
95
|
+
class PortForwarder:
|
|
96
|
+
"""Use the same args as the `portforward.forward` method."""
|
|
97
|
+
|
|
98
|
+
def __init__(
|
|
99
|
+
self,
|
|
100
|
+
namespace: str,
|
|
101
|
+
pod_or_service: str,
|
|
102
|
+
from_port: int,
|
|
103
|
+
to_port: int,
|
|
104
|
+
config_path: Optional[str] = None,
|
|
105
|
+
waiting: float = 0.1,
|
|
106
|
+
log_level: LogLevel = LogLevel.INFO,
|
|
107
|
+
kube_context: str = "",
|
|
108
|
+
bind_ip: Union[ipaddress.IPv4Address, ipaddress.IPv6Address, str, None] = None,
|
|
109
|
+
) -> None:
|
|
110
|
+
self._async_forwarder = AsyncPortForwarder(
|
|
111
|
+
namespace,
|
|
112
|
+
pod_or_service,
|
|
113
|
+
from_port,
|
|
114
|
+
to_port,
|
|
115
|
+
config_path,
|
|
116
|
+
waiting,
|
|
117
|
+
log_level,
|
|
118
|
+
kube_context,
|
|
119
|
+
bind_ip,
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
def forward(self):
|
|
123
|
+
asyncio.run(self._async_forwarder.forward())
|
|
124
|
+
|
|
125
|
+
def stop(self):
|
|
126
|
+
asyncio.run(self._async_forwarder.stop())
|
|
127
|
+
|
|
128
|
+
@property
|
|
129
|
+
def is_stopped(self):
|
|
130
|
+
return self._async_forwarder.is_stopped
|
|
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
|
+
|
|
137
|
+
|
|
138
|
+
class AsyncPortForwarder:
|
|
139
|
+
"""Use the same args as the `portforward.forward` method."""
|
|
140
|
+
|
|
141
|
+
def __init__(
|
|
142
|
+
self,
|
|
143
|
+
namespace: str,
|
|
144
|
+
pod_or_service: str,
|
|
145
|
+
from_port: int,
|
|
146
|
+
to_port: int,
|
|
147
|
+
config_path: Optional[str] = None,
|
|
148
|
+
waiting: float = 0.1,
|
|
149
|
+
log_level: LogLevel = LogLevel.INFO,
|
|
150
|
+
kube_context: str = "",
|
|
151
|
+
bind_ip: Union[ipaddress.IPv4Address, ipaddress.IPv6Address, str, None] = None,
|
|
152
|
+
) -> None:
|
|
153
|
+
self.namespace: str = _validate_str("namespace", namespace)
|
|
154
|
+
self.pod_or_service: str = _validate_str("pod_or_service", pod_or_service)
|
|
155
|
+
self.to_port: int = _validate_port("to_port", to_port)
|
|
156
|
+
self.log_level: LogLevel = _validate_log(log_level)
|
|
157
|
+
self.waiting: float = waiting
|
|
158
|
+
|
|
159
|
+
self.config_path: str = _config_path(config_path)
|
|
160
|
+
self.kube_context: str = _kube_context(kube_context)
|
|
161
|
+
|
|
162
|
+
_validate_port("from_port", from_port)
|
|
163
|
+
bind_ip = _validate_ip_address(bind_ip)
|
|
164
|
+
|
|
165
|
+
self.actual_pod_name: str = ""
|
|
166
|
+
self.from_port: int = 0
|
|
167
|
+
self._is_stopped: bool = False
|
|
168
|
+
self.bind_address: str = f"{bind_ip}:{from_port}"
|
|
169
|
+
|
|
170
|
+
async def forward(self):
|
|
171
|
+
(self.actual_pod_name, self.from_port) = await _portforward.forward(
|
|
172
|
+
self.namespace,
|
|
173
|
+
self.pod_or_service,
|
|
174
|
+
self.bind_address,
|
|
175
|
+
self.to_port,
|
|
176
|
+
self.config_path,
|
|
177
|
+
self.log_level.value,
|
|
178
|
+
self.kube_context,
|
|
179
|
+
)
|
|
180
|
+
self._is_stopped = False
|
|
181
|
+
|
|
182
|
+
async def stop(self):
|
|
183
|
+
await _portforward.stop(
|
|
184
|
+
self.namespace, self.actual_pod_name, self.to_port, self.log_level.value
|
|
185
|
+
)
|
|
186
|
+
self._is_stopped = True
|
|
187
|
+
|
|
188
|
+
def is_stopped(self):
|
|
189
|
+
return self._is_stopped
|
|
190
|
+
|
|
191
|
+
|
|
146
192
|
# ===== PRIVATE =====
|
|
147
193
|
|
|
148
194
|
|
|
@@ -153,14 +199,11 @@ def _validate_str(arg_name, arg) -> str:
|
|
|
153
199
|
if len(arg) == 0:
|
|
154
200
|
raise ValueError(f"{arg_name} cannot be an empty str")
|
|
155
201
|
|
|
156
|
-
if "/" in arg:
|
|
157
|
-
raise ValueError(f"{arg_name} contains illegal character '/'")
|
|
158
|
-
|
|
159
202
|
return arg
|
|
160
203
|
|
|
161
204
|
|
|
162
205
|
def _validate_port(arg_name, arg) -> int:
|
|
163
|
-
in_range = arg and 0
|
|
206
|
+
in_range = arg is not None and 0 <= arg < 65536
|
|
164
207
|
if arg is None or not isinstance(arg, int) or not in_range:
|
|
165
208
|
raise ValueError(f"{arg_name}={arg} is not a valid port")
|
|
166
209
|
|
|
@@ -174,6 +217,18 @@ def _validate_log(log_level):
|
|
|
174
217
|
return log_level
|
|
175
218
|
|
|
176
219
|
|
|
220
|
+
def _validate_ip_address(ip_address):
|
|
221
|
+
if not ip_address:
|
|
222
|
+
return "127.0.0.1"
|
|
223
|
+
|
|
224
|
+
if isinstance(ip_address, ipaddress.IPv4Address) or isinstance(
|
|
225
|
+
ip_address, ipaddress.IPv4Address
|
|
226
|
+
):
|
|
227
|
+
return str(ip_address)
|
|
228
|
+
|
|
229
|
+
return str(ipaddress.ip_address(ip_address))
|
|
230
|
+
|
|
231
|
+
|
|
177
232
|
def _config_path(config_path_arg) -> str:
|
|
178
233
|
if config_path_arg and not isinstance(config_path_arg, str):
|
|
179
234
|
raise ValueError(f"config_path={config_path_arg} is not a valid str")
|
|
@@ -188,9 +243,11 @@ def _config_path(config_path_arg) -> str:
|
|
|
188
243
|
return config_path if os.path.isfile(config_path) else ""
|
|
189
244
|
|
|
190
245
|
|
|
191
|
-
def _kube_context(
|
|
192
|
-
if
|
|
193
|
-
|
|
246
|
+
def _kube_context(context):
|
|
247
|
+
if not context:
|
|
248
|
+
return ""
|
|
249
|
+
|
|
250
|
+
if not isinstance(context, str):
|
|
251
|
+
raise ValueError(f"kube_context={context} is not a valid str")
|
|
194
252
|
|
|
195
|
-
|
|
196
|
-
raise ValueError(f"kube_context contains illegal character '/'")
|
|
253
|
+
return context
|
|
Binary file
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Rust native module / Python C Extension
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
async def forward(
|
|
6
|
+
namespace: str,
|
|
7
|
+
pod_or_service: str,
|
|
8
|
+
bind_address: str,
|
|
9
|
+
to_port: int,
|
|
10
|
+
config_path: str,
|
|
11
|
+
log_level: int,
|
|
12
|
+
kube_context: str,
|
|
13
|
+
) -> None:
|
|
14
|
+
pass
|
|
15
|
+
|
|
16
|
+
async def stop(namespace: str, actual_pod: str, to_port: int, log_level: int) -> None:
|
|
17
|
+
pass
|
portforward/py.typed
ADDED
|
File without changes
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: portforward
|
|
3
|
+
Version: 0.7.3
|
|
4
|
+
Classifier: Programming Language :: Rust
|
|
5
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
6
|
+
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
License-File: AUTHORS.rst
|
|
15
|
+
Summary: Easy Kubernetes Port-Forward For Python
|
|
16
|
+
Keywords: portforward,kubernetes,k8s
|
|
17
|
+
Author-email: Sebastian Ziemann <corka149@mailbox.org>
|
|
18
|
+
License: MIT License
|
|
19
|
+
Requires-Python: >=3.7
|
|
20
|
+
Description-Content-Type: text/x-rst; charset=UTF-8
|
|
21
|
+
Project-URL: Documentation, https://portforward.readthedocs.io
|
|
22
|
+
Project-URL: Repository, https://github.com/pytogo/portforward.git
|
|
23
|
+
Project-URL: Changelog, https://github.com/pytogo/portforward/blob/main/HISTORY.rst
|
|
24
|
+
|
|
25
|
+
===========
|
|
26
|
+
portforward
|
|
27
|
+
===========
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
.. image:: https://img.shields.io/pypi/v/portforward.svg
|
|
31
|
+
:target: https://pypi.python.org/pypi/portforward
|
|
32
|
+
|
|
33
|
+
.. image:: https://img.shields.io/pypi/status/portforward.svg
|
|
34
|
+
:target: https://pypi.python.org/pypi/portforward
|
|
35
|
+
|
|
36
|
+
.. image:: https://img.shields.io/pypi/dm/portforward
|
|
37
|
+
:alt: PyPI - Downloads
|
|
38
|
+
|
|
39
|
+
.. image:: https://readthedocs.org/projects/portforward/badge/?version=latest
|
|
40
|
+
:target: https://portforward.readthedocs.io/en/latest/?version=latest
|
|
41
|
+
:alt: Documentation Status
|
|
42
|
+
|
|
43
|
+
.. image:: https://github.com/pytogo/portforward/actions/workflows/python-app.yml/badge.svg
|
|
44
|
+
:target: https://github.com/pytogo/portforward/actions
|
|
45
|
+
:alt: Build status
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
Easy Kubernetes Port-Forward For Python
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
* Free software: MIT license
|
|
53
|
+
* Documentation: https://portforward.readthedocs.io.
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
Installation
|
|
57
|
+
-----------------------------
|
|
58
|
+
|
|
59
|
+
Wheels are available for:
|
|
60
|
+
|
|
61
|
+
* **Windows** (architectures: ``x64``, ``x86``)
|
|
62
|
+
* **macOS** (architectures: ``x86_64``, ``aarch64``)
|
|
63
|
+
* **Linux** (architectures: ``x86_64``, ``x86``, ``aarch64``, ``armv7``, ``s390x``, ``ppc64le``)
|
|
64
|
+
|
|
65
|
+
Musllinux wheels (Alpine‑compatible) are provided for ``x86_64``, ``x86``, ``aarch64`` and ``armv7``.
|
|
66
|
+
|
|
67
|
+
with Python versions:
|
|
68
|
+
|
|
69
|
+
* 3.9
|
|
70
|
+
* 3.10
|
|
71
|
+
* 3.11
|
|
72
|
+
* 3.12
|
|
73
|
+
* 3.13
|
|
74
|
+
|
|
75
|
+
**Requirements for installation from source**
|
|
76
|
+
|
|
77
|
+
The following things are required when there is no wheel available for the target system.
|
|
78
|
+
|
|
79
|
+
* `Rust` installed and available in the path (https://www.rust-lang.org/tools/install)
|
|
80
|
+
* `Python` (at least v3.7 - below was never tested but might work)
|
|
81
|
+
|
|
82
|
+
Pip knows how to install ``portforward``.
|
|
83
|
+
|
|
84
|
+
.. code-block::
|
|
85
|
+
|
|
86
|
+
pip install portforward
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
Quickstart
|
|
90
|
+
----------
|
|
91
|
+
|
|
92
|
+
.. code-block:: Python
|
|
93
|
+
|
|
94
|
+
import requests
|
|
95
|
+
|
|
96
|
+
import portforward
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def main():
|
|
100
|
+
namespace = "test"
|
|
101
|
+
pod_name = "web" # You can also use a service name instead
|
|
102
|
+
local_port = 9000 # from port
|
|
103
|
+
pod_port = 80 # to port
|
|
104
|
+
|
|
105
|
+
# No path to kube config provided - will use default from $HOME/.kube/config
|
|
106
|
+
with portforward.forward(namespace, pod_name, local_port, pod_port):
|
|
107
|
+
response = requests.get("http://localhost:9000")
|
|
108
|
+
print(f"Done: \n'{response.status_code}'\n'{response.text[:20]}...'")
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
if __name__ == "__main__":
|
|
112
|
+
main()
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
Features
|
|
116
|
+
--------
|
|
117
|
+
|
|
118
|
+
* Native Kubernetes port-forwarding with the ``.kube/config`` from the home dir
|
|
119
|
+
or any other path to config.
|
|
120
|
+
* Portforward for pods and services - the lib will first look for a pod with matching name then for
|
|
121
|
+
a service
|
|
122
|
+
* Waiting for a pod to become ready
|
|
123
|
+
* Multiple forwards per pod or service
|
|
124
|
+
* As context manager, sync or async client
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
Development
|
|
128
|
+
-----------
|
|
129
|
+
|
|
130
|
+
In case you want to develop on this library itself please take a look at the CONTRIBUTING page.
|
|
131
|
+
|
|
132
|
+
Credits
|
|
133
|
+
-------
|
|
134
|
+
|
|
135
|
+
This project is enabled by PyO3_.
|
|
136
|
+
|
|
137
|
+
.. _PyO3: https://pyo3.rs
|
|
138
|
+
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
portforward-0.7.3.dist-info/METADATA,sha256=fg1fMNa7rbi-Z19mWoBvQ0GpmyJL9c6OT63ZZmvV72w,4029
|
|
2
|
+
portforward-0.7.3.dist-info/WHEEL,sha256=77DqkvxB4HqZitBRK_M49NRS207JKb0MotMEjnxEWQ8,96
|
|
3
|
+
portforward-0.7.3.dist-info/licenses/LICENSE,sha256=_-nf_xCZIwUkKBXXiYR-fjbXGhmx6V-7b3jSKoolnO4,1096
|
|
4
|
+
portforward-0.7.3.dist-info/licenses/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=vnkQ8n7alOiNHEjhxcRQTfZlZBkashXrRv74NpDwexA,7125
|
|
8
|
+
portforward/_portforward.cp310-win_amd64.pyd,sha256=4D8s-t167eK14DE42J4sSqn4Nw60QkYHekqssCnbXJM,11387904
|
|
9
|
+
portforward-0.7.3.dist-info/RECORD,,
|
_portforward.h
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
/* Code generated by cmd/cgo; DO NOT EDIT. */
|
|
2
|
-
|
|
3
|
-
/* package github.com/pytogo/portforward */
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
#line 1 "cgo-builtin-export-prolog"
|
|
7
|
-
|
|
8
|
-
#include <stddef.h> /* for ptrdiff_t below */
|
|
9
|
-
|
|
10
|
-
#ifndef GO_CGO_EXPORT_PROLOGUE_H
|
|
11
|
-
#define GO_CGO_EXPORT_PROLOGUE_H
|
|
12
|
-
|
|
13
|
-
#ifndef GO_CGO_GOSTRING_TYPEDEF
|
|
14
|
-
typedef struct { const char *p; ptrdiff_t n; } _GoString_;
|
|
15
|
-
#endif
|
|
16
|
-
|
|
17
|
-
#endif
|
|
18
|
-
|
|
19
|
-
/* Start of preamble from import "C" comments. */
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
#line 3 "main.go"
|
|
23
|
-
#include <Python.h>
|
|
24
|
-
int PyArg_ParseTuple_ssiisis(PyObject* args, char** a, char** b, int* c, int* d, char** e, int* f, char** g);
|
|
25
|
-
int PyArg_ParseTuple_ssi(PyObject* args, char** a, char** b, int* c);
|
|
26
|
-
void raise_exception(char *msg);
|
|
27
|
-
|
|
28
|
-
#line 1 "cgo-generated-wrapper"
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
/* End of preamble from import "C" comments. */
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
/* Start of boilerplate cgo prologue. */
|
|
35
|
-
#line 1 "cgo-gcc-export-header-prolog"
|
|
36
|
-
|
|
37
|
-
#ifndef GO_CGO_PROLOGUE_H
|
|
38
|
-
#define GO_CGO_PROLOGUE_H
|
|
39
|
-
|
|
40
|
-
typedef signed char GoInt8;
|
|
41
|
-
typedef unsigned char GoUint8;
|
|
42
|
-
typedef short GoInt16;
|
|
43
|
-
typedef unsigned short GoUint16;
|
|
44
|
-
typedef int GoInt32;
|
|
45
|
-
typedef unsigned int GoUint32;
|
|
46
|
-
typedef long long GoInt64;
|
|
47
|
-
typedef unsigned long long GoUint64;
|
|
48
|
-
typedef GoInt64 GoInt;
|
|
49
|
-
typedef GoUint64 GoUint;
|
|
50
|
-
typedef __SIZE_TYPE__ GoUintptr;
|
|
51
|
-
typedef float GoFloat32;
|
|
52
|
-
typedef double GoFloat64;
|
|
53
|
-
typedef float _Complex GoComplex64;
|
|
54
|
-
typedef double _Complex GoComplex128;
|
|
55
|
-
|
|
56
|
-
/*
|
|
57
|
-
static assertion to make sure the file is being used on architecture
|
|
58
|
-
at least with matching size of GoInt.
|
|
59
|
-
*/
|
|
60
|
-
typedef char _check_for_64_bit_pointer_matching_GoInt[sizeof(void*)==64/8 ? 1:-1];
|
|
61
|
-
|
|
62
|
-
#ifndef GO_CGO_GOSTRING_TYPEDEF
|
|
63
|
-
typedef _GoString_ GoString;
|
|
64
|
-
#endif
|
|
65
|
-
typedef void *GoMap;
|
|
66
|
-
typedef void *GoChan;
|
|
67
|
-
typedef struct { void *t; void *v; } GoInterface;
|
|
68
|
-
typedef struct { void *data; GoInt len; GoInt cap; } GoSlice;
|
|
69
|
-
|
|
70
|
-
#endif
|
|
71
|
-
|
|
72
|
-
/* End of boilerplate cgo prologue. */
|
|
73
|
-
|
|
74
|
-
#ifdef __cplusplus
|
|
75
|
-
extern "C" {
|
|
76
|
-
#endif
|
|
77
|
-
|
|
78
|
-
extern __declspec(dllexport) PyObject* forward(PyObject* self, PyObject* args);
|
|
79
|
-
extern __declspec(dllexport) PyObject* stop(PyObject* self, PyObject* args);
|
|
80
|
-
|
|
81
|
-
#ifdef __cplusplus
|
|
82
|
-
}
|
|
83
|
-
#endif
|
_portforward.pyd
DELETED
|
Binary file
|
|
@@ -1,256 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: portforward
|
|
3
|
-
Version: 0.5.0
|
|
4
|
-
Summary: Kubernetes Port-Forward Go-Edition For Python
|
|
5
|
-
Home-page: https://github.com/pytogo/portforward
|
|
6
|
-
Author: Sebastian Ziemann
|
|
7
|
-
Author-email: corka149@mailbox.org
|
|
8
|
-
License: MIT license
|
|
9
|
-
Keywords: portforward
|
|
10
|
-
Platform: UNKNOWN
|
|
11
|
-
Classifier: Development Status :: 4 - Beta
|
|
12
|
-
Classifier: Intended Audience :: Developers
|
|
13
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
-
Classifier: Natural Language :: English
|
|
15
|
-
Classifier: Programming Language :: Python :: 3
|
|
16
|
-
Classifier: Programming Language :: Python :: 3.6
|
|
17
|
-
Classifier: Programming Language :: Python :: 3.7
|
|
18
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
19
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
20
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
-
Requires-Python: >=3.6
|
|
22
|
-
License-File: LICENSE
|
|
23
|
-
License-File: AUTHORS.rst
|
|
24
|
-
|
|
25
|
-
===========
|
|
26
|
-
portforward
|
|
27
|
-
===========
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
.. image:: https://img.shields.io/pypi/v/portforward.svg
|
|
31
|
-
:target: https://pypi.python.org/pypi/portforward
|
|
32
|
-
|
|
33
|
-
.. image:: https://img.shields.io/pypi/status/portforward.svg
|
|
34
|
-
:target: https://pypi.python.org/pypi/portforward
|
|
35
|
-
|
|
36
|
-
.. image:: https://img.shields.io/pypi/dm/portforward
|
|
37
|
-
:alt: PyPI - Downloads
|
|
38
|
-
|
|
39
|
-
.. image:: https://readthedocs.org/projects/portforward/badge/?version=latest
|
|
40
|
-
:target: https://portforward.readthedocs.io/en/latest/?version=latest
|
|
41
|
-
:alt: Documentation Status
|
|
42
|
-
|
|
43
|
-
.. image:: https://github.com/pytogo/portforward/actions/workflows/python-app.yml/badge.svg
|
|
44
|
-
:target: https://github.com/pytogo/portforward/actions
|
|
45
|
-
:alt: Build status
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
Kubernetes Port-Forward Go-Edition For Python
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
* Free software: MIT license
|
|
53
|
-
* Documentation: https://portforward.readthedocs.io.
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
Installation
|
|
57
|
-
-----------------------------
|
|
58
|
-
|
|
59
|
-
Wheels are available for:
|
|
60
|
-
|
|
61
|
-
* Windows
|
|
62
|
-
* MacOS X
|
|
63
|
-
* Linux
|
|
64
|
-
|
|
65
|
-
with Python versions:
|
|
66
|
-
|
|
67
|
-
* 3.6
|
|
68
|
-
* 3.7
|
|
69
|
-
* 3.8
|
|
70
|
-
* 3.9
|
|
71
|
-
* 3.10
|
|
72
|
-
* 3.11
|
|
73
|
-
|
|
74
|
-
and architectures:
|
|
75
|
-
|
|
76
|
-
* x84_64
|
|
77
|
-
* arm64 (known as M1/Apple Chip - MacOS only)
|
|
78
|
-
|
|
79
|
-
**Requirements for installation from source**
|
|
80
|
-
|
|
81
|
-
The following things are required when there is no wheel available for the target system.
|
|
82
|
-
|
|
83
|
-
* `Go` installed and available in the path (at least v1.16 / https://go.dev)
|
|
84
|
-
* `Python` (at least v3.6 - below was never tested but might work)
|
|
85
|
-
* `gcc` (for Windows available via MinGW)
|
|
86
|
-
|
|
87
|
-
Pip knows how to install ``portforward``.
|
|
88
|
-
|
|
89
|
-
.. code-block::
|
|
90
|
-
|
|
91
|
-
pip install portforward
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
Quickstart
|
|
95
|
-
----------
|
|
96
|
-
|
|
97
|
-
.. code-block:: Python
|
|
98
|
-
|
|
99
|
-
import requests
|
|
100
|
-
|
|
101
|
-
import portforward
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
def main():
|
|
105
|
-
namespace = "test"
|
|
106
|
-
pod_name = "web" # You can also use a service name instead
|
|
107
|
-
local_port = 9000 # from port
|
|
108
|
-
pod_port = 80 # to port
|
|
109
|
-
|
|
110
|
-
# No path to kube config provided - will use default from $HOME/.kube/config
|
|
111
|
-
with portforward.forward(namespace, pod_name, local_port, pod_port):
|
|
112
|
-
response = requests.get("http://localhost:9000")
|
|
113
|
-
print(f"Done: \n'{response.status_code}'\n'{response.text[:20]}...'")
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
if __name__ == "__main__":
|
|
117
|
-
main()
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
Features
|
|
121
|
-
--------
|
|
122
|
-
|
|
123
|
-
* Go native Kubernetes port-forwarding with the ``.kube/config`` from the home dir
|
|
124
|
-
or any other path to config.
|
|
125
|
-
* Portforward for pods and services - the lib will first look for a pod with matching name then for
|
|
126
|
-
a service
|
|
127
|
-
* Waiting for a pod to become ready
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
Development
|
|
131
|
-
-----------
|
|
132
|
-
|
|
133
|
-
In case you want to develop on this library itself please take a look at the CONTRIBUTING page.
|
|
134
|
-
|
|
135
|
-
Credits
|
|
136
|
-
-------
|
|
137
|
-
|
|
138
|
-
This package was created with Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template.
|
|
139
|
-
|
|
140
|
-
.. _Cookiecutter: https://github.com/audreyr/cookiecutter
|
|
141
|
-
.. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage
|
|
142
|
-
|
|
143
|
-
This project is enabled by setuptools-golang_.
|
|
144
|
-
|
|
145
|
-
.. _setuptools-golang: https://github.com/asottile/setuptools-golang
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
=======
|
|
149
|
-
History
|
|
150
|
-
=======
|
|
151
|
-
|
|
152
|
-
0.5.0 (2023-05-19)
|
|
153
|
-
------------------
|
|
154
|
-
* Move pytogo Go code into portforward
|
|
155
|
-
* Fix stopping portforward for services
|
|
156
|
-
* Allow portforwarding without contextmanager
|
|
157
|
-
* Allow multiple portforwards to same pod or service
|
|
158
|
-
|
|
159
|
-
0.4.5 (2023-03-06)
|
|
160
|
-
------------------
|
|
161
|
-
* Fix panic when logging an error
|
|
162
|
-
* Change default log level to INFO
|
|
163
|
-
|
|
164
|
-
0.4.4 (2023-02-28)
|
|
165
|
-
------------------
|
|
166
|
-
* Fix endless waiting
|
|
167
|
-
|
|
168
|
-
0.4.3 (2023-02-27)
|
|
169
|
-
------------------
|
|
170
|
-
* Throw error instead of panic when port is in usage
|
|
171
|
-
|
|
172
|
-
0.4.2 (2023-02-06)
|
|
173
|
-
------------------
|
|
174
|
-
* Use in-cluster-config when no kube config file is available
|
|
175
|
-
|
|
176
|
-
0.4.1 (2023-02-01)
|
|
177
|
-
------------------
|
|
178
|
-
* Bump pytogo/portforward version
|
|
179
|
-
|
|
180
|
-
0.4.0 (2023-01-31)
|
|
181
|
-
------------------
|
|
182
|
-
* Respect environment variable KUBECONFIG
|
|
183
|
-
* Wait if a pod is not ready yet
|
|
184
|
-
* Be able to use service as targets
|
|
185
|
-
|
|
186
|
-
0.3.1 (2022-12-26)
|
|
187
|
-
------------------
|
|
188
|
-
* Allow selecting kubernetes target context
|
|
189
|
-
|
|
190
|
-
0.3.0 (2022-10-08)
|
|
191
|
-
------------------
|
|
192
|
-
* Introduction of logging level as replacement for verbose mode
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
0.2.8 (2022-08-22)
|
|
196
|
-
------------------
|
|
197
|
-
* Added verbose mode
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
0.2.7 (2021-10-05)
|
|
201
|
-
------------------
|
|
202
|
-
* Added missing import
|
|
203
|
-
* Added type hint
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
0.2.6 (2021-10-05)
|
|
207
|
-
------------------
|
|
208
|
-
* Fixed type hint
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
0.2.5 (2021-09-09)
|
|
212
|
-
------------------
|
|
213
|
-
* Moved the actual portforward to own module
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
0.2.4 (2021-08-23)
|
|
217
|
-
------------------
|
|
218
|
-
* Added adal import for Azure AD
|
|
219
|
-
* Fixed host IPs with paths
|
|
220
|
-
* Made timeout flexible
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
0.2.3 (2021-08-23)
|
|
224
|
-
------------------
|
|
225
|
-
* Fixed case when hostIP contains a path
|
|
226
|
-
* Added common and cloud provider auth plugins
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
0.2.2 (2021-08-23)
|
|
230
|
-
------------------
|
|
231
|
-
* Fixed missing module ``portforward``
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
0.2.1 (2021-08-19)
|
|
235
|
-
------------------
|
|
236
|
-
* Decrease binary size if pre-compile wheels
|
|
237
|
-
(Improvement of setuptools-golang)
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
0.2.0 (2021-08-14)
|
|
241
|
-
------------------
|
|
242
|
-
|
|
243
|
-
* First Release on PyPI.
|
|
244
|
-
* Made path to kube config variable.
|
|
245
|
-
* Port-forwarding became non-blocking.
|
|
246
|
-
* Fixed verification bug when port was None.
|
|
247
|
-
* Added throwing own error.
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
0.1.0 (2021-08-09)
|
|
251
|
-
------------------
|
|
252
|
-
|
|
253
|
-
* First release on Test PyPI.
|
|
254
|
-
* Blocking port-forward with fixed path for kube config.
|
|
255
|
-
|
|
256
|
-
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
_portforward.h,sha256=4uG6h21hHdx2siurKG4hWyrBPU8AwEzz81SJlawCvgc,2018
|
|
2
|
-
_portforward.pyd,sha256=BQ7BSZJLsv8n9Ep6oQa1S_QGzlEgZNxPahs0fM3FVu0,29423104
|
|
3
|
-
portforward.py,sha256=wElAKCXxpPUBQxfttPQTb0w7NXh2aDAq2cwh7Cb73V0,5479
|
|
4
|
-
portforward-0.5.0.dist-info/AUTHORS.rst,sha256=mskf9O-AvJL9NxWUYX0nJRuLfBw7SH-T-H-pPYLW-xI,176
|
|
5
|
-
portforward-0.5.0.dist-info/LICENSE,sha256=_-nf_xCZIwUkKBXXiYR-fjbXGhmx6V-7b3jSKoolnO4,1096
|
|
6
|
-
portforward-0.5.0.dist-info/METADATA,sha256=KDQqf0KbwfHhfwI3fFCYSATLW1pWM868Udc8hQyTIDY,5875
|
|
7
|
-
portforward-0.5.0.dist-info/WHEEL,sha256=W26pYN7HLsBT1jrDSL9udgf_mdNKJmYmL23sIP-FcgM,102
|
|
8
|
-
portforward-0.5.0.dist-info/top_level.txt,sha256=exoD3EZ-bCCtxQBQLSjSOZet0334F_dpAGxXr8XhWUA,25
|
|
9
|
-
portforward-0.5.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|