def METHOD_NAME(task: dsl.ContainerOp, resource_name: str,
                            default_request: Optional[str],
                            default_limit: Optional[str]):
    if task.container.get_resource_limit(resource_name):
        # Do nothing.
        # Limit is set, request will default to limit if not set (Kubernetes default behavior),
        # so we do not need to further apply defaults.
        return
    if default_limit:
        task.container.add_resource_limit(resource_name, default_limit)
    if default_request:
        if not task.container.get_resource_request(resource_name):
            task.container.add_resource_request(resource_name, default_request)