-
Notifications
You must be signed in to change notification settings - Fork 3
/
y-build-nothing
executable file
·37 lines (29 loc) · 1.28 KB
/
y-build-nothing
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env bash
[ -z "$DEBUG" ] || set -x
set -eo pipefail
# Settings
DEFAULT_REGISTRY=builds-registry.ystack.svc.cluster.local
[ -z "$BUILDS_REGISTRY" ] && BUILDS_REGISTRY=$DEFAULT_REGISTRY
[ -z "$PUSH_REGISTRY" ] && PUSH_REGISTRY=$DEFAULT_REGISTRY
if [ "$(curl -s --connect-timeout 3 http://$BUILDS_REGISTRY/v2/)" != "{}" ]
then
echo "ERROR Skaffold need local access to the builds registry for digest lookup"
echo "Registry: $BUILDS_REGISTRY"
echo "Look for y-stack's ingress or port-forward utilities"
exit 1
fi
[ -z "$IMAGE" ] && echo "No IMAGE env (from for example Skaffold)" && exit 1
IMAGE=$IMAGE
case "$IMAGE" in
$BUILDS_REGISTRY/* ) ;;
$BUILDS_REGISTRY:80/* ) ;;
$PUSH_REGISTRY/* ) echo "Unlike y-build this script won't push to non-build registries" && exit 1 ;;
* ) echo "Output is restricted to PUSH_REGISTRY=$PUSH_REGISTRY. Got: $IMAGE" && exit 1 ;;
esac
NOTHING_IMAGE=busybox@sha256:95cf004f559831017cdf4628aaf1bb30133677be8702a8c5f2994629f637a209
# TODO copy is significantly faster if the source image is already in the target repo
# crane hangs for a long time if it doesn't know that the registry is plain http
NOTHING_IMAGE=$(echo $NOTHING_IMAGE | sed 's|.local|.local:80|')
IMAGE=$(echo $IMAGE | sed 's|.local|.local:80|')
set -x
y-crane cp $NOTHING_IMAGE $IMAGE