Skip to content

Commit

Permalink
skip profile schemas when checking for schema migrations (#5446)
Browse files Browse the repository at this point in the history
* skip profile schemas when checking for schema migrations

* remove dead code

* invert the conditional
  • Loading branch information
ajtmccarty authored Jan 14, 2025
1 parent dd1cc18 commit 42703f5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 15 deletions.
15 changes: 1 addition & 14 deletions backend/infrahub/core/validators/models/violation.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,4 @@
from typing import Union

from pydantic import BaseModel, Field

from infrahub.core.branch import Branch
from infrahub.core.path import SchemaPath
from infrahub.core.schema import GenericSchema, NodeSchema


class SchemaConstraintValidatorRequest(BaseModel):
branch: Branch = Field(..., description="The name of the branch to target")
constraint_name: str = Field(..., description="The name of the constraint to validate")
node_schema: Union[NodeSchema, GenericSchema] = Field(..., description="Schema of Node or Generic to validate")
schema_path: SchemaPath = Field(..., description="SchemaPath to the element of the schema to validate")
from pydantic import BaseModel


class SchemaViolation(BaseModel):
Expand Down
5 changes: 4 additions & 1 deletion backend/infrahub/core/validators/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,14 @@ async def schema_validate_migrations(message: SchemaValidateMigrationData) -> li
log.info(f"{len(message.constraints)} constraint(s) to validate")
# NOTE this task is a good candidate to add a progress bar
for constraint in message.constraints:
schema = message.schema_branch.get(name=constraint.path.schema_kind)
if not isinstance(schema, (GenericSchema, NodeSchema)):
continue
batch.add(
task=schema_path_validate,
branch=message.branch,
constraint_name=constraint.constraint_name,
node_schema=message.schema_branch.get(name=constraint.path.schema_kind),
node_schema=schema,
schema_path=constraint.path,
)

Expand Down

0 comments on commit 42703f5

Please sign in to comment.