Merge pull request 'pkgs/cli: Validate clan directory for update-hardware-config' (#4367) from kenji/ke-hardware-update-validation into main
Reviewed-on: https://git.clan.lol/clan/clan-core/pulls/4367
This commit is contained in:
@@ -2,6 +2,7 @@ import argparse
|
||||
import logging
|
||||
from pathlib import Path
|
||||
|
||||
from clan_lib.flake import require_flake
|
||||
from clan_lib.machines.hardware import (
|
||||
HardwareConfig,
|
||||
HardwareGenerateOptions,
|
||||
@@ -19,8 +20,9 @@ log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def update_hardware_config_command(args: argparse.Namespace) -> None:
|
||||
validate_machine_names([args.machine], args.flake)
|
||||
machine = Machine(flake=args.flake, name=args.machine)
|
||||
flake = require_flake(args.flake)
|
||||
validate_machine_names([args.machine], flake)
|
||||
machine = Machine(flake=flake, name=args.machine)
|
||||
opts = HardwareGenerateOptions(
|
||||
machine=machine,
|
||||
password=args.password,
|
||||
|
||||
15
pkgs/clan-cli/clan_cli/machines/hardware_test.py
Normal file
15
pkgs/clan-cli/clan_cli/machines/hardware_test.py
Normal file
@@ -0,0 +1,15 @@
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
from clan_lib.errors import ClanError
|
||||
|
||||
from clan_cli.tests.helpers import cli
|
||||
|
||||
|
||||
def test_create_command_no_flake(
|
||||
tmp_path: Path, monkeypatch: pytest.MonkeyPatch
|
||||
) -> None:
|
||||
monkeypatch.chdir(tmp_path)
|
||||
|
||||
with pytest.raises(ClanError):
|
||||
cli.run(["machines", "update-hardware-config", "machine"])
|
||||
Reference in New Issue
Block a user