Skip to content

Commit 818f991

Browse files
authored
Merge pull request #482 from aleksandra-malinowska/cherry-pick-safety-net
Extra checks when pushing an image to gcr repository
2 parents 624ba01 + 74a8b57 commit 818f991

2 files changed

Lines changed: 36 additions & 1 deletion

File tree

cluster-autoscaler/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ ifndef REGISTRY
2727
$(ERR)
2828
endif
2929
docker build --pull -t ${REGISTRY}/cluster-autoscaler:${TAG} .
30-
gcloud docker -- push ${REGISTRY}/cluster-autoscaler:${TAG}
30+
./push_image.sh ${REGISTRY}/cluster-autoscaler:${TAG}
3131

3232
clean:
3333
rm -f cluster-autoscaler

cluster-autoscaler/push_image.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/bash
2+
3+
# Copyright 2017 The Kubernetes Authors.
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+
IMAGE_TO_PUSH=$1
18+
if [ -z $IMAGE_TO_PUSH ]; then
19+
echo No image passed
20+
exit 1
21+
fi
22+
23+
echo "About to push image $IMAGE_TO_PUSH"
24+
read -r -p "Are you sure? [y/N] " response
25+
if [[ "$response" =~ ^([yY])+$ ]]; then
26+
gcloud docker -- pull $IMAGE_TO_PUSH
27+
if [ $? -eq 0 ]; then
28+
echo $IMAGE_TO_PUSH already exists
29+
exit 1
30+
fi
31+
gcloud docker -- push $IMAGE_TO_PUSH
32+
else
33+
echo Aborted
34+
exit 1
35+
fi

0 commit comments

Comments
 (0)