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

fixes #427: Handle empty strings in elements enabling conditional logic #428

Merged
merged 3 commits into from
Dec 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -741,6 +741,43 @@ $ docker buildx bake --print webapp
}
```

Example of only adding tags if a variable is not empty using an `notequal` function:

```
$ cat <<'EOF' > docker-bake.hcl
variable "TAG" {default="" }

group "default" {
targets = [
"webapp",
]
}

target "webapp" {
context="."
dockerfile="Dockerfile"
tags = [
"my-image:latest",
notequal("",TAG) ? "my-image:${TAG}": "",
]
}
EOF

$ docker buildx bake --print webapp
{
"target": {
"webapp": {
"context": ".",
"dockerfile": "Dockerfile",
"tags": [
"my-image:latest"
]
}
}
}
```


### `buildx imagetools create [OPTIONS] [SOURCE] [SOURCE...]`

Imagetools contains commands for working with manifest lists in the registry. These commands are useful for inspecting multi-platform build results.
Expand Down
3 changes: 3 additions & 0 deletions bake/bake.go
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,9 @@ func removeDupes(s []string) []string {
if _, ok := seen[v]; ok {
continue
}
if v == "" {
continue
}
seen[v] = struct{}{}
s[i] = v
i++
Expand Down
1 change: 1 addition & 0 deletions bake/hcl.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ var (
"csvdecode": stdlib.CSVDecodeFunc,
"coalesce": stdlib.CoalesceFunc,
"coalescelist": stdlib.CoalesceListFunc,
"compact": stdlib.CompactFunc,
"concat": stdlib.ConcatFunc,
"contains": stdlib.ContainsFunc,
"distinct": stdlib.DistinctFunc,
Expand Down