mirror of
https://github.com/kubevirt/kubevirt.core.git
synced 2026-07-29 10:54:35 +00:00
Merge pull request #235 from carterpewpew/fix/set-composable-vars-ignores-strict-fal
fix: pass user-configured `strict` option to `_set_composite_vars` in kubevirt inventory plugin
This commit is contained in:
@@ -920,7 +920,7 @@ class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable):
|
|||||||
trust_compose_groups(self.get_option("compose")),
|
trust_compose_groups(self.get_option("compose")),
|
||||||
hostvars,
|
hostvars,
|
||||||
hostname,
|
hostname,
|
||||||
strict=True,
|
strict=strict,
|
||||||
)
|
)
|
||||||
self._add_host_to_composed_groups(
|
self._add_host_to_composed_groups(
|
||||||
trust_compose_groups(self.get_option("groups")),
|
trust_compose_groups(self.get_option("groups")),
|
||||||
|
|||||||
@@ -61,3 +61,30 @@ def test_set_composable_vars(
|
|||||||
assert host in groups["block_migratable_vmis"]["children"]
|
assert host in groups["block_migratable_vmis"]["children"]
|
||||||
assert "fedora_40" in groups
|
assert "fedora_40" in groups
|
||||||
assert host in groups["fedora_40"]["children"]
|
assert host in groups["fedora_40"]["children"]
|
||||||
|
|
||||||
|
|
||||||
|
def test_set_composable_vars_strict_false_ignores_compose_errors(
|
||||||
|
inventory,
|
||||||
|
groups,
|
||||||
|
hosts,
|
||||||
|
):
|
||||||
|
inventory._options = {
|
||||||
|
"compose": {"custom_label": "vmi_nonexistent_label"},
|
||||||
|
"groups": {},
|
||||||
|
"keyed_groups": [],
|
||||||
|
"strict": False,
|
||||||
|
}
|
||||||
|
inventory._populate_inventory(
|
||||||
|
{
|
||||||
|
"default_hostname": "test",
|
||||||
|
"cluster_domain": "test.com",
|
||||||
|
"namespaces": {
|
||||||
|
"default": {"vms": [], "vmis": [VMI], "services": {}},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
InventoryOptions(),
|
||||||
|
)
|
||||||
|
|
||||||
|
host = f"{DEFAULT_NAMESPACE}-testvmi"
|
||||||
|
assert host in hosts
|
||||||
|
assert "custom_label" not in hosts[host]
|
||||||
|
|||||||
Reference in New Issue
Block a user