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

build: add variable validation in bake #21508

Merged
merged 1 commit into from
Nov 28, 2024

Conversation

dvdksn
Copy link
Collaborator

@dvdksn dvdksn commented Nov 26, 2024

Signed-off-by: David Karlsson [email protected]

@github-actions github-actions bot added the area/build Relates to Dockerfiles or docker build command label Nov 26, 2024
Copy link

netlify bot commented Nov 26, 2024

Deploy Preview for docsdocker ready!

Name Link
🔨 Latest commit 1769e0d
🔍 Latest deploy log https://app.netlify.com/sites/docsdocker/deploys/674842c8e9875600083a1649
😎 Deploy Preview https://deploy-preview-21508--docsdocker.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@dvdksn dvdksn force-pushed the bake-variable-validation branch from f5dc86c to 8b9574f Compare November 28, 2024 07:53
@dvdksn dvdksn marked this pull request as ready for review November 28, 2024 07:53
@dvdksn dvdksn requested a review from crazy-max as a code owner November 28, 2024 07:53
crazy-max
crazy-max previously approved these changes Nov 28, 2024
Copy link
Member

@crazy-max crazy-max left a comment

Choose a reason for hiding this comment

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

Nice thanks! These are great examples 🎉

@crazy-max
Copy link
Member

Wonder if we could show another example where a variable depends on another one like: docker/buildx#2794 (comment)

variable "FOO" {}
variable "BAR" {
  validation {
    condition = FOO != ""
    error_message = "BAR requires FOO to be set."
  }
}

target "default" {
  args = {
    BAR = BAR
  }
}
$ docker buildx bake --print
#1 [internal] load local bake definitions
#1 reading docker-bake.hcl 183B / 183B done
#1 DONE 0.0s
docker-bake.hcl:4
--------------------
   2 |     variable "BAR" {
   3 |       validation {
   4 | >>>     condition = FOO != ""
   5 |         error_message = "BAR requires FOO to be set."
   6 |       }
--------------------
ERROR: docker-bake.hcl:4,17-26: Validation failed; BAR requires FOO to be set.

@dvdksn
Copy link
Collaborator Author

dvdksn commented Nov 28, 2024

@crazy-max updated the examples a little (added a dependency one, and clarified the existing ones)

@dvdksn dvdksn requested a review from crazy-max November 28, 2024 10:16
Copy link
Member

@crazy-max crazy-max left a comment

Choose a reason for hiding this comment

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

❤️

@dvdksn dvdksn merged commit 300e985 into docker:main Nov 28, 2024
14 checks passed
@dvdksn dvdksn deleted the bake-variable-validation branch November 28, 2024 10:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/build Relates to Dockerfiles or docker build command
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants