예제 #1
0
def _detect_stage_version(stage_name):
    """
  Stage version is defined as:
    - `v1` for bash script stage definitions
    - `v2+` for python stage definitions

  Starts by checking for latest version.

  Returns:
      (version, filepath)
  """
    stage_python_filepath = shared.get_stage_file(stage_name)
    if os.path.exists(stage_python_filepath):
        stage = shared.get_stage_object(stage_name)
        stage_version = getattr(stage, "spec_version", STAGE_VERSION_2_0)
        if stage_version not in SUPPORTED_STAGE_VERSIONS:
            raise ValueError("Unsupported spec version: '%s'. "
                             "Supported versions are %s" %
                             (stage_version, SUPPORTED_STAGE_VERSIONS))
        return stage_version, stage_python_filepath

    stage_bash_filepath = os.path.join(constants.PROJECT_DIR,
                                       "scripts/variables/stages",
                                       "%s.sh" % stage_name)
    if os.path.exists(stage_bash_filepath):
        return STAGE_VERSION_1_0, stage_bash_filepath

    raise ValueError("No stage file found for name: '%s'" % stage_name)
예제 #2
0
def download_config_files(stage, debug=False):
  stage_file_path = shared.get_stage_file(stage.stage_name)
  service_account_file_path = shared.get_service_account_file(stage)
  command = "cloudshell download-files \
    \"{stage_file}\" \
    \"{service_account_file}\"".format(
      stage_file=stage_file_path,
      service_account_file=service_account_file_path)
  shared.execute_command("Download configuration files", command, debug=debug)
예제 #3
0
def download_config_files(stage, debug=False):
    stage_file_path = shared.get_stage_file(stage.stage_name)
    cmd = (f'cloudshell download-files "{stage_file_path}"')
    shared.execute_command('Download configuration file', cmd, debug=debug)