mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-05-18 17:27:49 +08:00
Merge pull request #2487 from daghack/call-lint
Rename --print to --call and make previous name hidden
This commit is contained in:
commit
a24043e9f1
@ -597,11 +597,6 @@ func buildCmd(dockerCli command.Cli, rootOpts *rootOptions, debugConfig *debug.D
|
|||||||
|
|
||||||
flags.StringArrayVar(&options.platforms, "platform", platformsDefault, "Set target platform for build")
|
flags.StringArrayVar(&options.platforms, "platform", platformsDefault, "Set target platform for build")
|
||||||
|
|
||||||
if confutil.IsExperimental() {
|
|
||||||
flags.StringVar(&options.printFunc, "print", "", "Print result of information request (e.g., outline, targets)")
|
|
||||||
cobrautil.MarkFlagsExperimental(flags, "print")
|
|
||||||
}
|
|
||||||
|
|
||||||
flags.BoolVar(&options.exportPush, "push", false, `Shorthand for "--output=type=registry"`)
|
flags.BoolVar(&options.exportPush, "push", false, `Shorthand for "--output=type=registry"`)
|
||||||
|
|
||||||
flags.BoolVarP(&options.quiet, "quiet", "q", false, "Suppress the build output and print image ID on success")
|
flags.BoolVarP(&options.quiet, "quiet", "q", false, "Suppress the build output and print image ID on success")
|
||||||
@ -633,12 +628,20 @@ func buildCmd(dockerCli command.Cli, rootOpts *rootOptions, debugConfig *debug.D
|
|||||||
cobrautil.MarkFlagsExperimental(flags, "root", "detach", "server-config")
|
cobrautil.MarkFlagsExperimental(flags, "root", "detach", "server-config")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
flags.StringVar(&options.printFunc, "call", "build", `Set method for evaluating build ("check", "outline", "targets")`)
|
||||||
|
flags.VarPF(callAlias(options, "check"), "check", "", `Shorthand for "--call=check"`)
|
||||||
|
flags.Lookup("check").NoOptDefVal = "true"
|
||||||
|
|
||||||
// hidden flags
|
// hidden flags
|
||||||
var ignore string
|
var ignore string
|
||||||
var ignoreSlice []string
|
var ignoreSlice []string
|
||||||
var ignoreBool bool
|
var ignoreBool bool
|
||||||
var ignoreInt int64
|
var ignoreInt int64
|
||||||
|
|
||||||
|
flags.StringVar(&options.printFunc, "print", "", "Print result of information request (e.g., outline, targets)")
|
||||||
|
cobrautil.MarkFlagsExperimental(flags, "print")
|
||||||
|
flags.MarkHidden("print")
|
||||||
|
|
||||||
flags.BoolVar(&ignoreBool, "compress", false, "Compress the build context using gzip")
|
flags.BoolVar(&ignoreBool, "compress", false, "Compress the build context using gzip")
|
||||||
flags.MarkHidden("compress")
|
flags.MarkHidden("compress")
|
||||||
|
|
||||||
@ -1002,6 +1005,20 @@ func maybeJSONArray(v string) []string {
|
|||||||
return []string{v}
|
return []string{v}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func callAlias(options *buildOptions, value string) cobrautil.BoolFuncValue {
|
||||||
|
return func(s string) error {
|
||||||
|
v, err := strconv.ParseBool(s)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if v {
|
||||||
|
options.printFunc = value
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// timeBuildCommand will start a timer for timing the build command. It records the time when the returned
|
// timeBuildCommand will start a timer for timing the build command. It records the time when the returned
|
||||||
// function is invoked into a metric.
|
// function is invoked into a metric.
|
||||||
func timeBuildCommand(mp metric.MeterProvider, attrs attribute.Set) func(err error) {
|
func timeBuildCommand(mp metric.MeterProvider, attrs attribute.Set) func(err error) {
|
||||||
|
@ -24,7 +24,9 @@ Start a build
|
|||||||
| [`--builder`](#builder) | `string` | | Override the configured builder instance |
|
| [`--builder`](#builder) | `string` | | Override the configured builder instance |
|
||||||
| [`--cache-from`](#cache-from) | `stringArray` | | External cache sources (e.g., `user/app:cache`, `type=local,src=path/to/dir`) |
|
| [`--cache-from`](#cache-from) | `stringArray` | | External cache sources (e.g., `user/app:cache`, `type=local,src=path/to/dir`) |
|
||||||
| [`--cache-to`](#cache-to) | `stringArray` | | Cache export destinations (e.g., `user/app:cache`, `type=local,dest=path/to/dir`) |
|
| [`--cache-to`](#cache-to) | `stringArray` | | Cache export destinations (e.g., `user/app:cache`, `type=local,dest=path/to/dir`) |
|
||||||
|
| `--call` | `string` | `build` | Set method for evaluating build (`check`, `outline`, `targets`) |
|
||||||
| [`--cgroup-parent`](https://docs.docker.com/reference/cli/docker/image/build/#cgroup-parent) | `string` | | Set the parent cgroup for the `RUN` instructions during build |
|
| [`--cgroup-parent`](https://docs.docker.com/reference/cli/docker/image/build/#cgroup-parent) | `string` | | Set the parent cgroup for the `RUN` instructions during build |
|
||||||
|
| `--check` | | | Shorthand for `--call=check` |
|
||||||
| `--detach` | | | Detach buildx server (supported only on linux) (EXPERIMENTAL) |
|
| `--detach` | | | Detach buildx server (supported only on linux) (EXPERIMENTAL) |
|
||||||
| [`-f`](https://docs.docker.com/reference/cli/docker/image/build/#file), [`--file`](https://docs.docker.com/reference/cli/docker/image/build/#file) | `string` | | Name of the Dockerfile (default: `PATH/Dockerfile`) |
|
| [`-f`](https://docs.docker.com/reference/cli/docker/image/build/#file), [`--file`](https://docs.docker.com/reference/cli/docker/image/build/#file) | `string` | | Name of the Dockerfile (default: `PATH/Dockerfile`) |
|
||||||
| `--iidfile` | `string` | | Write the image ID to a file |
|
| `--iidfile` | `string` | | Write the image ID to a file |
|
||||||
@ -36,7 +38,6 @@ Start a build
|
|||||||
| [`--no-cache-filter`](#no-cache-filter) | `stringArray` | | Do not cache specified stages |
|
| [`--no-cache-filter`](#no-cache-filter) | `stringArray` | | Do not cache specified stages |
|
||||||
| [`-o`](#output), [`--output`](#output) | `stringArray` | | Output destination (format: `type=local,dest=path`) |
|
| [`-o`](#output), [`--output`](#output) | `stringArray` | | Output destination (format: `type=local,dest=path`) |
|
||||||
| [`--platform`](#platform) | `stringArray` | | Set target platform for build |
|
| [`--platform`](#platform) | `stringArray` | | Set target platform for build |
|
||||||
| `--print` | `string` | | Print result of information request (e.g., outline, targets) (EXPERIMENTAL) |
|
|
||||||
| [`--progress`](#progress) | `string` | `auto` | Set type of progress output (`auto`, `plain`, `tty`). Use plain to show container output |
|
| [`--progress`](#progress) | `string` | `auto` | Set type of progress output (`auto`, `plain`, `tty`). Use plain to show container output |
|
||||||
| [`--provenance`](#provenance) | `string` | | Shorthand for `--attest=type=provenance` |
|
| [`--provenance`](#provenance) | `string` | | Shorthand for `--attest=type=provenance` |
|
||||||
| `--pull` | | | Always attempt to pull all referenced images |
|
| `--pull` | | | Always attempt to pull all referenced images |
|
||||||
|
@ -20,7 +20,9 @@ Start a build
|
|||||||
| `--builder` | `string` | | Override the configured builder instance |
|
| `--builder` | `string` | | Override the configured builder instance |
|
||||||
| `--cache-from` | `stringArray` | | External cache sources (e.g., `user/app:cache`, `type=local,src=path/to/dir`) |
|
| `--cache-from` | `stringArray` | | External cache sources (e.g., `user/app:cache`, `type=local,src=path/to/dir`) |
|
||||||
| `--cache-to` | `stringArray` | | Cache export destinations (e.g., `user/app:cache`, `type=local,dest=path/to/dir`) |
|
| `--cache-to` | `stringArray` | | Cache export destinations (e.g., `user/app:cache`, `type=local,dest=path/to/dir`) |
|
||||||
|
| `--call` | `string` | `build` | Set method for evaluating build (`check`, `outline`, `targets`) |
|
||||||
| [`--cgroup-parent`](https://docs.docker.com/reference/cli/docker/image/build/#cgroup-parent) | `string` | | Set the parent cgroup for the `RUN` instructions during build |
|
| [`--cgroup-parent`](https://docs.docker.com/reference/cli/docker/image/build/#cgroup-parent) | `string` | | Set the parent cgroup for the `RUN` instructions during build |
|
||||||
|
| `--check` | | | Shorthand for `--call=check` |
|
||||||
| `--detach` | | | Detach buildx server (supported only on linux) (EXPERIMENTAL) |
|
| `--detach` | | | Detach buildx server (supported only on linux) (EXPERIMENTAL) |
|
||||||
| [`-f`](https://docs.docker.com/reference/cli/docker/image/build/#file), [`--file`](https://docs.docker.com/reference/cli/docker/image/build/#file) | `string` | | Name of the Dockerfile (default: `PATH/Dockerfile`) |
|
| [`-f`](https://docs.docker.com/reference/cli/docker/image/build/#file), [`--file`](https://docs.docker.com/reference/cli/docker/image/build/#file) | `string` | | Name of the Dockerfile (default: `PATH/Dockerfile`) |
|
||||||
| `--iidfile` | `string` | | Write the image ID to a file |
|
| `--iidfile` | `string` | | Write the image ID to a file |
|
||||||
@ -32,7 +34,6 @@ Start a build
|
|||||||
| `--no-cache-filter` | `stringArray` | | Do not cache specified stages |
|
| `--no-cache-filter` | `stringArray` | | Do not cache specified stages |
|
||||||
| `-o`, `--output` | `stringArray` | | Output destination (format: `type=local,dest=path`) |
|
| `-o`, `--output` | `stringArray` | | Output destination (format: `type=local,dest=path`) |
|
||||||
| `--platform` | `stringArray` | | Set target platform for build |
|
| `--platform` | `stringArray` | | Set target platform for build |
|
||||||
| `--print` | `string` | | Print result of information request (e.g., outline, targets) (EXPERIMENTAL) |
|
|
||||||
| `--progress` | `string` | `auto` | Set type of progress output (`auto`, `plain`, `tty`). Use plain to show container output |
|
| `--progress` | `string` | `auto` | Set type of progress output (`auto`, `plain`, `tty`). Use plain to show container output |
|
||||||
| `--provenance` | `string` | | Shorthand for `--attest=type=provenance` |
|
| `--provenance` | `string` | | Shorthand for `--attest=type=provenance` |
|
||||||
| `--pull` | | | Always attempt to pull all referenced images |
|
| `--pull` | | | Always attempt to pull all referenced images |
|
||||||
|
@ -9,10 +9,13 @@ import (
|
|||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const defaultPrintFunc = "build"
|
||||||
|
|
||||||
func ParsePrintFunc(str string) (*controllerapi.PrintFunc, error) {
|
func ParsePrintFunc(str string) (*controllerapi.PrintFunc, error) {
|
||||||
if str == "" {
|
if str == "" {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
csvReader := csv.NewReader(strings.NewReader(str))
|
csvReader := csv.NewReader(strings.NewReader(str))
|
||||||
fields, err := csvReader.Read()
|
fields, err := csvReader.Read()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -41,5 +44,17 @@ func ParsePrintFunc(str string) (*controllerapi.PrintFunc, error) {
|
|||||||
f.Name = field
|
f.Name = field
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// "check" has been added as an alias for "lint",
|
||||||
|
// in order to maintain backwards compatibility
|
||||||
|
// we need to convert it.
|
||||||
|
if f.Name == "check" {
|
||||||
|
f.Name = "lint"
|
||||||
|
}
|
||||||
|
|
||||||
|
if f.Name == defaultPrintFunc {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
return f, nil
|
return f, nil
|
||||||
}
|
}
|
||||||
|
11
util/cobrautil/boolfunc.go
Normal file
11
util/cobrautil/boolfunc.go
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
package cobrautil
|
||||||
|
|
||||||
|
type BoolFuncValue func(string) error
|
||||||
|
|
||||||
|
func (f BoolFuncValue) Set(s string) error { return f(s) }
|
||||||
|
|
||||||
|
func (f BoolFuncValue) String() string { return "" }
|
||||||
|
|
||||||
|
func (f BoolFuncValue) Type() string { return "bool" }
|
||||||
|
|
||||||
|
func (f BoolFuncValue) IsBoolFlag() bool { return true }
|
Loading…
x
Reference in New Issue
Block a user