Validate type-specific requirements.
Source code in core/engine/schema.py
| @validates_schema
def validate_upstream(self, data, **_kwargs):
"""Validate type-specific requirements."""
if data.get("type") == "github":
if not data.get("repo"):
raise ValidationError("'repo' is required for upstream type 'github'")
# Validate archive_name format if provided
archive_name = data.get("archive_name")
if archive_name is not None:
if isinstance(archive_name, dict):
# Dict format: must have keys for all architectures
if not archive_name:
raise ValidationError("archive_name dict cannot be empty")
# Validate that all values are strings
for arch, pattern in archive_name.items():
if not isinstance(pattern, str):
raise ValidationError(
f"archive_name[{arch}] must be a string, got {type(pattern)}"
)
elif not isinstance(archive_name, str):
raise ValidationError(
"archive_name must be either a string pattern or a dict mapping architectures to patterns"
)
elif data.get("type") == "local":
if not data.get("local_binary") and not data.get("local_archive"):
raise ValidationError(
"'local_binary' or 'local_archive' required for upstream type 'local'"
)
if data.get("local_binary") and data.get("local_archive"):
raise ValidationError(
"Only one of 'local_binary' or 'local_archive' allowed"
)
|