| 51 | } |
| 52 | |
| 53 | func (opts buildOptions) toAPIBuildOptions(services []string) (api.BuildOptions, error) { |
| 54 | var SSHKeys []types.SSHKey |
| 55 | if opts.ssh != "" { |
| 56 | id, path, found := strings.Cut(opts.ssh, "=") |
| 57 | if !found && id != "default" { |
| 58 | return api.BuildOptions{}, fmt.Errorf("invalid ssh key %q", opts.ssh) |
| 59 | } |
| 60 | SSHKeys = append(SSHKeys, types.SSHKey{ |
| 61 | ID: id, |
| 62 | Path: path, |
| 63 | }) |
| 64 | } |
| 65 | builderName := opts.builder |
| 66 | if builderName == "" { |
| 67 | builderName = os.Getenv("BUILDX_BUILDER") |
| 68 | } |
| 69 | |
| 70 | uiMode := display.Mode |
| 71 | if uiMode == display.ModeJSON { |
| 72 | uiMode = "rawjson" |
| 73 | } |
| 74 | |
| 75 | return api.BuildOptions{ |
| 76 | Pull: opts.pull, |
| 77 | Push: opts.push, |
| 78 | Progress: uiMode, |
| 79 | Args: types.NewMappingWithEquals(opts.args), |
| 80 | NoCache: opts.noCache, |
| 81 | Quiet: opts.quiet, |
| 82 | Services: services, |
| 83 | Deps: opts.deps, |
| 84 | Memory: int64(opts.memory), |
| 85 | Print: opts.print, |
| 86 | Check: opts.check, |
| 87 | SSHs: SSHKeys, |
| 88 | Builder: builderName, |
| 89 | SBOM: opts.sbom, |
| 90 | Provenance: opts.provenance, |
| 91 | }, nil |
| 92 | } |
| 93 | |
| 94 | func buildCommand(p *ProjectOptions, dockerCli command.Cli, backendOptions *BackendOptions) *cobra.Command { |
| 95 | opts := buildOptions{ |