blob: f7207701f256fde89f3571eba0f1fb870866969a [file] [log] [blame]
Gary Wu3fc3c722018-05-07 11:00:41 -07001#!/bin/bash
2
3if [ "$#" -ne 2 ]; then
Gary Wu64c540b2018-05-09 15:04:32 -07004 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 Wu3fc3c722018-05-07 11:00:41 -07006 exit 1
7fi
8
9# expected parameters
Gary Wu4885ce62018-05-07 12:27:37 -070010MANIFEST=$(realpath $1)
11OOM_DIR=$(realpath $2)
Gary Wu3fc3c722018-05-07 11:00:41 -070012
13if [ -z "$WORKSPACE" ]; then
14 export WORKSPACE=`git rev-parse --show-toplevel`
15fi
16
17DIR=$(dirname $(readlink -f "$0"))
18TARGET_DIR=$DIR/target
19rm -rf $TARGET_DIR
20mkdir -p $TARGET_DIR
21cd $TARGET_DIR
22
23cd $OOM_DIR
Gary Wu4885ce62018-05-07 12:27:37 -070024rgrep "image: .*" --include=values.yaml -h | cut -d ' ' -f 2 | tr -d '"'| grep -v '<' | grep -e "^onap" -e "^openecomp" | LC_ALL=C sort -u > $TARGET_DIR/oom-manifest.txt
Gary Wu3fc3c722018-05-07 11:00:41 -070025touch $TARGET_DIR/docker-manifest-new-entries.txt
26
27for 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
36done
37
Gary Wu4885ce62018-05-07 12:27:37 -070038cat $MANIFEST $TARGET_DIR/docker-manifest-new-entries.txt | LC_ALL=C sort -u > $MANIFEST.tmp
39mv $MANIFEST.tmp $MANIFEST