Skip to content

bake: restrict target name#929

Merged
tonistiigi merged 1 commit intodocker:masterfrom
crazy-max:bake-target-name
Jan 26, 2022
Merged

bake: restrict target name#929
tonistiigi merged 1 commit intodocker:masterfrom
crazy-max:bake-target-name

Conversation

@crazy-max
Copy link
Copy Markdown
Member

@crazy-max crazy-max commented Jan 25, 2022

fixes #888

This fix adds a restriction [a-zA-Z0-9_-]+
for target name. This is pretty much the same as the
container name restriction in moby.


# docker-compose.yml
services:
  a.bc:
    build:
      context: .
$ docker buildx bake --print
error: invalid service name "a.bc": only "[a-zA-Z0-9_-]+" are allowed

// docker-bake.hcl
group "default" {
  targets = ["a.bc"]
}

target "a.bc" {
  context = "."
}
$ docker buildx bake --print
docker-bake.hcl:5
--------------------
   3 |     }
   4 |
   5 | >>> target "a.bc" {
   6 |       context = "."
   7 |     }
--------------------
error: docker-bake.hcl:5,8-14: Invalid name; only "[a-zA-Z0-9_-]+" are allowed

Signed-off-by: CrazyMax [email protected]

@crazy-max crazy-max requested a review from tonistiigi January 25, 2022 17:41
@crazy-max crazy-max force-pushed the bake-target-name branch 2 times, most recently from 57ff895 to d995dc8 Compare January 25, 2022 21:54
Copy link
Copy Markdown
Member

@tonistiigi tonistiigi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does compose side do something similar already?

Comment thread bake/hclparser/hclparser.go Outdated
This fix adds a restriction `[a-zA-Z0-9_-]+`
for target name. This is pretty much the same as the
container name restriction in moby.

Signed-off-by: CrazyMax <[email protected]>
@crazy-max crazy-max requested a review from tonistiigi January 26, 2022 09:44
@crazy-max crazy-max added this to the v0.8.0 milestone Jan 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bake : Allowed "/" in target names collides with bake --push option

2 participants