sed regex now accounts for trailing whitespace

This commit is contained in:
m-okeefe 2019-01-29 09:20:21 -08:00
parent 3fdf206263
commit 0c2251ea46
4 changed files with 4 additions and 40 deletions

View file

@ -15,6 +15,4 @@ releases.
1. `./make-docker-images.sh`: builds and pushes images to the specified Docker repository.
2. `./make-release-artifacts.sh`: injects updated images/tag into
`./release/kubernetes-manifests/demo.yaml`.
3. `./restore-release-artifacts.sh`: restores image names/tags in `demo.yaml` to defaults
(`adservice`, `cartservice`, etc.)
4. `./make-release.sh`: runs scripts 1 and 2, then runs `git tag` / pushes updated manifests to master.
3. `./make-release.sh`: runs scripts 1 and 2, then runs `git tag` / pushes updated manifests to master.

View file

@ -32,8 +32,8 @@ do
svcname="$(basename $dir)"
image="$REPO_PREFIX/$svcname:$TAG"
pattern="^[[:blank:]]*image:.*$svcname.*"
replace=" image: $image"
pattern="^\([[:blank:]]*\)image:[[:blank:]].*$svcname\(.*\)\([[:blank:]]*\)"
replace="\1image: $image\3"
sed -i '' "s|$pattern|$replace|g" $manifestfile
done

View file

@ -1,35 +0,0 @@
# Copyright 2019 Google LLC
#
# 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.
# Restores images ./release/kubernetes-manifests/demo.yaml to match ./kubernetes-manifests
#!/usr/bin/env bash
set -euo pipefail
log() { echo "$1" >&2; }
fail() { log "$1"; exit 1; }
manifestfile="./release/kubernetes-manifests/demo.yaml"
# restore release/ manifest images to skaffold default, eg. "adservice"
for dir in ./src/*/
do
svcname=$(basename $dir)
pattern="^[[:blank:]]*image:.*$svcname.*"
replace=" image: $svcname"
sed -i '' "s|$pattern|$replace|g" $manifestfile
done
log "Restored demo.yaml."

View file

@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
apiVersion: extensions/v1beta1
kind: Deployment
metadata: