def _pre_route(operation: Operation) -> Operation: """Called before any routing logic is applied""" # If no source garden is defined set it to the local garden if operation.source_garden_name is None: operation.source_garden_name = config.get("garden.name") if operation.operation_type == "REQUEST_CREATE": if operation.model.namespace is None: operation.model.namespace = config.get("garden.name") elif operation.operation_type == "SYSTEM_READ_ALL": if operation.kwargs.get("filter_params", {}).get("namespace") == "": operation.kwargs["filter_params"]["namespace"] = config.get( "garden.name") return operation
def _pre_route(operation: Operation) -> Operation: """Called before any routing logic is applied""" # If no source garden is defined set it to the local garden if operation.source_garden_name is None: operation.source_garden_name = config.get("garden.name") if operation.operation_type == "REQUEST_CREATE": if operation.model.namespace is None: operation.model.namespace = config.get("garden.name") elif operation.operation_type == "SYSTEM_READ_ALL": # what looks like a sensible edit is to change the next line to: # operation.kwargs.get("filter_params", {}).get("namespace", "") == "": # but that will break everything, as it turns out. So, unless # operation.kwargs has a key called filter_params whose value is a dictionary # that has a key called namespace and its value is an empty string, the follow- # ing never runs. Intuition says that's not what was intended here, so # TODO: look into this if operation.kwargs.get("filter_params", {}).get("namespace") == "": operation.kwargs["filter_params"]["namespace"] = config.get( "garden.name") return operation