예제 #1
0
def _GetRegionalizedBuilder(args, executable, region_getter, docker_image_tag):
    """Return Docker image path for regionalized builder wrapper.

  Args:
    args: gcloud command args
    executable: name of builder executable to run
    region_getter: method that returns desired region based on args
    docker_image_tag: tag for Docker builder images (e.g. 'release')

  Returns:
    str: path to Docker images for regionalized builder.
  """
    try:
        region = region_getter(args)
    except HttpError:
        region = ''

    if not region:
        return ''

    regionalized_builder = _REGIONALIZED_BUILDER_DOCKER_PATTERN.format(
        executable=executable,
        region=region,
        docker_image_tag=docker_image_tag)

    # Verify builder image exists. Some situations when a repo won't exist:
    # - new region wrappers are not deployed to
    # - Artifact registry not in a region (e.g. us-west3/us-west4)
    try:
        docker_util.GetDockerImage(regionalized_builder)
        return regionalized_builder
    except (HttpNotFoundError, HttpError):
        # We can't verify the repo exists
        return ''
예제 #2
0
def _GetRegionalizedBuilder(args, executable, region_getter, docker_image_tag):
  """Return Docker image path for regionalized builder wrapper.

  Args:
    args: gcloud command args
    executable: name of builder executable to run
    region_getter: method that returns desired region based on args
    docker_image_tag: tag for Docker builder images (e.g. 'release')

  Returns:
    str: path to Docker images for regionalized builder.
  """
  try:
    region = region_getter(args)
  except HttpError:
    region = ''

  if not region:
    return ''

  regionalized_builder = _REGIONALIZED_BUILDER_DOCKER_PATTERN.format(
      executable=executable,
      region=region,
      docker_image_tag=docker_image_tag)

  # Verify builder image exists. Some situations when a repo won't exist:
  # - new region wrappers are not deployed to
  # - Artifact registry not in a region (e.g. us-west3/us-west4)
  try:
    docker_util.GetDockerImage(regionalized_builder)
    return regionalized_builder
  except HttpNotFoundError:
    # We're sure here that repo or image don't exist
    return ''
  except HttpError:
    # For other HTTP errors, such as no permission to check if the repo exists
    # return the builder path and let Cloud Build run method handle potential
    # failures due to missing repo
    return regionalized_builder