feat: skip bindings for platform sources
This commit is contained in:
@@ -175,6 +175,7 @@ def _available_sources(
|
|||||||
AvailableSource(
|
AvailableSource(
|
||||||
id=source.id,
|
id=source.id,
|
||||||
enabled=source.enabled,
|
enabled=source.enabled,
|
||||||
|
platform=source.policy.platform,
|
||||||
capabilities=capabilities,
|
capabilities=capabilities,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -96,6 +96,7 @@ class AvailableSource(BaseModel):
|
|||||||
|
|
||||||
id: str
|
id: str
|
||||||
enabled: bool = True
|
enabled: bool = True
|
||||||
|
platform: bool = False
|
||||||
capabilities: dict[str, AvailableCapability] = Field(default_factory=dict)
|
capabilities: dict[str, AvailableCapability] = Field(default_factory=dict)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -23,8 +23,15 @@ def validate_deployment_dependencies(
|
|||||||
diagnostics: list[DependencyDiagnostic] = []
|
diagnostics: list[DependencyDiagnostic] = []
|
||||||
|
|
||||||
for logical_ref, required in artifact.required_capability_map().items():
|
for logical_ref, required in artifact.required_capability_map().items():
|
||||||
|
platform_source = sources_by_id.get(required.logical_source)
|
||||||
|
if platform_source is not None and platform_source.platform:
|
||||||
|
bound_source_id = required.logical_source
|
||||||
|
else:
|
||||||
bound_source_id = bindings.get(required.logical_source)
|
bound_source_id = bindings.get(required.logical_source)
|
||||||
if bound_source_id is None:
|
if bound_source_id is None:
|
||||||
|
if not sources_by_id:
|
||||||
|
bound_source_id = required.logical_source
|
||||||
|
else:
|
||||||
diagnostics.append(
|
diagnostics.append(
|
||||||
_diagnostic(
|
_diagnostic(
|
||||||
code="binding_missing",
|
code="binding_missing",
|
||||||
|
|||||||
@@ -204,3 +204,52 @@ def test_validate_deployment_accepts_reducer_capability() -> None:
|
|||||||
)
|
)
|
||||||
|
|
||||||
assert diagnostics == []
|
assert diagnostics == []
|
||||||
|
|
||||||
|
|
||||||
|
def test_platform_source_requirement_does_not_need_binding() -> None:
|
||||||
|
artifact = artifact_with(
|
||||||
|
required_capability(logical_source="wf.std", capability_name="replace")
|
||||||
|
)
|
||||||
|
deployment = WorkflowDeployment(
|
||||||
|
id="demo.default",
|
||||||
|
artifact_id=artifact.id,
|
||||||
|
artifact_version=artifact.version,
|
||||||
|
bindings={},
|
||||||
|
)
|
||||||
|
|
||||||
|
diagnostics = validate_deployment_dependencies(
|
||||||
|
artifact=artifact,
|
||||||
|
deployment=deployment,
|
||||||
|
sources=[
|
||||||
|
AvailableSource(
|
||||||
|
id="wf.std",
|
||||||
|
platform=True,
|
||||||
|
capabilities={
|
||||||
|
"replace": AvailableCapability(name="replace", kind="node_spec")
|
||||||
|
},
|
||||||
|
)
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
assert diagnostics == []
|
||||||
|
|
||||||
|
|
||||||
|
def test_missing_platform_source_still_reports_source_missing() -> None:
|
||||||
|
artifact = artifact_with(
|
||||||
|
required_capability(logical_source="wf.std", capability_name="replace")
|
||||||
|
)
|
||||||
|
deployment = WorkflowDeployment(
|
||||||
|
id="demo.default",
|
||||||
|
artifact_id=artifact.id,
|
||||||
|
artifact_version=artifact.version,
|
||||||
|
bindings={},
|
||||||
|
)
|
||||||
|
|
||||||
|
diagnostics = validate_deployment_dependencies(
|
||||||
|
artifact=artifact,
|
||||||
|
deployment=deployment,
|
||||||
|
sources=[],
|
||||||
|
)
|
||||||
|
|
||||||
|
assert [diagnostic.code for diagnostic in diagnostics] == ["source_missing"]
|
||||||
|
assert diagnostics[0].bound_source == "wf.std"
|
||||||
|
|||||||
Reference in New Issue
Block a user