def resolve_project_id()

in composer_local_dev/utils.py [0:0]


def resolve_project_id(project_id: Optional[str]) -> str:
    """
    Resolve optional ``project_id``. If ``project_id`` is None, retrieve its
    value from Google Cloud CLI.
    """
    if project_id is not None:
        return project_id
    LOG.info(
        "Project id was not provided. It will be retrieved using Cloud CLI."
    )
    try:
        return get_project_id()
    except errors.ComposerCliError as err:
        raise click.UsageError(
            f"Please provide Google Cloud project id "
            f"(using '-p' / '--project' option). Failed to retrieve "
            f"project id from gcloud configuration:\n{err}"
        )