Merge pull request 'extraModules: soft deprecation for string extraModules' (#5656) from inline into main
Reviewed-on: https://git.clan.lol/clan/clan-core/pulls/5656
This commit is contained in:
@@ -859,7 +859,11 @@ in
|
|||||||
instanceRes.nixosModule
|
instanceRes.nixosModule
|
||||||
]
|
]
|
||||||
++ (map (
|
++ (map (
|
||||||
s: if builtins.typeOf s == "string" then "${directory}/${s}" else s
|
s:
|
||||||
|
if builtins.typeOf s == "string" then
|
||||||
|
lib.warn "String types for 'extraModules' will be deprecated - ${s}" "${directory}/${s}"
|
||||||
|
else
|
||||||
|
lib.setDefaultModuleLocation "via inventory.instances.${instanceName}.roles.${roleName}" s
|
||||||
) instanceCfg.roles.${roleName}.extraModules);
|
) instanceCfg.roles.${roleName}.extraModules);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,12 +44,6 @@ in
|
|||||||
description = ''
|
description = ''
|
||||||
List of additionally imported `.nix` expressions.
|
List of additionally imported `.nix` expressions.
|
||||||
|
|
||||||
Supported types:
|
|
||||||
|
|
||||||
- **Strings**: Interpreted relative to the 'directory' passed to `lib.clan`.
|
|
||||||
- **Paths**: should be relative to the current file.
|
|
||||||
- **Any**: Nix expression must be serializable to JSON.
|
|
||||||
|
|
||||||
!!! Note
|
!!! Note
|
||||||
**The import only happens if the machine is part of the service or role.**
|
**The import only happens if the machine is part of the service or role.**
|
||||||
|
|
||||||
@@ -74,7 +68,7 @@ in
|
|||||||
```
|
```
|
||||||
'';
|
'';
|
||||||
default = [ ];
|
default = [ ];
|
||||||
type = types.listOf types.deferredModule;
|
type = types.listOf types.raw;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -243,7 +243,11 @@ API.register(get_system_file)
|
|||||||
if "oneOf" not in return_type:
|
if "oneOf" not in return_type:
|
||||||
msg = (
|
msg = (
|
||||||
f"Return type of function '{name}' is not a union type. Expected a union of Success and Error types."
|
f"Return type of function '{name}' is not a union type. Expected a union of Success and Error types."
|
||||||
# @DavHau: no idea wy exactly this leads to the "oneOf" ot being present, but this should help
|
# If the SuccessData type is unsupported it was dropped by Union narrowing.
|
||||||
|
# This is probably an antifeature
|
||||||
|
# Introduced because run_generator wanted to use:
|
||||||
|
# Callable[[Generator], dict[str, str]]
|
||||||
|
# In its function signature.
|
||||||
"Hint: When using dataclasses as return types, ensure they don't contain public fields with non-serializable types"
|
"Hint: When using dataclasses as return types, ensure they don't contain public fields with non-serializable types"
|
||||||
)
|
)
|
||||||
raise JSchemaTypeError(msg)
|
raise JSchemaTypeError(msg)
|
||||||
|
|||||||
@@ -28,13 +28,11 @@ class InventoryInstanceRoleMachine(TypedDict):
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
InventoryInstanceRoleExtramodulesType = list[Unknown]
|
|
||||||
InventoryInstanceRoleMachinesType = dict[str, InventoryInstanceRoleMachine]
|
InventoryInstanceRoleMachinesType = dict[str, InventoryInstanceRoleMachine]
|
||||||
InventoryInstanceRoleSettingsType = Unknown
|
InventoryInstanceRoleSettingsType = Unknown
|
||||||
InventoryInstanceRoleTagsType = dict[str, Any] | list[str]
|
InventoryInstanceRoleTagsType = dict[str, Any] | list[str]
|
||||||
|
|
||||||
class InventoryInstanceRole(TypedDict):
|
class InventoryInstanceRole(TypedDict):
|
||||||
extraModules: NotRequired[InventoryInstanceRoleExtramodulesType]
|
|
||||||
machines: NotRequired[InventoryInstanceRoleMachinesType]
|
machines: NotRequired[InventoryInstanceRoleMachinesType]
|
||||||
settings: NotRequired[InventoryInstanceRoleSettingsType]
|
settings: NotRequired[InventoryInstanceRoleSettingsType]
|
||||||
tags: NotRequired[InventoryInstanceRoleTagsType]
|
tags: NotRequired[InventoryInstanceRoleTagsType]
|
||||||
|
|||||||
@@ -241,6 +241,11 @@ def generate_dataclass(
|
|||||||
# If we are at the top level, and the attribute name is not explicitly included we only do shallow
|
# If we are at the top level, and the attribute name is not explicitly included we only do shallow
|
||||||
field_name = prop.replace("-", "_")
|
field_name = prop.replace("-", "_")
|
||||||
|
|
||||||
|
# Skip "extraModules"
|
||||||
|
# TODO: Introduce seperate model that is tied to the serialization format
|
||||||
|
if "extraModules" in field_name:
|
||||||
|
continue
|
||||||
|
|
||||||
# if len(attr_path) == 0 and prop in shallow_attrs:
|
# if len(attr_path) == 0 and prop in shallow_attrs:
|
||||||
# field_def = field_name, "dict[str, Any]"
|
# field_def = field_name, "dict[str, Any]"
|
||||||
# fields_with_default.append(field_def)
|
# fields_with_default.append(field_def)
|
||||||
|
|||||||
Reference in New Issue
Block a user