Skip to content

bake: fix groups print#881

Merged
tonistiigi merged 1 commit intodocker:masterfrom
crazy-max:fix-bake-print
Dec 14, 2021
Merged

bake: fix groups print#881
tonistiigi merged 1 commit intodocker:masterfrom
crazy-max:fix-bake-print

Conversation

@crazy-max
Copy link
Copy Markdown
Member

fixes #877

@tonistiigi Also found an odd case when a group and target can have the same name without erroring:

group "foo" {
  targets = ["image"]
}
target "foo" {
  dockerfile = "bar"
}
target "image" {
  dockerfile = "test"
}
$ docker buildx bake --print foo
{
  "group": {
    "default": {
      "targets": [
        "image"
      ]
    }
  },
  "target": {
    "image": {
      "context": ".",
      "dockerfile": "test"
    }
  }
}

Not sure if it's expected?

Signed-off-by: CrazyMax [email protected]

@tonistiigi
Copy link
Copy Markdown
Member

Group taking precedence over target sgtm. But

group "foo" {
  targets = ["foo"]
}

should probably also work.

@crazy-max crazy-max marked this pull request as draft December 13, 2021 16:04
@crazy-max
Copy link
Copy Markdown
Member Author

@tonistiigi

group "foo" {
  targets = ["foo"]
}

should probably also work.

It doesn't unfortunately:

group "foo" {
  targets = ["foo"]
}
target "foo" {
  dockerfile = "bar"
}
docker buildx bake foo --print
{
  "group": {
    "default": {
      "targets": [
        "foo"
      ]
    }
  },
  "target": {}
}

Because group is already visited:

for _, n := range c.ResolveGroup(n) {

Changes in ResolveGroup fixes it but I wonder if it should not be done in the ReadTargets func.

@crazy-max crazy-max marked this pull request as ready for review December 13, 2021 16:56
@crazy-max crazy-max requested a review from tonistiigi December 13, 2021 18:10
@tonistiigi
Copy link
Copy Markdown
Member

It doesn't unfortunately:

@crazy-max we can fix that one separately

Signed-off-by: CrazyMax <[email protected]>
@tonistiigi tonistiigi merged commit 33c121d into docker:master Dec 14, 2021
@crazy-max crazy-max deleted the fix-bake-print branch December 14, 2021 00:15
@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 --print show wrong docker-bake.json when we target a group not default

2 participants