Skip to content

Commit

Permalink
Do not allow template generation for generics
Browse files Browse the repository at this point in the history
  • Loading branch information
gmazoyer committed Mar 4, 2025
1 parent 5ac76c1 commit 214095c
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ class Migration020(InternalSchemaMigration):
def init(cls, **kwargs: dict[str, Any]) -> Self:
internal_schema = cls.get_internal_schema()
schema_node = internal_schema.get_node(name="SchemaNode")
schema_generic = internal_schema.get_node(name="SchemaGeneric")

migrations = [
NodeAttributeAddMigration(
Expand All @@ -32,14 +31,7 @@ def init(cls, **kwargs: dict[str, Any]) -> Self:
schema_path=SchemaPath(
schema_kind="SchemaNode", path_type=SchemaPathType.ATTRIBUTE, field_name="generate_template"
),
),
NodeAttributeAddMigration(
new_node_schema=schema_generic,
previous_node_schema=schema_generic,
schema_path=SchemaPath(
schema_kind="SchemaNode", path_type=SchemaPathType.ATTRIBUTE, field_name="generate_template"
),
),
)
]
return cls(migrations=migrations, **kwargs) # type: ignore[arg-type]

Expand Down
8 changes: 0 additions & 8 deletions backend/infrahub/core/schema/definitions/internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -866,14 +866,6 @@ def to_dict(self) -> dict[str, Any]:
optional=True,
extra={"update": UpdateSupport.VALIDATE_CONSTRAINT},
),
SchemaAttribute(
name="generate_template",
kind="Boolean",
description="Indicate if an object template schema should be generated for this schema",
default_value=False,
optional=True,
extra={"update": UpdateSupport.ALLOWED},
),
SchemaAttribute(
name="used_by",
kind="List",
Expand Down
5 changes: 0 additions & 5 deletions backend/infrahub/core/schema/generated/genericnode_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ class GeneratedGenericSchema(BaseNodeSchema):
description="Indicate if a profile schema should be generated for this schema",
json_schema_extra={"update": "validate_constraint"},
)
generate_template: bool = Field(
default=False,
description="Indicate if an object template schema should be generated for this schema",
json_schema_extra={"update": "allowed"},
)
used_by: list[str] = Field(
default_factory=list,
description="List of Nodes that are referencing this Generic",
Expand Down
4 changes: 2 additions & 2 deletions backend/infrahub/core/schema/schema_branch.py
Original file line number Diff line number Diff line change
Expand Up @@ -1779,7 +1779,7 @@ def manage_object_template_relationships(self) -> None:
This relationship allows to record from which template an object has been created.
"""
for node_name in self.node_names + self.generic_names:
for node_name in self.node_names:
node = self.get(name=node_name, duplicate=False)

if (
Expand Down Expand Up @@ -1933,7 +1933,7 @@ def manage_object_template_schemas(self) -> None:
need_templates: set[NodeSchema | GenericSchema] = set()
template_schema_kinds: set[str] = set()

for node_name in self.node_names + self.generic_names:
for node_name in self.node_names:
node = self.get(name=node_name, duplicate=False)

# Delete old object templates if schemas were removed
Expand Down
12 changes: 0 additions & 12 deletions docs/docs/reference/schema/generic.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ Below is the list of all available options to define a Generic in the schema
| [**display_labels**](#display_labels) | Attribute | List of attributes to use to generate the display label | False |
| [**documentation**](#documentation) | Attribute | Link to a documentation associated with this object, can be internal or external. | False |
| [**generate_profile**](#generate_profile) | Attribute | Indicate if a profile schema should be generated for this schema | False |
| [**generate_template**](#generate_template) | Attribute | Indicate if an object template schema should be generated for this schema | False |
| [**hierarchical**](#hierarchical) | Attribute | Defines if the Generic support the hierarchical mode. | False |
| [**human_friendly_id**](#human_friendly_id) | Attribute | Human friendly and unique identifier for the object. | False |
| [**icon**](#icon) | Attribute | Defines the icon to use in the menu. Must be a valid value from the MDI library https://icon-sets.iconify.design/mdi/ | False |
Expand Down Expand Up @@ -105,17 +104,6 @@ Below is the list of all available options to define a Generic in the schema
| **Default Value** | True |
| **Constraints** | |

### generate_template

| Key | Value |
| ---- | --------------- |
| **Name** | generate_template |
| **Kind** | `Boolean` |
| **Description** | Indicate if an object template schema should be generated for this schema |
| **Optional** | True |
| **Default Value** | False |
| **Constraints** | |

### hierarchical

| Key | Value |
Expand Down
1 change: 0 additions & 1 deletion docs/docs/reference/schema/validator-migration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,5 @@ In this context, an element represent either a Node, a Generic, an Attribute or
| **documentation** | allowed |
| **hierarchical** | validate_constraint |
| **generate_profile** | validate_constraint |
| **generate_template** | allowed |


0 comments on commit 214095c

Please sign in to comment.