blob: dc4048c399d432b3cabe0ab81e5a174c6fd72b89 [file] [log] [blame]
Zack Williams8bef3022018-09-18 13:35:09 -07001#!/usr/bin/env bash
2#
3# Copyright 2018-present Open Networking Foundation
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
17# update_xos_docker.sh
18# Updates docker FROM lines of synchronizers and xos core, when XOS is updated,
19# and the synchronizer has the same parent SemVer major version
20#
21# Before using this, update XOS version in orchestration/xos/VERSION file
22#
23# After running script, `repo diff` will show the updated files.
24#
25# To undo changes: `repo forall -c git checkout *Dockerfile*`
26
27set -eu -o pipefail
28
29WORKSPACE=${WORKSPACE:-../../..}
30
31XOS_MAJOR=$(cut -b 1 "${WORKSPACE}/cord/orchestration/xos/VERSION")
32
33XOS_VERSION=$(cat "${WORKSPACE}/cord/orchestration/xos/VERSION")
34
35# Update Synchronizer FROM parent versions
36for df in ${WORKSPACE}/cord/orchestration/xos_services/*/Dockerfile.synchronizer \
37 ${WORKSPACE}/cord/orchestration/profiles/*/Dockerfile.synchronizer
38do
39 df_contents=$(cat "$df")
40
41 # shellcheck disable=SC2076
42 if [[ "$df_contents" =~ "FROM xosproject/xos-synchronizer-base:${XOS_MAJOR}" ||
43 "$df_contents" =~ "FROM xosproject/xos-synchronizer-base:master" ]]
44 then
45 echo "Updating synchronizer Dockerfile: ${df}"
46 sed -i -- "s/^FROM\\(.*\\):.*$/FROM\\1:$XOS_VERSION/" "$df"
47 fi
48done
49
50# Update XOS parent versions
51for df in ${WORKSPACE}/cord/orchestration/xos/containers/*/Dockerfile* \
52 ${WORKSPACE}/cord/orchestration/xos-tosca/Dockerfile
53do
54 echo "Updating core Dockerfile: ${df}"
55 sed -i -- "s/^FROM xos\\(.*\\):.*$/FROM xos\\1:$XOS_VERSION/" "$df"
56done