Commit 88149e47 authored by Sergio Gimenez's avatar Sergio Gimenez
Browse files

fix: scope federated artefacts per federation context

parent fa824011
Loading
Loading
Loading
Loading
+15 −2
Original line number Diff line number Diff line
@@ -112,6 +112,16 @@ def _normalize_federated_app_provider_id(app_provider_id, fallback_source):
    )


def _normalize_federated_artefact_id(federation_context_id, artefact_id, fallback_source):
    if artefact_id and re.match(
        r"^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-"
        r"[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$",
        str(artefact_id),
    ):
        return str(uuid.uuid5(uuid.NAMESPACE_URL, f"{federation_context_id}:{artefact_id}"))
    return str(uuid.uuid5(uuid.NAMESPACE_URL, f"{federation_context_id}:{fallback_source}"))


def submit_app(body: dict):
    """
    Controller for submitting application metadata.
@@ -349,8 +359,11 @@ def create_app_instance():
            if component_specs and isinstance(component_specs, list):
                component_name = component_specs[0].get("componentName")
            component_name = component_name or app_name
            if not artefact_id:
                artefact_id = str(uuid.uuid5(uuid.NAMESPACE_URL, str(app_id)))
            artefact_id = _normalize_federated_artefact_id(
                zone.get("fedContextId"),
                artefact_id,
                app_id,
            )

            service_name_nb = _ensure_service_name(
                (component_specs[0].get("serviceNameNB") if component_specs else None),