def deploy_app()

in appengine/integration_tests/testsuite/deploy_app.py [0:0]


def deploy_app(appdir, environment, base_image=None,
               builder_image=None, yaml=None):
    try:
        if yaml:
            # convert yaml to absolute path before changing directory
            yaml = os.path.abspath(yaml)

        # change to app directory (and remember original directory)
        owd = os.getcwd()
        os.chdir(appdir)

        # fills in image field in templated Dockerfile and/or builder yaml
        if base_image:
            _set_base_image(base_image)
        if builder_image:
            _set_builder_image(builder_image)

        if environment == constants.GAE:
            return deploy_app_gae(yaml)
        elif environment == constants.GKE:
            return deploy_app_gke(yaml)
        else:
            raise Exception('Invalid environment provided: %s', environment)

    except subprocess.CalledProcessError as cpe:
        logging.error('Error encountered when deploying application! %s',
                      cpe.output)
        raise
    except Exception as e:
        logging.error('Error encountered when deploying application! %s', e)
        raise
    finally:
        _cleanup_files(appdir)
        os.chdir(owd)