mirror of
				https://gitea.com/Lydanne/buildx.git
				synced 2025-11-03 17:43:42 +08:00 
			
		
		
		
	Merge pull request #428 from zanven42/master
fixes #427: Handle empty strings in elements enabling conditional logic
This commit is contained in:
		
							
								
								
									
										37
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										37
									
								
								README.md
									
									
									
									
									
								
							@@ -745,6 +745,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...]`
 | 
					### `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.
 | 
					Imagetools contains commands for working with manifest lists in the registry. These commands are useful for inspecting multi-platform build results.
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -526,6 +526,9 @@ func removeDupes(s []string) []string {
 | 
				
			|||||||
		if _, ok := seen[v]; ok {
 | 
							if _, ok := seen[v]; ok {
 | 
				
			||||||
			continue
 | 
								continue
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
							if v == "" {
 | 
				
			||||||
 | 
								continue
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
		seen[v] = struct{}{}
 | 
							seen[v] = struct{}{}
 | 
				
			||||||
		s[i] = v
 | 
							s[i] = v
 | 
				
			||||||
		i++
 | 
							i++
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -31,6 +31,7 @@ var (
 | 
				
			|||||||
		"csvdecode":              stdlib.CSVDecodeFunc,
 | 
							"csvdecode":              stdlib.CSVDecodeFunc,
 | 
				
			||||||
		"coalesce":               stdlib.CoalesceFunc,
 | 
							"coalesce":               stdlib.CoalesceFunc,
 | 
				
			||||||
		"coalescelist":           stdlib.CoalesceListFunc,
 | 
							"coalescelist":           stdlib.CoalesceListFunc,
 | 
				
			||||||
 | 
							"compact":                stdlib.CompactFunc,
 | 
				
			||||||
		"concat":                 stdlib.ConcatFunc,
 | 
							"concat":                 stdlib.ConcatFunc,
 | 
				
			||||||
		"contains":               stdlib.ContainsFunc,
 | 
							"contains":               stdlib.ContainsFunc,
 | 
				
			||||||
		"distinct":               stdlib.DistinctFunc,
 | 
							"distinct":               stdlib.DistinctFunc,
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user