Merge pull request 'tests/generate_flake: support inventory argument' (#1798) from DavHau/clan-core:DavHau-vars into main
This commit is contained in:
@@ -56,6 +56,7 @@ def generate_flake(
|
|||||||
},
|
},
|
||||||
# define the machines directly including their config
|
# define the machines directly including their config
|
||||||
machine_configs: dict[str, dict] = {},
|
machine_configs: dict[str, dict] = {},
|
||||||
|
inventory: dict[str, dict] = {},
|
||||||
) -> FlakeForTest:
|
) -> FlakeForTest:
|
||||||
"""
|
"""
|
||||||
Creates a clan flake with the given name.
|
Creates a clan flake with the given name.
|
||||||
@@ -80,6 +81,12 @@ def generate_flake(
|
|||||||
shutil.copytree(flake_template, flake)
|
shutil.copytree(flake_template, flake)
|
||||||
sp.run(["chmod", "+w", "-R", str(flake)], check=True)
|
sp.run(["chmod", "+w", "-R", str(flake)], check=True)
|
||||||
|
|
||||||
|
# initialize inventory
|
||||||
|
if inventory:
|
||||||
|
# check if inventory valid
|
||||||
|
inventory_path = flake / "inventory.json"
|
||||||
|
inventory_path.write_text(json.dumps(inventory, indent=2))
|
||||||
|
|
||||||
# substitute `substitutions` in all files of the template
|
# substitute `substitutions` in all files of the template
|
||||||
for file in flake.rglob("*"):
|
for file in flake.rglob("*"):
|
||||||
if file.is_file():
|
if file.is_file():
|
||||||
|
|||||||
Reference in New Issue
Block a user