portforward 0.6.1__tar.gz → 0.6.2__tar.gz
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-0.6.2/.github/workflows/release.yml +120 -0
- {portforward-0.6.1 → portforward-0.6.2}/.readthedocs.yml +5 -1
- {portforward-0.6.1 → portforward-0.6.2}/Cargo.lock +1 -1
- {portforward-0.6.1 → portforward-0.6.2}/Cargo.toml +1 -1
- {portforward-0.6.1 → portforward-0.6.2}/HISTORY.rst +8 -0
- {portforward-0.6.1 → portforward-0.6.2}/Makefile +4 -4
- {portforward-0.6.1 → portforward-0.6.2}/PKG-INFO +6 -11
- {portforward-0.6.1 → portforward-0.6.2}/README.rst +4 -9
- {portforward-0.6.1 → portforward-0.6.2}/docs/modules.rst +1 -1
- {portforward-0.6.1 → portforward-0.6.2}/pyproject.toml +2 -2
- {portforward-0.6.1 → portforward-0.6.2}/python/portforward/__init__.py +26 -10
- {portforward-0.6.1 → portforward-0.6.2}/python/portforward/_portforward.pyi +1 -1
- {portforward-0.6.1 → portforward-0.6.2}/src/lib.rs +2 -2
- {portforward-0.6.1 → portforward-0.6.2}/src/portforward.rs +4 -3
- {portforward-0.6.1 → portforward-0.6.2}/tests/test_portforward.py +13 -1
- {portforward-0.6.1 → portforward-0.6.2}/.editorconfig +0 -0
- {portforward-0.6.1 → portforward-0.6.2}/.github/ISSUE_TEMPLATE.md +0 -0
- {portforward-0.6.1 → portforward-0.6.2}/.github/workflows/python-app.yml +0 -0
- {portforward-0.6.1 → portforward-0.6.2}/.gitignore +0 -0
- {portforward-0.6.1 → portforward-0.6.2}/AUTHORS.rst +0 -0
- {portforward-0.6.1 → portforward-0.6.2}/CONTRIBUTING.rst +0 -0
- {portforward-0.6.1 → portforward-0.6.2}/LICENSE +0 -0
- {portforward-0.6.1 → portforward-0.6.2}/docs/Makefile +0 -0
- {portforward-0.6.1 → portforward-0.6.2}/docs/authors.rst +0 -0
- {portforward-0.6.1 → portforward-0.6.2}/docs/conf.py +0 -0
- {portforward-0.6.1 → portforward-0.6.2}/docs/contributing.rst +0 -0
- {portforward-0.6.1 → portforward-0.6.2}/docs/docs/conf.rst +0 -0
- {portforward-0.6.1 → portforward-0.6.2}/docs/docs/modules.rst +0 -0
- {portforward-0.6.1 → portforward-0.6.2}/docs/history.rst +0 -0
- {portforward-0.6.1 → portforward-0.6.2}/docs/index.rst +0 -0
- {portforward-0.6.1 → portforward-0.6.2}/docs/installation.rst +0 -0
- {portforward-0.6.1 → portforward-0.6.2}/docs/make.bat +0 -0
- {portforward-0.6.1 → portforward-0.6.2}/docs/portforward.rst +0 -0
- {portforward-0.6.1 → portforward-0.6.2}/python/portforward/py.typed +0 -0
- {portforward-0.6.1 → portforward-0.6.2}/requirements-dev.txt +0 -0
- {portforward-0.6.1 → portforward-0.6.2}/tests/conftest.py +0 -0
- {portforward-0.6.1 → portforward-0.6.2}/tests/resources.yaml +0 -0
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# This file is autogenerated by maturin v0.14.17
|
|
2
|
+
# To update, run
|
|
3
|
+
#
|
|
4
|
+
# maturin generate-ci github
|
|
5
|
+
#
|
|
6
|
+
name: Release
|
|
7
|
+
|
|
8
|
+
on:
|
|
9
|
+
push:
|
|
10
|
+
tags:
|
|
11
|
+
- 'v*'
|
|
12
|
+
# pull_request:
|
|
13
|
+
workflow_dispatch:
|
|
14
|
+
|
|
15
|
+
permissions:
|
|
16
|
+
contents: read
|
|
17
|
+
|
|
18
|
+
jobs:
|
|
19
|
+
linux:
|
|
20
|
+
runs-on: ubuntu-latest
|
|
21
|
+
strategy:
|
|
22
|
+
matrix:
|
|
23
|
+
target: [x86_64, x86, aarch64]
|
|
24
|
+
version: [ "3.8", "3.9", "3.10", "3.11", "3.12" ]
|
|
25
|
+
steps:
|
|
26
|
+
- uses: actions/checkout@v3
|
|
27
|
+
- uses: actions/setup-python@v4
|
|
28
|
+
with:
|
|
29
|
+
python-version: ${{ matrix.version }}
|
|
30
|
+
- name: Build wheels
|
|
31
|
+
uses: PyO3/maturin-action@v1
|
|
32
|
+
with:
|
|
33
|
+
target: ${{ matrix.target }}
|
|
34
|
+
args: --release --out dist --find-interpreter
|
|
35
|
+
sccache: 'true'
|
|
36
|
+
manylinux: auto
|
|
37
|
+
- name: Upload wheels
|
|
38
|
+
uses: actions/upload-artifact@v3
|
|
39
|
+
with:
|
|
40
|
+
name: wheels
|
|
41
|
+
path: dist
|
|
42
|
+
|
|
43
|
+
windows:
|
|
44
|
+
runs-on: windows-latest
|
|
45
|
+
strategy:
|
|
46
|
+
matrix:
|
|
47
|
+
target: [x64, x86]
|
|
48
|
+
version: [ "3.8", "3.9", "3.10", "3.11", "3.12" ]
|
|
49
|
+
steps:
|
|
50
|
+
- uses: actions/checkout@v3
|
|
51
|
+
- uses: actions/setup-python@v4
|
|
52
|
+
with:
|
|
53
|
+
python-version: ${{ matrix.version }}
|
|
54
|
+
architecture: ${{ matrix.target }}
|
|
55
|
+
- name: Build wheels
|
|
56
|
+
uses: PyO3/maturin-action@v1
|
|
57
|
+
with:
|
|
58
|
+
target: ${{ matrix.target }}
|
|
59
|
+
args: --release --out dist --find-interpreter
|
|
60
|
+
sccache: 'true'
|
|
61
|
+
- name: Upload wheels
|
|
62
|
+
uses: actions/upload-artifact@v3
|
|
63
|
+
with:
|
|
64
|
+
name: wheels
|
|
65
|
+
path: dist
|
|
66
|
+
|
|
67
|
+
macos:
|
|
68
|
+
runs-on: macos-latest
|
|
69
|
+
strategy:
|
|
70
|
+
matrix:
|
|
71
|
+
target: [x86_64, aarch64]
|
|
72
|
+
version: [ "3.8", "3.9", "3.10", "3.11", "3.12" ]
|
|
73
|
+
steps:
|
|
74
|
+
- uses: actions/checkout@v3
|
|
75
|
+
- uses: actions/setup-python@v4
|
|
76
|
+
with:
|
|
77
|
+
python-version: ${{ matrix.version }}
|
|
78
|
+
- name: Build wheels
|
|
79
|
+
uses: PyO3/maturin-action@v1
|
|
80
|
+
with:
|
|
81
|
+
target: ${{ matrix.target }}
|
|
82
|
+
args: --release --out dist --find-interpreter
|
|
83
|
+
sccache: 'true'
|
|
84
|
+
- name: Upload wheels
|
|
85
|
+
uses: actions/upload-artifact@v3
|
|
86
|
+
with:
|
|
87
|
+
name: wheels
|
|
88
|
+
path: dist
|
|
89
|
+
|
|
90
|
+
sdist:
|
|
91
|
+
runs-on: ubuntu-latest
|
|
92
|
+
steps:
|
|
93
|
+
- uses: actions/checkout@v3
|
|
94
|
+
- name: Build sdist
|
|
95
|
+
uses: PyO3/maturin-action@v1
|
|
96
|
+
with:
|
|
97
|
+
command: sdist
|
|
98
|
+
args: --out dist
|
|
99
|
+
- name: Upload sdist
|
|
100
|
+
uses: actions/upload-artifact@v3
|
|
101
|
+
with:
|
|
102
|
+
name: wheels
|
|
103
|
+
path: dist
|
|
104
|
+
|
|
105
|
+
release:
|
|
106
|
+
name: Release
|
|
107
|
+
runs-on: ubuntu-latest
|
|
108
|
+
if: "startsWith(github.ref, 'refs/tags/')"
|
|
109
|
+
needs: [linux, windows, macos, sdist]
|
|
110
|
+
steps:
|
|
111
|
+
- uses: actions/download-artifact@v3
|
|
112
|
+
with:
|
|
113
|
+
name: wheels
|
|
114
|
+
- name: Publish to PyPI
|
|
115
|
+
uses: PyO3/maturin-action@v1
|
|
116
|
+
env:
|
|
117
|
+
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
|
|
118
|
+
with:
|
|
119
|
+
command: upload
|
|
120
|
+
args: --skip-existing *
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
version: 2
|
|
2
2
|
|
|
3
|
+
build:
|
|
4
|
+
os: "ubuntu-22.04"
|
|
5
|
+
tools:
|
|
6
|
+
python: "3.10"
|
|
7
|
+
|
|
3
8
|
# Build documentation in the docs/ directory with Sphinx
|
|
4
9
|
sphinx:
|
|
5
10
|
configuration: docs/conf.py
|
|
@@ -10,6 +15,5 @@ formats:
|
|
|
10
15
|
|
|
11
16
|
# Optionally set the version of Python and requirements required to build your docs
|
|
12
17
|
python:
|
|
13
|
-
version: "3.8"
|
|
14
18
|
install:
|
|
15
19
|
- requirements: requirements-dev.txt
|
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
History
|
|
3
3
|
=======
|
|
4
4
|
|
|
5
|
+
0.6.2 (2024-06-19)
|
|
6
|
+
------------------
|
|
7
|
+
* Allow defining binding ip
|
|
8
|
+
|
|
9
|
+
0.6.1 (2024-01-25)
|
|
10
|
+
------------------
|
|
11
|
+
* Fixed wrong logger setup
|
|
12
|
+
|
|
5
13
|
0.6.0 (2023-06-13)
|
|
6
14
|
------------------
|
|
7
15
|
* Rewrite native part in Rust with support of Py03 and maturin
|
|
@@ -66,36 +66,36 @@ servedocs: docs ## compile the docs watching for changes
|
|
|
66
66
|
|
|
67
67
|
release-linux: clean ## creates and release linux wheels
|
|
68
68
|
mkdir -p dist
|
|
69
|
-
docker run --rm -v $(PWD):/io ghcr.io/pyo3/maturin build --release -i python3.7 --out dist --strip
|
|
70
69
|
docker run --rm -v $(PWD):/io ghcr.io/pyo3/maturin build --release -i python3.8 --out dist --strip
|
|
71
70
|
docker run --rm -v $(PWD):/io ghcr.io/pyo3/maturin build --release -i python3.9 --out dist --strip
|
|
72
71
|
docker run --rm -v $(PWD):/io ghcr.io/pyo3/maturin build --release -i python3.10 --out dist --strip
|
|
73
72
|
docker run --rm -v $(PWD):/io ghcr.io/pyo3/maturin build --release -i python3.11 --out dist --strip
|
|
73
|
+
docker run --rm -v $(PWD):/io ghcr.io/pyo3/maturin build --release -i python3.12 --out dist --strip
|
|
74
74
|
|
|
75
75
|
maturin sdist --out dist
|
|
76
76
|
|
|
77
77
|
twine upload dist/*
|
|
78
78
|
|
|
79
79
|
release-macos: clean ## creates and release macos wheels
|
|
80
|
-
maturin build --release --target aarch64-apple-darwin --zig -i python3.7 --out dist --strip
|
|
81
80
|
maturin build --release --target aarch64-apple-darwin --zig -i python3.8 --out dist --strip
|
|
82
81
|
maturin build --release --target aarch64-apple-darwin --zig -i python3.9 --out dist --strip
|
|
83
82
|
maturin build --release --target aarch64-apple-darwin --zig -i python3.10 --out dist --strip
|
|
84
83
|
maturin build --release --target aarch64-apple-darwin --zig -i python3.11 --out dist --strip
|
|
84
|
+
maturin build --release --target aarch64-apple-darwin --zig -i python3.12 --out dist --strip
|
|
85
85
|
|
|
86
|
-
maturin build --release -i python3.7 --out dist --strip
|
|
87
86
|
maturin build --release -i python3.8 --out dist --strip
|
|
88
87
|
maturin build --release -i python3.9 --out dist --strip
|
|
89
88
|
maturin build --release -i python3.10 --out dist --strip
|
|
90
89
|
maturin build --release -i python3.11 --out dist --strip
|
|
90
|
+
maturin build --release -i python3.12 --out dist --strip
|
|
91
91
|
|
|
92
92
|
twine upload dist/*
|
|
93
93
|
|
|
94
94
|
release-windows: clean ## creates and release window wheels
|
|
95
|
-
maturin build --release -i python37 --out dist --strip
|
|
96
95
|
maturin build --release -i python38 --out dist --strip
|
|
97
96
|
maturin build --release -i python39 --out dist --strip
|
|
98
97
|
maturin build --release -i python310 --out dist --strip
|
|
99
98
|
maturin build --release -i python311 --out dist --strip
|
|
99
|
+
maturin build --release -i python312 --out dist --strip
|
|
100
100
|
|
|
101
101
|
twine upload dist/*
|
|
@@ -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: Documentation, https://portforward.readthedocs.io
|
|
22
21
|
Project-URL: Repository, https://github.com/pytogo/portforward.git
|
|
23
22
|
Project-URL: Changelog, https://github.com/pytogo/portforward/blob/main/HISTORY.rst
|
|
23
|
+
Project-URL: Documentation, https://portforward.readthedocs.io
|
|
24
24
|
|
|
25
25
|
===========
|
|
26
26
|
portforward
|
|
@@ -58,22 +58,17 @@ 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
|
|
|
67
|
-
* 3.7
|
|
68
67
|
* 3.8
|
|
69
68
|
* 3.9
|
|
70
69
|
* 3.10
|
|
71
70
|
* 3.11
|
|
72
|
-
|
|
73
|
-
and architectures:
|
|
74
|
-
|
|
75
|
-
* x84_64
|
|
76
|
-
* arm64 (known as M1/Apple Chip - MacOS only)
|
|
71
|
+
* 3.12
|
|
77
72
|
|
|
78
73
|
**Requirements for installation from source**
|
|
79
74
|
|
|
@@ -34,22 +34,17 @@ Installation
|
|
|
34
34
|
|
|
35
35
|
Wheels are available for:
|
|
36
36
|
|
|
37
|
-
* Windows
|
|
38
|
-
* MacOS X
|
|
39
|
-
* Linux
|
|
37
|
+
* Windows (architectures: x64, x86)
|
|
38
|
+
* MacOS X (architectures: x86_64, aarch64)
|
|
39
|
+
* Linux (architectures: x86_64, x86, aarch64)
|
|
40
40
|
|
|
41
41
|
with Python versions:
|
|
42
42
|
|
|
43
|
-
* 3.7
|
|
44
43
|
* 3.8
|
|
45
44
|
* 3.9
|
|
46
45
|
* 3.10
|
|
47
46
|
* 3.11
|
|
48
|
-
|
|
49
|
-
and architectures:
|
|
50
|
-
|
|
51
|
-
* x84_64
|
|
52
|
-
* arm64 (known as M1/Apple Chip - MacOS only)
|
|
47
|
+
* 3.12
|
|
53
48
|
|
|
54
49
|
**Requirements for installation from source**
|
|
55
50
|
|
|
@@ -4,7 +4,7 @@ build-backend = "maturin"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "portforward"
|
|
7
|
-
version = "0.6.
|
|
7
|
+
version = "0.6.2"
|
|
8
8
|
authors = [{ name = "Sebastian Ziemann", email = "corka149@mailbox.org" }]
|
|
9
9
|
description = "Easy Kubernetes Port-Forward For Python"
|
|
10
10
|
readme = "README.rst"
|
|
@@ -34,7 +34,7 @@ module-name = "portforward._portforward"
|
|
|
34
34
|
python-source = "python"
|
|
35
35
|
|
|
36
36
|
[tool.bumpversion]
|
|
37
|
-
current_version = "0.6.
|
|
37
|
+
current_version = "0.6.2"
|
|
38
38
|
tag = true
|
|
39
39
|
commit = true
|
|
40
40
|
|
|
@@ -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
|
|
@@ -52,12 +54,6 @@ def forward(
|
|
|
52
54
|
>>> import portforward
|
|
53
55
|
>>> with portforward.forward("test", "web-svc", 9000, 80):
|
|
54
56
|
>>> # Do work
|
|
55
|
-
>>>
|
|
56
|
-
>>> # Or without context manager
|
|
57
|
-
>>>
|
|
58
|
-
>>> forwarder = portforward.forward("test", "some-pod", 9000, 80)
|
|
59
|
-
>>> # Do work
|
|
60
|
-
>>> forwarder.stop()
|
|
61
57
|
|
|
62
58
|
:param namespace: Target namespace
|
|
63
59
|
:param pod_or_service: Name of target Pod or service
|
|
@@ -67,6 +63,7 @@ def forward(
|
|
|
67
63
|
:param waiting: Delay in seconds
|
|
68
64
|
:param log_level: Level of logging
|
|
69
65
|
:param kube_context: Target kubernetes context (fallback is current context)
|
|
66
|
+
:param bind_ip: To which IP shall the portforward be bind
|
|
70
67
|
:return: forwarder to manual stop the forwarding
|
|
71
68
|
"""
|
|
72
69
|
|
|
@@ -79,6 +76,7 @@ def forward(
|
|
|
79
76
|
waiting,
|
|
80
77
|
log_level,
|
|
81
78
|
kube_context,
|
|
79
|
+
bind_ip,
|
|
82
80
|
)
|
|
83
81
|
|
|
84
82
|
try:
|
|
@@ -107,6 +105,7 @@ class PortForwarder:
|
|
|
107
105
|
waiting: float = 0.1,
|
|
108
106
|
log_level: LogLevel = LogLevel.INFO,
|
|
109
107
|
kube_context: str = "",
|
|
108
|
+
bind_ip: Union[ipaddress.IPv4Address, ipaddress.IPv6Address, str, None] = None,
|
|
110
109
|
) -> None:
|
|
111
110
|
self._async_forwarder = AsyncPortForwarder(
|
|
112
111
|
namespace,
|
|
@@ -117,6 +116,7 @@ class PortForwarder:
|
|
|
117
116
|
waiting,
|
|
118
117
|
log_level,
|
|
119
118
|
kube_context,
|
|
119
|
+
bind_ip,
|
|
120
120
|
)
|
|
121
121
|
|
|
122
122
|
def forward(self):
|
|
@@ -143,10 +143,10 @@ class AsyncPortForwarder:
|
|
|
143
143
|
waiting: float = 0.1,
|
|
144
144
|
log_level: LogLevel = LogLevel.INFO,
|
|
145
145
|
kube_context: str = "",
|
|
146
|
+
bind_ip: Union[ipaddress.IPv4Address, ipaddress.IPv6Address, str, None] = None,
|
|
146
147
|
) -> None:
|
|
147
148
|
self.namespace: str = _validate_str("namespace", namespace)
|
|
148
149
|
self.pod_or_service: str = _validate_str("pod_or_service", pod_or_service)
|
|
149
|
-
self.from_port: int = _validate_port("from_port", from_port)
|
|
150
150
|
self.to_port: int = _validate_port("to_port", to_port)
|
|
151
151
|
self.log_level: LogLevel = _validate_log(log_level)
|
|
152
152
|
self.waiting: float = waiting
|
|
@@ -154,14 +154,18 @@ class AsyncPortForwarder:
|
|
|
154
154
|
self.config_path: str = _config_path(config_path)
|
|
155
155
|
self.kube_context: str = _kube_context(kube_context)
|
|
156
156
|
|
|
157
|
+
_validate_port("from_port", from_port)
|
|
158
|
+
bind_ip = _validate_ip_address(bind_ip)
|
|
159
|
+
|
|
157
160
|
self.actual_pod_name: str = ""
|
|
158
161
|
self._is_stopped: bool = False
|
|
162
|
+
self.bind_address: str = f"{bind_ip}:{from_port}"
|
|
159
163
|
|
|
160
164
|
async def forward(self):
|
|
161
165
|
self.actual_pod_name = await _portforward.forward(
|
|
162
166
|
self.namespace,
|
|
163
167
|
self.pod_or_service,
|
|
164
|
-
self.
|
|
168
|
+
self.bind_address,
|
|
165
169
|
self.to_port,
|
|
166
170
|
self.config_path,
|
|
167
171
|
self.log_level.value,
|
|
@@ -210,6 +214,18 @@ def _validate_log(log_level):
|
|
|
210
214
|
return log_level
|
|
211
215
|
|
|
212
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
|
+
|
|
213
229
|
def _config_path(config_path_arg) -> str:
|
|
214
230
|
if config_path_arg and not isinstance(config_path_arg, str):
|
|
215
231
|
raise ValueError(f"config_path={config_path_arg} is not a valid str")
|
|
@@ -9,7 +9,7 @@ fn forward(
|
|
|
9
9
|
py: Python<'_>,
|
|
10
10
|
namespace: String,
|
|
11
11
|
pod_or_service: String,
|
|
12
|
-
|
|
12
|
+
bind_address: String,
|
|
13
13
|
to_port: u16,
|
|
14
14
|
config_path: String,
|
|
15
15
|
log_level: u64,
|
|
@@ -20,7 +20,7 @@ fn forward(
|
|
|
20
20
|
let config = portforward::ForwardConfig::builder()
|
|
21
21
|
.namespace(namespace)
|
|
22
22
|
.pod_or_service(pod_or_service)
|
|
23
|
-
.
|
|
23
|
+
.bind_address(bind_address)
|
|
24
24
|
.to_port(to_port)
|
|
25
25
|
.config_path(config_path)
|
|
26
26
|
.kube_context(kube_context)
|
|
@@ -14,6 +14,7 @@ use log::*;
|
|
|
14
14
|
use once_cell::sync::Lazy;
|
|
15
15
|
use std::net::SocketAddr;
|
|
16
16
|
use std::{collections::HashMap, path::Path};
|
|
17
|
+
use std::str::FromStr;
|
|
17
18
|
use tokio::{
|
|
18
19
|
io::{AsyncRead, AsyncWrite},
|
|
19
20
|
net::TcpListener,
|
|
@@ -27,7 +28,7 @@ use typed_builder::TypedBuilder;
|
|
|
27
28
|
pub struct ForwardConfig {
|
|
28
29
|
namespace: String,
|
|
29
30
|
pod_or_service: String,
|
|
30
|
-
|
|
31
|
+
bind_address: String,
|
|
31
32
|
to_port: u16,
|
|
32
33
|
config_path: String,
|
|
33
34
|
kube_context: String,
|
|
@@ -55,7 +56,7 @@ pub async fn forward(config: ForwardConfig) -> anyhow::Result<String> {
|
|
|
55
56
|
|
|
56
57
|
PORTFORWARD_REGISTRY.register(&q_name, forwarding).await;
|
|
57
58
|
|
|
58
|
-
let addr = SocketAddr::
|
|
59
|
+
let addr = SocketAddr::from_str(&config.bind_address).with_context(move || config.bind_address)?;
|
|
59
60
|
let tcp_listener = TcpListener::bind(addr).await?;
|
|
60
61
|
let forward_task = setup_forward_task(
|
|
61
62
|
tcp_listener,
|
|
@@ -80,7 +81,7 @@ async fn load_config(
|
|
|
80
81
|
return Ok(incluster_config);
|
|
81
82
|
}
|
|
82
83
|
|
|
83
|
-
let kube_config = kube::config::Kubeconfig::read_from(config_path
|
|
84
|
+
let kube_config = kube::config::Kubeconfig::read_from(config_path)?;
|
|
84
85
|
let mut options = kube::config::KubeConfigOptions::default();
|
|
85
86
|
|
|
86
87
|
// "" is the sign for using default context
|
|
@@ -160,11 +160,23 @@ def test_forward_invalid_parameter(namespace, pod, from_port, to_port):
|
|
|
160
160
|
pytest.fail("Should raise error before")
|
|
161
161
|
|
|
162
162
|
|
|
163
|
+
def test_validate_ip_address():
|
|
164
|
+
namespace = "test_ns"
|
|
165
|
+
pod = "test_pod"
|
|
166
|
+
from_port = 9000
|
|
167
|
+
to_port = 10000
|
|
168
|
+
bind_ip = "not-an-ip-adress"
|
|
169
|
+
|
|
170
|
+
with pytest.raises(ValueError):
|
|
171
|
+
with portforward.forward(namespace, pod, from_port, to_port, bind_ip=bind_ip):
|
|
172
|
+
pytest.fail("Should raise error before")
|
|
173
|
+
|
|
174
|
+
|
|
163
175
|
def test_forward_raise_error():
|
|
164
176
|
"""Tests the conversion of the C extension error into the Python Error"""
|
|
165
177
|
|
|
166
178
|
# Arrange
|
|
167
|
-
namespace = "test" + str(uuid.uuid4()) # Should never
|
|
179
|
+
namespace = "test" + str(uuid.uuid4()) # Should never exist
|
|
168
180
|
pod = "web"
|
|
169
181
|
from_ = 9000
|
|
170
182
|
to = 80
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|