Skip to content

Commit 25f509f

Browse files
authored
Test import (#81)
* fix imports * Prepare release nebius-vpngw-v0.5.3
1 parent 98b00a7 commit 25f509f

File tree

4 files changed

+178
-3
lines changed

4 files changed

+178
-3
lines changed

services/vpngw/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ All notable changes to this project are tracked here. This changelog follows
1414

1515
## [Unreleased]
1616

17+
## [nebius-vpngw-v0.5.3] - 2026-03-10
18+
19+
- Made the output path optional for `create-from-peer-config`; when omitted, the generated config now defaults to `./nebius-vpngw.config.yaml`.
20+
- Added `--local-config-file` as an output-file alias for `create-from-peer-config`, with fail-fast validation if it conflicts with the positional output path.
1721
## [nebius-vpngw-v0.5.2] - 2026-03-08
1822

1923
- Expanded the pytest-based test suite, split unit/integration coverage, centralized test config in `pyproject.toml`, and added `Makefile` targets plus service-scoped CI.

services/vpngw/README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,14 @@ nebius-vpngw create-from-peer-config my-vpn.config.yaml \
549549
--peer-config-file branch-office.csv
550550
```
551551
552+
Or use the output-path flag form:
553+
554+
```bash
555+
nebius-vpngw create-from-peer-config \
556+
--peer-config-file gcp-peer.txt \
557+
--local-config-file my-vpn.config.yaml
558+
```
559+
552560
If the generated output already matches the existing file, rerunning the command
553561
is a no-op and exits successfully.
554562
@@ -977,6 +985,9 @@ nebius-vpngw create-from-peer-config nebius-vpn.config.yaml \
977985
--peer-config-file gcp-peer.txt
978986
```
979987
988+
If you omit both `CONFIG_FILE` and `--local-config-file`, the command writes `./nebius-vpngw.config.yaml`.
989+
`--local-config-file` is accepted as an output-path alias on this command.
990+
980991
`create-from-peer-config` now builds `connections:` from parsed peer specs instead of reusing the template's fixed sample topology. The generated file is validated against the schema before it is written.
981992

982993
### Keyword Matching
@@ -1034,6 +1045,14 @@ nebius-vpngw create-from-peer-config gcp-ha-vpn.config.yaml \
10341045
--peer-config-file gcp-peer.txt
10351046
```
10361047

1048+
Equivalent flag form:
1049+
1050+
```bash
1051+
nebius-vpngw create-from-peer-config \
1052+
--peer-config-file gcp-peer.txt \
1053+
--local-config-file gcp-ha-vpn.config.yaml
1054+
```
1055+
10371056
**3. Generated BGP target shape (review and adjust values before deploy):**
10381057

10391058
```yaml

services/vpngw/src/nebius_vpngw/cli.py

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1350,8 +1350,21 @@ def prep_network(
13501350

13511351
@app.command(options_metavar="")
13521352
def create_from_peer_config(
1353-
config_file: Path = typer.Argument(
1354-
..., help="Path for new configuration file (recommended: *.config.yaml)"
1353+
config_file: Path | None = typer.Argument(
1354+
None,
1355+
help=(
1356+
"Path for new configuration file "
1357+
f"(default: ./{DEFAULT_CONFIG_FILENAME}; recommended: *.config.yaml)"
1358+
),
1359+
),
1360+
local_config_file: Path | None = typer.Option(
1361+
None,
1362+
"--local-config-file",
1363+
"-c",
1364+
help=(
1365+
"Output local config file path. "
1366+
"Alias for CONFIG_FILE on this command."
1367+
),
13551368
),
13561369
peer_config_file: list[Path] = typer.Option(
13571370
...,
@@ -1377,6 +1390,22 @@ def create_from_peer_config(
13771390

13781391
console = Console()
13791392

1393+
if config_file is not None and local_config_file is not None and config_file != local_config_file:
1394+
console.print()
1395+
console.print(
1396+
Panel.fit(
1397+
"[bold red]✗ Conflicting output file arguments[/bold red]\n\n"
1398+
f"CONFIG_FILE: [cyan]{config_file}[/cyan]\n"
1399+
f"--local-config-file: [cyan]{local_config_file}[/cyan]\n\n"
1400+
"Provide only one output path, or pass the same value to both.",
1401+
title="[red]Error[/red]",
1402+
border_style="red",
1403+
)
1404+
)
1405+
raise typer.Exit(code=1)
1406+
1407+
config_file = local_config_file or config_file or (Path.cwd() / DEFAULT_CONFIG_FILENAME)
1408+
13801409
if not peer_config_file:
13811410
console.print(
13821411
Panel.fit(

services/vpngw/tests/unit/test_peer_importer.py

Lines changed: 124 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import yaml
77
from typer.testing import CliRunner
88

9-
from nebius_vpngw.cli import app
9+
from nebius_vpngw.cli import DEFAULT_CONFIG_FILENAME, app
1010
from nebius_vpngw.config_loader import build_config_from_peer_files
1111
from nebius_vpngw.config_template import DEFAULT_CONFIG_TEMPLATE
1212
from nebius_vpngw.peer_parsers import parse_peer_source
@@ -150,3 +150,126 @@ def test_create_from_peer_config_generates_bgp_config_from_csv(tmp_path: Path) -
150150
"nebius-primary",
151151
"nebius-secondary",
152152
]
153+
154+
155+
def test_create_from_peer_config_defaults_output_path(tmp_path: Path, monkeypatch) -> None:
156+
peer_file = tmp_path / "gcp-peer.yaml"
157+
peer_file.write_text(
158+
yaml.safe_dump(
159+
{
160+
"name": "gcp-ha-vpn",
161+
"vendor": "gcp",
162+
"routing_mode": "bgp",
163+
"remote_asn": 65014,
164+
"tunnels": [
165+
{
166+
"name": "nebius-primary",
167+
"remote_public_ip": "34.157.15.187",
168+
"psk": "cli-psk-1",
169+
"inner_local_ip": "169.254.10.1",
170+
"inner_remote_ip": "169.254.10.2",
171+
}
172+
],
173+
},
174+
sort_keys=False,
175+
),
176+
encoding="utf-8",
177+
)
178+
monkeypatch.chdir(tmp_path)
179+
180+
result = CliRunner().invoke(
181+
app,
182+
[
183+
"create-from-peer-config",
184+
"--peer-config-file",
185+
str(peer_file),
186+
],
187+
)
188+
189+
assert result.exit_code == 0, result.stdout
190+
191+
output_file = tmp_path / DEFAULT_CONFIG_FILENAME
192+
generated = yaml.safe_load(output_file.read_text(encoding="utf-8"))
193+
assert len(generated["connections"]) == 1
194+
connection = generated["connections"][0]
195+
assert connection["name"] == "gcp-ha-vpn"
196+
assert connection["vendor"] == "gcp"
197+
assert connection["bgp"]["remote_asn"] == 65014
198+
199+
200+
def test_create_from_peer_config_accepts_local_config_file_alias(tmp_path: Path) -> None:
201+
peer_file = tmp_path / "gcp-peer.yaml"
202+
peer_file.write_text(
203+
yaml.safe_dump(
204+
{
205+
"name": "gcp-ha-vpn",
206+
"vendor": "gcp",
207+
"routing_mode": "bgp",
208+
"remote_asn": 65014,
209+
"tunnels": [
210+
{
211+
"name": "nebius-primary",
212+
"remote_public_ip": "34.157.15.187",
213+
"psk": "cli-psk-1",
214+
"inner_local_ip": "169.254.10.1",
215+
"inner_remote_ip": "169.254.10.2",
216+
}
217+
],
218+
},
219+
sort_keys=False,
220+
),
221+
encoding="utf-8",
222+
)
223+
output_file = tmp_path / "example.config.yaml"
224+
225+
result = CliRunner().invoke(
226+
app,
227+
[
228+
"create-from-peer-config",
229+
"--peer-config-file",
230+
str(peer_file),
231+
"--local-config-file",
232+
str(output_file),
233+
],
234+
)
235+
236+
assert result.exit_code == 0, result.stdout
237+
238+
generated = yaml.safe_load(output_file.read_text(encoding="utf-8"))
239+
assert len(generated["connections"]) == 1
240+
connection = generated["connections"][0]
241+
assert connection["name"] == "gcp-ha-vpn"
242+
assert connection["vendor"] == "gcp"
243+
assert connection["bgp"]["remote_asn"] == 65014
244+
245+
246+
def test_create_from_peer_config_rejects_conflicting_output_paths(tmp_path: Path) -> None:
247+
peer_file = tmp_path / "gcp-peer.yaml"
248+
peer_file.write_text(
249+
yaml.safe_dump(
250+
{
251+
"name": "gcp-ha-vpn",
252+
"vendor": "gcp",
253+
"tunnels": [{"remote_public_ip": "34.157.15.187"}],
254+
},
255+
sort_keys=False,
256+
),
257+
encoding="utf-8",
258+
)
259+
positional_output = tmp_path / "positional.config.yaml"
260+
option_output = tmp_path / "option.config.yaml"
261+
262+
result = CliRunner().invoke(
263+
app,
264+
[
265+
"create-from-peer-config",
266+
str(positional_output),
267+
"--peer-config-file",
268+
str(peer_file),
269+
"--local-config-file",
270+
str(option_output),
271+
],
272+
)
273+
274+
assert result.exit_code == 1, result.stdout
275+
assert "Conflicting output file arguments" in result.stdout

0 commit comments

Comments
 (0)