-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathlib
54 lines (48 loc) · 1.49 KB
/
lib
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/bash
: "${BASH_LIB_DIR:?BASH_LIB_DIR must be set. Please source bash-lib/init before other scripts from bash-lib.}"
# Sets additional required environment variables that aren't available in the
# secrets.yml file, and performs other preparatory steps
function bl_build_gke_image() {
local image="gke-utils:latest"
local rc=0
docker rmi ${image} || true
bl_spushd "${BASH_LIB_DIR}/k8s"
# Prepare Docker images
docker build --tag "${image}"\
--build-arg KUBECTL_CLI_URL="${KUBECTL_CLI_URL}" \
. 1>&2
rc=${?}
bl_spopd
return ${rc}
}
# Delete an image from GCR, unless it is has multiple tags pointing to it
# This means another parallel build is using the image and we should
# just untag it to be deleted by the later job
function bl_delete_gke_image() {
local image_and_tag="${1}"
bl_run_docker_gke_command "
gcloud container images delete --force-delete-tags -q ${image_and_tag}
"
}
function bl_run_docker_gke_command() {
docker run --rm \
-i \
-e DOCKER_REGISTRY_URL \
-e DOCKER_REGISTRY_PATH \
-e GCLOUD_SERVICE_KEY="/tmp${GCLOUD_SERVICE_KEY}" \
-e GCLOUD_CLUSTER_NAME \
-e GCLOUD_ZONE \
-e SECRETLESS_IMAGE \
-e KUBECTL_CLI_URL \
-e GCLOUD_PROJECT_NAME \
-v "${GCLOUD_SERVICE_KEY}:/tmp${GCLOUD_SERVICE_KEY}" \
-v /var/run/docker.sock:/var/run/docker.sock \
-v ~/.config:/root/.config \
-v "${PWD}:/src" \
-w /src \
"gke-utils:latest" \
bash -ec "
/scripts/platform_login
${1}
"
}