Looks like there might be some unintended case tra...
# general
r
Looks like there might be some unintended case transformation going on in the Docker plugin... if I specify...
Copy code
docker_image(
  ...
  image_tags=[
    "{build_args.BRANCH}"
  ]
)
where
BRANCH
is included in
[docker] env_vars
and
[docker] build_args
(is it correct that it should be included in both places?) ... and if
BRANCH
has upper-case characters it looks like the tags on the image are all in lower case. Or maybe this is by design?
c
Hi!
(is it correct that it should be included in both places?)
No, if you want to pick up the
BRANCH
from the envrionment Pants is running in, it is enough to list it in
[docker] build_args
or on the
docker_image
target with
extra_build_args
without a value (i.e. as
BRANCH
not as
BRANCH=some-value
) https://www.pantsbuild.org/docs/tagging-docker-images#using-env-vars-to-include-dynamic-data-in-tags
upper-case characters […] are all in lower case
Yes, this is by design, for two reasons. a) First, since this is the required format for an image name: https://docs.docker.com/engine/reference/commandline/tag/#extended-description
An image name is made up of slash-separated name components, optionally prefixed by a registry hostname. The hostname must comply with standard DNS rules, but may not contain underscores. If a hostname is present, it may optionally be followed by a port number in the format
:8080
. If not present, the command uses Docker’s public registry located at
<http://registry-1.docker.io|registry-1.docker.io>
by default. Name components may contain lowercase letters, digits and separators. A separator is defined as a period, one or two underscores, or one or more dashes. A name component may not start or end with a separator.
This continues however with
A tag name must be valid ASCII and may contain lowercase and uppercase letters, digits, underscores, periods and dashes.
Which I’ve overlooked when implementing this, so Pants is currently forcing the tag to be lowercase, although that is not required (but may be a good idea, given the next point for lowercasing the image name) - but I consider this a bug, though (that the tag part is forced to lowercase as well). b) Looking at the bigger picture, where the image name may be referenced in other tools/systems, there are cases where the image name may be transformed (to lowercase) in which case it will be really difficult to restore to the original casing for subsequent steps (the Docker registry is case sensitive). This may sound a bit random, but is a real case we’ve had issues with (for more scenarios than image names) at my work.
(oh, I got a palindrome issue number 😛 )
🔥 1
r
Thanks for the insight. This has been an issue for me as I'm unable to get the
publish
step to work with the gcloud auth as mentioned in a previous thread, although I can run
package
just fine and then I get tripped up when I run
docker push some-image-name:$BRANCH
... the
package
has tagged with
$BRANCH
converted to lower-case but in the rest of my script
$BRANCH
was obviously still in mixed case... however I've updated my script to force to lower-case. I'll see if I can get
publish
working with the gcloud auth as well.
c
Ah, and there you’re using BRANCH as tag, which should’ve been left in its original form, per the bug report. I’ll get a fix out for that.
OK, fix pushed, pending review/merge and cherry picks: https://github.com/pantsbuild/pants/pull/15254
❤️ 2