(ctx context.Context, client *containerd.Client, options types.BuilderBuildOptions)
| 205 | } |
| 206 | |
| 207 | func generateBuildctlArgs(ctx context.Context, client *containerd.Client, options types.BuilderBuildOptions) (buildCtlBinary string, |
| 208 | buildctlArgs []string, needsLoading bool, metaFile string, tags []string, cleanup func(), err error) { |
| 209 | |
| 210 | buildctlBinary, err := buildkitutil.BuildctlBinary() |
| 211 | if err != nil { |
| 212 | return "", nil, false, "", nil, nil, err |
| 213 | } |
| 214 | |
| 215 | output := options.Output |
| 216 | if output == "" { |
| 217 | info, err := client.Server(ctx) |
| 218 | if err != nil { |
| 219 | return "", nil, false, "", nil, nil, err |
| 220 | } |
| 221 | sharable, err := isImageSharable(options.BuildKitHost, options.GOptions.Namespace, info.UUID, options.GOptions.Snapshotter, options.Platform) |
| 222 | if err != nil { |
| 223 | return "", nil, false, "", nil, nil, err |
| 224 | } |
| 225 | if sharable { |
| 226 | output = "type=image,unpack=true" // ensure the target stage is unlazied (needed for any snapshotters) |
| 227 | } else { |
| 228 | output = "type=docker" |
| 229 | if len(options.Platform) > 1 { |
| 230 | // For avoiding `error: failed to solve: docker exporter does not currently support exporting manifest lists` |
| 231 | // TODO: consider using type=oci for single-options.Platform build too |
| 232 | output = "type=oci" |
| 233 | } |
| 234 | needsLoading = true |
| 235 | } |
| 236 | } else { |
| 237 | if !strings.Contains(output, "type=") { |
| 238 | // should accept --output <DIR> as an alias of --output |
| 239 | // type=local,dest=<DIR> |
| 240 | output = fmt.Sprintf("type=local,dest=%s", output) |
| 241 | } |
| 242 | if strings.Contains(output, "type=docker") || strings.Contains(output, "type=oci") { |
| 243 | if !strings.Contains(output, "dest=") { |
| 244 | needsLoading = true |
| 245 | } |
| 246 | } |
| 247 | } |
| 248 | if tags = strutil.DedupeStrSlice(options.Tag); len(tags) > 0 { |
| 249 | ref := tags[0] |
| 250 | parsedReference, err := referenceutil.Parse(ref) |
| 251 | if err != nil { |
| 252 | return "", nil, false, "", nil, nil, err |
| 253 | } |
| 254 | output += ",name=" + parsedReference.String() |
| 255 | |
| 256 | // pick the first tag and add it to output |
| 257 | for idx, tag := range tags { |
| 258 | parsedReference, err = referenceutil.Parse(tag) |
| 259 | if err != nil { |
| 260 | return "", nil, false, "", nil, nil, err |
| 261 | } |
| 262 | tags[idx] = parsedReference.String() |
| 263 | } |
| 264 | } else if len(tags) == 0 { |
no test coverage detected
searching dependent graphs…