Skip to content

Commit

Permalink
go_image: implement tag_name (#2206)
Browse files Browse the repository at this point in the history
This is a follow-up for 7d34678
  • Loading branch information
motiejus authored Jan 21, 2023
1 parent e48c7cc commit fc729d8
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion go/image.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ STATIC_DEFAULT_BASE = select({
"//conditions:default": "@go_image_static//image",
})

def go_image(name, base = None, deps = [], layers = [], env = {}, binary = None, **kwargs):
def go_image(name, base = None, tag_name = None, deps = [], layers = [], env = {}, binary = None, **kwargs):
"""Constructs a container image wrapping a go_binary target.
Args:
Expand Down Expand Up @@ -123,6 +123,7 @@ def go_image(name, base = None, deps = [], layers = [], env = {}, binary = None,
compatible_with = kwargs.get("compatible_with", None)
app_layer(
name = name,
tag_name = tag_name,
base = base,
env = env,
binary = binary,
Expand Down
2 changes: 1 addition & 1 deletion testing/e2e/go_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function test_go_image_busybox() {
clear_docker
bazel run -c dbg tests/container/go:go_image -- --norun
local number=$RANDOM
id=$(docker run -d --entrypoint=sh bazel/tests/container/go:go_image -c "echo aa${number}bb")
id=$(docker run -d --entrypoint=sh bazel/tests/container/go:go_image-with-our-tag -c "echo aa${number}bb")
docker wait $id
logs=$(docker logs $id)
EXPECT_CONTAINS $logs "aa${number}bb"
Expand Down
1 change: 1 addition & 0 deletions tests/container/go/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ go_image(
env = {"GO_IMAGE_TEST_KEY": "go_image_test_value"},
importpath = "github.com/bazelbuild/rules_docker/docker/tests/container/go",
pure = "off", # we should be using gcr.io/distroless/base as a base image
tag_name = "go_image-with-our-tag",
tags = [
"tag1",
"tag2",
Expand Down

0 comments on commit fc729d8

Please sign in to comment.