def generate_v2_image_properties()

in marketplace/deployer_util/expand_config.py [0:0]


def generate_v2_image_properties(schema, values_dict, result):
  repo_prefix = values_dict.get(_IMAGE_REPO_PREFIX_PROPERTY_NAME, None)
  if not repo_prefix:
    raise MissingRequiredValue('A valid value for __image_repo_prefix__ '
                               'must be specified in values.yaml')
  tag = schema.x_google_marketplace.published_version
  for img in schema.x_google_marketplace.images.values():
    if img.name:
      # Allows an empty image name for legacy reason.
      registry_repo = '{}/{}'.format(repo_prefix, img.name)
    else:
      registry_repo = repo_prefix
    registry, repo = registry_repo.split('/', 1)
    full = '{}:{}'.format(registry_repo, tag)
    for prop in img.properties.values():
      if prop.part_type == config_helper.IMAGE_PROJECTION_TYPE_FULL:
        result[prop.name] = full
      elif prop.part_type == config_helper.IMAGE_PROJECTION_TYPE_REGISTRY:
        result[prop.name] = registry
      elif prop.part_type == config_helper.IMAGE_PROJECTION_TYPE_REGISTRY_REPO:
        result[prop.name] = registry_repo
      elif prop.part_type == config_helper.IMAGE_PROJECTION_TYPE_REPO:
        result[prop.name] = repo
      elif prop.part_type == config_helper.IMAGE_PROJECTION_TYPE_TAG:
        result[prop.name] = tag
      else:
        raise InvalidProperty(
            'Invalid type for images.properties.type: {}'.format(
                prop.part_type))