Skip to content

Commit e770f81

Browse files
authored
Merge pull request #61 from bazelbuild/drop-legacy
In an effort to start simplifying these rules…
2 parents 8715ea5 + 5b5bb1e commit e770f81

File tree

3 files changed

+8
-32
lines changed

3 files changed

+8
-32
lines changed

docker/build.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ def _docker_build_impl(ctx):
314314
] + _get_layers(ctx, ctx.attr.base, ctx.files.base)
315315

316316
# Generate the incremental load statement
317-
_incr_load(ctx, layers, {tag_name: {"name": name, "id": identifier}
317+
_incr_load(ctx, layers, {tag_name: {"id": identifier}
318318
for tag_name in tags},
319319
ctx.outputs.executable)
320320

docker/incremental_load.sh.tpl

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,6 @@ RUNFILES="${PYTHON_RUNFILES:-${BASH_SOURCE[0]}.runfiles}"
2222

2323
DOCKER="${DOCKER:-docker}"
2424

25-
FULL_DOCKER_VERSION=$(docker version -f {{.Server.Version}} 2> /dev/null \
26-
|| echo "1.5.0")
27-
DOCKER_MAJOR_VERSION=$(echo "$FULL_DOCKER_VERSION" | awk -F\. '{ print $1 }')
28-
DOCKER_MINOR_VERSION=$(echo "$FULL_DOCKER_VERSION" | awk -F\. '{ print $2 }')
29-
if [ "$DOCKER_MAJOR_VERSION" -eq "1" ] && [ "$DOCKER_MINOR_VERSION" -lt "10" ]; then
30-
LEGACY_DOCKER=true
31-
else
32-
LEGACY_DOCKER=false
33-
fi
34-
3525
# List all images identifier (only the identifier) from the local
3626
# docker registry.
3727
IMAGES="$("${DOCKER}" images -aq)"
@@ -42,34 +32,22 @@ IMAGE_LEN=$(for i in $IMAGES; do echo -n $i | wc -c; done | sort -g | head -1 |
4232
function incr_load() {
4333
# Load a layer if and only if the layer is not in "$IMAGES", that is
4434
# in the local docker registry.
45-
if [ "$LEGACY_DOCKER" = true ]; then
46-
name=$(cat ${RUNFILES}/$1)
47-
else
48-
name=$(cat ${RUNFILES}/$2)
49-
fi
35+
name=$(cat ${RUNFILES}/$1)
5036

5137
if (echo "$IMAGES" | grep -q ^${name:0:$IMAGE_LEN}$); then
5238
echo "Skipping $name, already loaded."
5339
else
5440
echo "Loading $name..."
55-
"${DOCKER}" load -i ${RUNFILES}/$3
41+
"${DOCKER}" load -i ${RUNFILES}/$2
5642
fi
5743
}
5844

5945
function tag_layer() {
60-
if [ "$LEGACY_DOCKER" = true ]; then
61-
name=$(cat ${RUNFILES}/$2)
62-
else
63-
name=$(cat ${RUNFILES}/$3)
64-
fi
46+
name=$(cat ${RUNFILES}/$2)
6547

6648
TAG="$1"
6749
echo "Tagging ${name} as ${TAG}"
68-
if [ "$LEGACY_DOCKER" = true ]; then
69-
"${DOCKER}" tag -f ${name} ${TAG}
70-
else
71-
"${DOCKER}" tag sha256:${name} ${TAG}
72-
fi
50+
"${DOCKER}" tag sha256:${name} ${TAG}
7351
}
7452

7553
function read_variables() {

docker/layers.bzl

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,19 +86,17 @@ def incremental_load(ctx, layers, images, output, stamp=False):
8686
"read_variables %s" % _get_runfile_path(ctx, f)
8787
for f in stamp_files]),
8888
"%{load_statements}": "\n".join([
89-
"incr_load '%s' '%s' '%s'" % (_get_runfile_path(ctx, l["name"]),
90-
_get_runfile_path(ctx, l["id"]),
91-
_get_runfile_path(ctx, l["layer"]))
89+
"incr_load '%s' '%s'" % (_get_runfile_path(ctx, l["id"]),
90+
_get_runfile_path(ctx, l["layer"]))
9291
# The last layer is the first in the list of layers.
9392
# We reverse to load the layer from the parent to the child.
9493
for l in reverse(layers)]),
9594
"%{tag_statements}": "\n".join([
96-
"tag_layer \"%s\" '%s' '%s'" % (
95+
"tag_layer \"%s\" '%s'" % (
9796
# Turn stamp variable references into bash variables.
9897
# It is notable that the only legal use of '{' in a
9998
# tag would be for stamp variables, '$' is not allowed.
10099
img if not stamp else img.replace("{", "${"),
101-
_get_runfile_path(ctx, images[img]["name"]),
102100
_get_runfile_path(ctx, images[img]["id"]))
103101
for img in images
104102
])

0 commit comments

Comments
 (0)