blob: d03bb02895b3aad53ba0babea6da1358d1af2aef [file] [log] [blame]
#!/bin/bash
# Copyright (C) 2023 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http:#www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
usage() {
me=`basename "$0"`
echo >&2 "Usage: $me [--help] [--osx] NEW"
exit 1
}
while test $# -gt 0 ; do
case "$1" in
--help)
usage
;;
--osx)
shift
export BACKUP_EXT=""
;;
*)
break
esac
done
NEW="$1"
if test -z "$NEW"; then
usage
fi
SCRIPT_PATH="$(dirname "$(readlink -f "$0")")"
API_PATH="$SCRIPT_PATH/../src/main/java/com/google/gerrit/k8s/operator"
OLD="$(yq e '.spec.versions[0].name' $SCRIPT_PATH/../../crd/current/gerritclusters.gerritoperator.google.com-v1.yml)"
sed -i ${BACKUP_EXT+"$BACKUP_EXT"} "s/$OLD/$NEW/g" "$API_PATH/Constants.java"
find $SCRIPT_PATH/.. $SCRIPT_PATH/../../Documentation/examples \
-name '*.yaml' \
-type f \
-exec sed -i ${BACKUP_EXT+"$BACKUP_EXT"} "s#gerritoperator.google.com/$OLD#gerritoperator.google.com/$NEW#g" {} ';'
sed -i ${BACKUP_EXT+"$BACKUP_EXT"} "s#$OLD#$NEW#g" $SCRIPT_PATH/../../Documentation/operator-api-reference.md
rm -r $SCRIPT_PATH/../../crd/deprecated
mv $SCRIPT_PATH/../../crd/current $SCRIPT_PATH/../../crd/deprecated
for f in "$SCRIPT_PATH/../../crd/deprecated/"*.yml; do
yq -i '.spec.versions[0].storage = false' "$f"
done
mkdir $SCRIPT_PATH/../../crd/current
pushd $SCRIPT_PATH/..
mvn clean install
popd