Gary Wu | 3fc3c72 | 2018-05-07 11:00:41 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | if [ "$#" -ne 2 ]; then |
Gary Wu | 64c540b | 2018-05-09 15:04:32 -0700 | [diff] [blame] | 4 | echo This script adds new docker images from OOM helm charts into docker-manifest.csv |
| 5 | echo "$0 <docker-manifest.csv> <oom repo directory>" |
Gary Wu | 3fc3c72 | 2018-05-07 11:00:41 -0700 | [diff] [blame] | 6 | exit 1 |
| 7 | fi |
| 8 | |
| 9 | # expected parameters |
Gary Wu | 4885ce6 | 2018-05-07 12:27:37 -0700 | [diff] [blame] | 10 | MANIFEST=$(realpath $1) |
| 11 | OOM_DIR=$(realpath $2) |
Gary Wu | 3fc3c72 | 2018-05-07 11:00:41 -0700 | [diff] [blame] | 12 | |
| 13 | if [ -z "$WORKSPACE" ]; then |
| 14 | export WORKSPACE=`git rev-parse --show-toplevel` |
| 15 | fi |
| 16 | |
| 17 | DIR=$(dirname $(readlink -f "$0")) |
| 18 | TARGET_DIR=$DIR/target |
| 19 | rm -rf $TARGET_DIR |
| 20 | mkdir -p $TARGET_DIR |
| 21 | cd $TARGET_DIR |
| 22 | |
| 23 | cd $OOM_DIR |
Gary Wu | f4db8a8 | 2018-10-17 14:56:31 -0700 | [diff] [blame] | 24 | rgrep -i "image: .*" --include=values.yaml -h | awk '{ $1=$1; print }' | cut -d ' ' -f 2 | tr -d '"'| grep -v '<' | grep -e "^onap" -e "^openecomp" | LC_ALL=C sort -u > $TARGET_DIR/oom-manifest.txt |
Gary Wu | 3fc3c72 | 2018-05-07 11:00:41 -0700 | [diff] [blame] | 25 | touch $TARGET_DIR/docker-manifest-new-entries.txt |
| 26 | |
| 27 | for line in $(cat $TARGET_DIR/oom-manifest.txt); do |
| 28 | image=$(echo $line | cut -d : -f 1) |
| 29 | tag=$(echo $line | cut -s -d : -f 2) |
| 30 | if [ -z "$tag" ]; then |
| 31 | tag="latest" |
| 32 | fi |
| 33 | if ! grep -q "$image" $MANIFEST; then |
| 34 | echo $image,$tag >> $TARGET_DIR/docker-manifest-new-entries.txt |
| 35 | fi |
| 36 | done |
| 37 | |
Gary Wu | 4885ce6 | 2018-05-07 12:27:37 -0700 | [diff] [blame] | 38 | cat $MANIFEST $TARGET_DIR/docker-manifest-new-entries.txt | LC_ALL=C sort -u > $MANIFEST.tmp |
| 39 | mv $MANIFEST.tmp $MANIFEST |