github.com/verrazzano/verrazzano@v1.7.1/tools/scripts/generate_image_list.sh (about)

     1  #!/bin/bash
     2  #
     3  # Copyright (c) 2021, 2023, Oracle and/or its affiliates.
     4  # Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
     5  #
     6  SCRIPT_DIR=$(cd $(dirname "$0"); pwd -P)
     7  
     8  if [ ! -f "$1" ]; then
     9    echo "You must specify the BOM file as input"
    10    exit 1
    11  fi
    12  if [ -z "$2" ]; then
    13    echo "You must specify the output image list file name"
    14    exit 1
    15  fi
    16  BOM_FILE=$1
    17  IMG_LIST_FILE=$2
    18  REPOS="${3:-verrazzano}"
    19  
    20  if [ -f "$IMG_LIST_FILE" ]; then
    21    echo "Output file $IMG_LIST_FILE already exists, please specify a new filename"
    22    exit 1
    23  else
    24    touch $IMG_LIST_FILE
    25  fi
    26  
    27  source $SCRIPT_DIR/bom_utils.sh
    28  
    29  function list_images() {
    30    local components=($(list_components))
    31    local global_registry=$(get_bom_global_registry)
    32    for component in "${components[@]}"; do
    33      local sub_components=$(list_subcomponent_names ${component})
    34      for subcomponent in ${sub_components}; do
    35        local override_registry=$(resolve_subcomponent_registry_from_bom ${component} ${subcomponent})
    36        local image_names=$(list_subcomponent_images ${component} ${subcomponent})
    37        for base_image in ${image_names}; do
    38          local from_repository=$(resolve_image_repo_from_bom ${component} ${subcomponent} ${base_image})
    39          local from_image
    40          if [ -n "$override_registry" ] && [ "$override_registry" != "null" ]; then
    41            from_image=${override_registry}/${from_repository}/${base_image}
    42          else
    43            from_image=${from_repository}/${base_image}
    44          fi
    45          local existing=$(cat ${IMG_LIST_FILE} | grep ${from_image})
    46          if [ -z "$existing" ]; then
    47            echo "${from_image}" >> ${IMG_LIST_FILE}
    48          fi
    49        done
    50  
    51      done
    52    done
    53  }
    54  
    55  list_images $1 $2