Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid bake target syntax still builds #2437

Open
crazy-max opened this issue Apr 29, 2024 · 1 comment
Open

Invalid bake target syntax still builds #2437

crazy-max opened this issue Apr 29, 2024 · 1 comment
Assignees
Labels
Milestone

Comments

@crazy-max
Copy link
Member

crazy-max commented Apr 29, 2024

I made a typo when writing a bake definition that contains an invalid targets field for target:

target "app" {
  dockerfile = "app.Dockerfile"
}

target "db" {
  dockerfile = "db.Dockerfile"
}

target "foo" {
  targets = ["app", "db"]
}

What's wrong is the bake definition still looks valid:

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

foo should be a group here:

target "app" {
  dockerfile = "app.Dockerfile"
}

target "db" {
  dockerfile = "db.Dockerfile"
}

group "foo" {
  targets = ["app", "db"]
}
$ docker buildx bake foo --print
{
  "group": {
    "default": {
      "targets": [
        "foo"
      ]
    },
    "foo": {
      "targets": [
        "app",
        "db"
      ]
    }
  },
  "target": {
    "app": {
      "context": ".",
      "dockerfile": "app.Dockerfile"
    },
    "db": {
      "context": ".",
      "dockerfile": "db.Dockerfile"
    }
  }
}

We should validate this.

@crazy-max crazy-max added kind/bug Something isn't working area/bake labels Apr 29, 2024
@crazy-max crazy-max added this to the v0.15.0 milestone Apr 29, 2024
@crazy-max crazy-max self-assigned this May 28, 2024
@crazy-max
Copy link
Member Author

crazy-max commented May 31, 2024

I started to work on it by evaluating contexts and adding strict schema validation for group and target block but there might be breaking changes if we introduce such validation. I move this one out of v0.15.0 milestone for now.

@crazy-max crazy-max modified the milestones: v0.15.0, v0.future May 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants