refactor: reduce coupling to Machine class in vars module

- Change Generator class to store machine name as string instead of Machine reference
- Update Generator.generators_from_flake() to only require machine name and flake
- Refactor check_vars() to accept machine name and flake instead of Machine object
- Create Machine instances only when needed for specific operations

This continues the effort to reduce dependencies on the Machine class,
making the codebase more modular and easier to refactor.
This commit is contained in:
DavHau
2025-07-05 15:54:37 +07:00
parent 448e60f866
commit d143359a2d
9 changed files with 50 additions and 61 deletions

View File

@@ -11,7 +11,7 @@ log = logging.getLogger(__name__)
def fix_vars(machine: Machine, generator_name: None | str = None) -> None:
from clan_cli.vars.generate import Generator
generators = Generator.generators_from_flake(machine.name, machine.flake, machine)
generators = Generator.generators_from_flake(machine.name, machine.flake)
if generator_name:
for generator in generators:
if generator_name == generator.name: