mirror of https://github.com/docker/buildx.git
Merge pull request #2660 from tonistiigi/debug-flag-cmds
commands: add debug as persistent flag
This commit is contained in:
commit
dc7f679ab1
|
@ -21,6 +21,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewRootCmd(name string, isPlugin bool, dockerCli command.Cli) *cobra.Command {
|
func NewRootCmd(name string, isPlugin bool, dockerCli command.Cli) *cobra.Command {
|
||||||
|
var opt rootOptions
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Short: "Docker Buildx",
|
Short: "Docker Buildx",
|
||||||
Long: `Extended build capabilities with BuildKit`,
|
Long: `Extended build capabilities with BuildKit`,
|
||||||
|
@ -32,6 +33,10 @@ func NewRootCmd(name string, isPlugin bool, dockerCli command.Cli) *cobra.Comman
|
||||||
HiddenDefaultCmd: true,
|
HiddenDefaultCmd: true,
|
||||||
},
|
},
|
||||||
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
|
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
|
||||||
|
if opt.debug {
|
||||||
|
debug.Enable()
|
||||||
|
}
|
||||||
|
|
||||||
cmd.SetContext(appcontext.Context())
|
cmd.SetContext(appcontext.Context())
|
||||||
if !isPlugin {
|
if !isPlugin {
|
||||||
return nil
|
return nil
|
||||||
|
@ -47,11 +52,6 @@ func NewRootCmd(name string, isPlugin bool, dockerCli command.Cli) *cobra.Comman
|
||||||
cmd.TraverseChildren = true
|
cmd.TraverseChildren = true
|
||||||
cmd.DisableFlagsInUseLine = true
|
cmd.DisableFlagsInUseLine = true
|
||||||
cli.DisableFlagsInUseLine(cmd)
|
cli.DisableFlagsInUseLine(cmd)
|
||||||
|
|
||||||
// DEBUG=1 should perform the same as --debug at the docker root level
|
|
||||||
if debug.IsEnabled() {
|
|
||||||
debug.Enable()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
logrus.SetFormatter(&logutil.Formatter{})
|
logrus.SetFormatter(&logutil.Formatter{})
|
||||||
|
@ -68,16 +68,16 @@ func NewRootCmd(name string, isPlugin bool, dockerCli command.Cli) *cobra.Comman
|
||||||
cmd.SetHelpTemplate(cmd.HelpTemplate() + "\nExperimental commands and flags are hidden. Set BUILDX_EXPERIMENTAL=1 to show them.\n")
|
cmd.SetHelpTemplate(cmd.HelpTemplate() + "\nExperimental commands and flags are hidden. Set BUILDX_EXPERIMENTAL=1 to show them.\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
addCommands(cmd, dockerCli)
|
addCommands(cmd, &opt, dockerCli)
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
type rootOptions struct {
|
type rootOptions struct {
|
||||||
builder string
|
builder string
|
||||||
|
debug bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func addCommands(cmd *cobra.Command, dockerCli command.Cli) {
|
func addCommands(cmd *cobra.Command, opts *rootOptions, dockerCli command.Cli) {
|
||||||
opts := &rootOptions{}
|
|
||||||
rootFlags(opts, cmd.PersistentFlags())
|
rootFlags(opts, cmd.PersistentFlags())
|
||||||
|
|
||||||
cmd.AddCommand(
|
cmd.AddCommand(
|
||||||
|
@ -112,4 +112,5 @@ func addCommands(cmd *cobra.Command, dockerCli command.Cli) {
|
||||||
|
|
||||||
func rootFlags(options *rootOptions, flags *pflag.FlagSet) {
|
func rootFlags(options *rootOptions, flags *pflag.FlagSet) {
|
||||||
flags.StringVar(&options.builder, "builder", os.Getenv("BUILDX_BUILDER"), "Override the configured builder instance")
|
flags.StringVar(&options.builder, "builder", os.Getenv("BUILDX_BUILDER"), "Override the configured builder instance")
|
||||||
|
flags.BoolVarP(&options.debug, "debug", "D", debug.IsEnabled(), "Enable debug logging")
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,7 @@ Extended build capabilities with BuildKit
|
||||||
| Name | Type | Default | Description |
|
| Name | Type | Default | Description |
|
||||||
|:------------------------|:---------|:--------|:-----------------------------------------|
|
|:------------------------|:---------|:--------|:-----------------------------------------|
|
||||||
| [`--builder`](#builder) | `string` | | Override the configured builder instance |
|
| [`--builder`](#builder) | `string` | | Override the configured builder instance |
|
||||||
|
| `-D`, `--debug` | `bool` | | Enable debug logging |
|
||||||
|
|
||||||
|
|
||||||
<!---MARKER_GEN_END-->
|
<!---MARKER_GEN_END-->
|
||||||
|
|
|
@ -18,6 +18,7 @@ Build from a file
|
||||||
| [`--builder`](#builder) | `string` | | Override the configured builder instance |
|
| [`--builder`](#builder) | `string` | | Override the configured builder instance |
|
||||||
| [`--call`](#call) | `string` | `build` | Set method for evaluating build (`check`, `outline`, `targets`) |
|
| [`--call`](#call) | `string` | `build` | Set method for evaluating build (`check`, `outline`, `targets`) |
|
||||||
| [`--check`](#check) | `bool` | | Shorthand for `--call=check` |
|
| [`--check`](#check) | `bool` | | Shorthand for `--call=check` |
|
||||||
|
| `-D`, `--debug` | `bool` | | Enable debug logging |
|
||||||
| [`-f`](#file), [`--file`](#file) | `stringArray` | | Build definition file |
|
| [`-f`](#file), [`--file`](#file) | `stringArray` | | Build definition file |
|
||||||
| `--load` | `bool` | | Shorthand for `--set=*.output=type=docker` |
|
| `--load` | `bool` | | Shorthand for `--set=*.output=type=docker` |
|
||||||
| [`--metadata-file`](#metadata-file) | `string` | | Write build result metadata to a file |
|
| [`--metadata-file`](#metadata-file) | `string` | | Write build result metadata to a file |
|
||||||
|
|
|
@ -27,6 +27,7 @@ Start a build
|
||||||
| [`--call`](#call) | `string` | `build` | Set method for evaluating build (`check`, `outline`, `targets`) |
|
| [`--call`](#call) | `string` | `build` | Set method for evaluating build (`check`, `outline`, `targets`) |
|
||||||
| [`--cgroup-parent`](#cgroup-parent) | `string` | | Set the parent cgroup for the `RUN` instructions during build |
|
| [`--cgroup-parent`](#cgroup-parent) | `string` | | Set the parent cgroup for the `RUN` instructions during build |
|
||||||
| [`--check`](#check) | `bool` | | Shorthand for `--call=check` |
|
| [`--check`](#check) | `bool` | | Shorthand for `--call=check` |
|
||||||
|
| `-D`, `--debug` | `bool` | | Enable debug logging |
|
||||||
| `--detach` | `bool` | | Detach buildx server (supported only on linux) (EXPERIMENTAL) |
|
| `--detach` | `bool` | | Detach buildx server (supported only on linux) (EXPERIMENTAL) |
|
||||||
| [`-f`](#file), [`--file`](#file) | `string` | | Name of the Dockerfile (default: `PATH/Dockerfile`) |
|
| [`-f`](#file), [`--file`](#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 |
|
||||||
|
|
|
@ -15,6 +15,7 @@ Create a new builder instance
|
||||||
| `--bootstrap` | `bool` | | Boot builder after creation |
|
| `--bootstrap` | `bool` | | Boot builder after creation |
|
||||||
| [`--buildkitd-config`](#buildkitd-config) | `string` | | BuildKit daemon config file |
|
| [`--buildkitd-config`](#buildkitd-config) | `string` | | BuildKit daemon config file |
|
||||||
| [`--buildkitd-flags`](#buildkitd-flags) | `string` | | BuildKit daemon flags |
|
| [`--buildkitd-flags`](#buildkitd-flags) | `string` | | BuildKit daemon flags |
|
||||||
|
| `-D`, `--debug` | `bool` | | Enable debug logging |
|
||||||
| [`--driver`](#driver) | `string` | | Driver to use (available: `docker-container`, `kubernetes`, `remote`) |
|
| [`--driver`](#driver) | `string` | | Driver to use (available: `docker-container`, `kubernetes`, `remote`) |
|
||||||
| [`--driver-opt`](#driver-opt) | `stringArray` | | Options for the driver |
|
| [`--driver-opt`](#driver-opt) | `stringArray` | | Options for the driver |
|
||||||
| [`--leave`](#leave) | `bool` | | Remove a node from builder instead of changing it |
|
| [`--leave`](#leave) | `bool` | | Remove a node from builder instead of changing it |
|
||||||
|
|
|
@ -15,6 +15,7 @@ Start debugger (EXPERIMENTAL)
|
||||||
| Name | Type | Default | Description |
|
| Name | Type | Default | Description |
|
||||||
|:------------------|:---------|:--------|:--------------------------------------------------------------------------------------------------------------------|
|
|:------------------|:---------|:--------|:--------------------------------------------------------------------------------------------------------------------|
|
||||||
| `--builder` | `string` | | Override the configured builder instance |
|
| `--builder` | `string` | | Override the configured builder instance |
|
||||||
|
| `-D`, `--debug` | `bool` | | Enable debug logging |
|
||||||
| `--detach` | `bool` | `true` | Detach buildx server for the monitor (supported only on linux) (EXPERIMENTAL) |
|
| `--detach` | `bool` | `true` | Detach buildx server for the monitor (supported only on linux) (EXPERIMENTAL) |
|
||||||
| `--invoke` | `string` | | Launch a monitor with executing specified command (EXPERIMENTAL) |
|
| `--invoke` | `string` | | Launch a monitor with executing specified command (EXPERIMENTAL) |
|
||||||
| `--on` | `string` | `error` | When to launch the monitor ([always, error]) (EXPERIMENTAL) |
|
| `--on` | `string` | `error` | When to launch the monitor ([always, error]) (EXPERIMENTAL) |
|
||||||
|
|
|
@ -23,6 +23,7 @@ Start a build
|
||||||
| `--call` | `string` | `build` | Set method for evaluating build (`check`, `outline`, `targets`) |
|
| `--call` | `string` | `build` | Set method for evaluating build (`check`, `outline`, `targets`) |
|
||||||
| `--cgroup-parent` | `string` | | Set the parent cgroup for the `RUN` instructions during build |
|
| `--cgroup-parent` | `string` | | Set the parent cgroup for the `RUN` instructions during build |
|
||||||
| `--check` | `bool` | | Shorthand for `--call=check` |
|
| `--check` | `bool` | | Shorthand for `--call=check` |
|
||||||
|
| `-D`, `--debug` | `bool` | | Enable debug logging |
|
||||||
| `--detach` | `bool` | | Detach buildx server (supported only on linux) (EXPERIMENTAL) |
|
| `--detach` | `bool` | | Detach buildx server (supported only on linux) (EXPERIMENTAL) |
|
||||||
| `-f`, `--file` | `string` | | Name of the Dockerfile (default: `PATH/Dockerfile`) |
|
| `-f`, `--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 |
|
||||||
|
|
|
@ -5,11 +5,12 @@ Proxy current stdio streams to builder instance
|
||||||
|
|
||||||
### Options
|
### Options
|
||||||
|
|
||||||
| Name | Type | Default | Description |
|
| Name | Type | Default | Description |
|
||||||
|:-------------|:---------|:--------|:----------------------------------------------------------------------------------------------------|
|
|:----------------|:---------|:--------|:----------------------------------------------------------------------------------------------------|
|
||||||
| `--builder` | `string` | | Override the configured builder instance |
|
| `--builder` | `string` | | Override the configured builder instance |
|
||||||
| `--platform` | `string` | | Target platform: this is used for node selection |
|
| `-D`, `--debug` | `bool` | | Enable debug logging |
|
||||||
| `--progress` | `string` | `quiet` | Set type of progress output (`auto`, `plain`, `tty`, `rawjson`). Use plain to show container output |
|
| `--platform` | `string` | | Target platform: this is used for node selection |
|
||||||
|
| `--progress` | `string` | `quiet` | Set type of progress output (`auto`, `plain`, `tty`, `rawjson`). Use plain to show container output |
|
||||||
|
|
||||||
|
|
||||||
<!---MARKER_GEN_END-->
|
<!---MARKER_GEN_END-->
|
||||||
|
|
|
@ -12,6 +12,7 @@ Disk usage
|
||||||
| Name | Type | Default | Description |
|
| Name | Type | Default | Description |
|
||||||
|:------------------------|:---------|:--------|:-----------------------------------------|
|
|:------------------------|:---------|:--------|:-----------------------------------------|
|
||||||
| [`--builder`](#builder) | `string` | | Override the configured builder instance |
|
| [`--builder`](#builder) | `string` | | Override the configured builder instance |
|
||||||
|
| `-D`, `--debug` | `bool` | | Enable debug logging |
|
||||||
| `--filter` | `filter` | | Provide filter values |
|
| `--filter` | `filter` | | Provide filter values |
|
||||||
| [`--verbose`](#verbose) | `bool` | | Provide a more verbose output |
|
| [`--verbose`](#verbose) | `bool` | | Provide a more verbose output |
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ Commands to work on images in registry
|
||||||
| Name | Type | Default | Description |
|
| Name | Type | Default | Description |
|
||||||
|:------------------------|:---------|:--------|:-----------------------------------------|
|
|:------------------------|:---------|:--------|:-----------------------------------------|
|
||||||
| [`--builder`](#builder) | `string` | | Override the configured builder instance |
|
| [`--builder`](#builder) | `string` | | Override the configured builder instance |
|
||||||
|
| `-D`, `--debug` | `bool` | | Enable debug logging |
|
||||||
|
|
||||||
|
|
||||||
<!---MARKER_GEN_END-->
|
<!---MARKER_GEN_END-->
|
||||||
|
|
|
@ -14,6 +14,7 @@ Create a new image based on source images
|
||||||
| [`--annotation`](#annotation) | `stringArray` | | Add annotation to the image |
|
| [`--annotation`](#annotation) | `stringArray` | | Add annotation to the image |
|
||||||
| [`--append`](#append) | `bool` | | Append to existing manifest |
|
| [`--append`](#append) | `bool` | | Append to existing manifest |
|
||||||
| [`--builder`](#builder) | `string` | | Override the configured builder instance |
|
| [`--builder`](#builder) | `string` | | Override the configured builder instance |
|
||||||
|
| `-D`, `--debug` | `bool` | | Enable debug logging |
|
||||||
| [`--dry-run`](#dry-run) | `bool` | | Show final image instead of pushing |
|
| [`--dry-run`](#dry-run) | `bool` | | Show final image instead of pushing |
|
||||||
| [`-f`](#file), [`--file`](#file) | `stringArray` | | Read source descriptor from file |
|
| [`-f`](#file), [`--file`](#file) | `stringArray` | | Read source descriptor from file |
|
||||||
| `--prefer-index` | `bool` | `true` | When only a single source is specified, prefer outputting an image index or manifest list instead of performing a carbon copy |
|
| `--prefer-index` | `bool` | `true` | When only a single source is specified, prefer outputting an image index or manifest list instead of performing a carbon copy |
|
||||||
|
|
|
@ -12,6 +12,7 @@ Show details of an image in the registry
|
||||||
| Name | Type | Default | Description |
|
| Name | Type | Default | Description |
|
||||||
|:------------------------|:---------|:----------------|:----------------------------------------------|
|
|:------------------------|:---------|:----------------|:----------------------------------------------|
|
||||||
| [`--builder`](#builder) | `string` | | Override the configured builder instance |
|
| [`--builder`](#builder) | `string` | | Override the configured builder instance |
|
||||||
|
| `-D`, `--debug` | `bool` | | Enable debug logging |
|
||||||
| [`--format`](#format) | `string` | `{{.Manifest}}` | Format the output using the given Go template |
|
| [`--format`](#format) | `string` | `{{.Manifest}}` | Format the output using the given Go template |
|
||||||
| [`--raw`](#raw) | `bool` | | Show original, unformatted JSON manifest |
|
| [`--raw`](#raw) | `bool` | | Show original, unformatted JSON manifest |
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ Inspect current builder instance
|
||||||
|:----------------------------|:---------|:--------|:--------------------------------------------|
|
|:----------------------------|:---------|:--------|:--------------------------------------------|
|
||||||
| [`--bootstrap`](#bootstrap) | `bool` | | Ensure builder has booted before inspecting |
|
| [`--bootstrap`](#bootstrap) | `bool` | | Ensure builder has booted before inspecting |
|
||||||
| [`--builder`](#builder) | `string` | | Override the configured builder instance |
|
| [`--builder`](#builder) | `string` | | Override the configured builder instance |
|
||||||
|
| `-D`, `--debug` | `bool` | | Enable debug logging |
|
||||||
|
|
||||||
|
|
||||||
<!---MARKER_GEN_END-->
|
<!---MARKER_GEN_END-->
|
||||||
|
|
|
@ -9,9 +9,10 @@ List builder instances
|
||||||
|
|
||||||
### Options
|
### Options
|
||||||
|
|
||||||
| Name | Type | Default | Description |
|
| Name | Type | Default | Description |
|
||||||
|:----------------------|:---------|:--------|:------------------|
|
|:----------------------|:---------|:--------|:---------------------|
|
||||||
| [`--format`](#format) | `string` | `table` | Format the output |
|
| `-D`, `--debug` | `bool` | | Enable debug logging |
|
||||||
|
| [`--format`](#format) | `string` | `table` | Format the output |
|
||||||
|
|
||||||
|
|
||||||
<!---MARKER_GEN_END-->
|
<!---MARKER_GEN_END-->
|
||||||
|
|
|
@ -13,6 +13,7 @@ Remove build cache
|
||||||
|:------------------------|:---------|:--------|:------------------------------------------|
|
|:------------------------|:---------|:--------|:------------------------------------------|
|
||||||
| `-a`, `--all` | `bool` | | Include internal/frontend images |
|
| `-a`, `--all` | `bool` | | Include internal/frontend images |
|
||||||
| [`--builder`](#builder) | `string` | | Override the configured builder instance |
|
| [`--builder`](#builder) | `string` | | Override the configured builder instance |
|
||||||
|
| `-D`, `--debug` | `bool` | | Enable debug logging |
|
||||||
| `--filter` | `filter` | | Provide filter values (e.g., `until=24h`) |
|
| `--filter` | `filter` | | Provide filter values (e.g., `until=24h`) |
|
||||||
| `-f`, `--force` | `bool` | | Do not prompt for confirmation |
|
| `-f`, `--force` | `bool` | | Do not prompt for confirmation |
|
||||||
| `--keep-storage` | `bytes` | `0` | Amount of disk space to keep for cache |
|
| `--keep-storage` | `bytes` | `0` | Amount of disk space to keep for cache |
|
||||||
|
|
|
@ -13,6 +13,7 @@ Remove one or more builder instances
|
||||||
|:------------------------------------|:---------|:--------|:-----------------------------------------|
|
|:------------------------------------|:---------|:--------|:-----------------------------------------|
|
||||||
| [`--all-inactive`](#all-inactive) | `bool` | | Remove all inactive builders |
|
| [`--all-inactive`](#all-inactive) | `bool` | | Remove all inactive builders |
|
||||||
| [`--builder`](#builder) | `string` | | Override the configured builder instance |
|
| [`--builder`](#builder) | `string` | | Override the configured builder instance |
|
||||||
|
| `-D`, `--debug` | `bool` | | Enable debug logging |
|
||||||
| [`-f`](#force), [`--force`](#force) | `bool` | | Do not prompt for confirmation |
|
| [`-f`](#force), [`--force`](#force) | `bool` | | Do not prompt for confirmation |
|
||||||
| [`--keep-daemon`](#keep-daemon) | `bool` | | Keep the BuildKit daemon running |
|
| [`--keep-daemon`](#keep-daemon) | `bool` | | Keep the BuildKit daemon running |
|
||||||
| [`--keep-state`](#keep-state) | `bool` | | Keep BuildKit state |
|
| [`--keep-state`](#keep-state) | `bool` | | Keep BuildKit state |
|
||||||
|
|
|
@ -12,6 +12,7 @@ Stop builder instance
|
||||||
| Name | Type | Default | Description |
|
| Name | Type | Default | Description |
|
||||||
|:------------------------|:---------|:--------|:-----------------------------------------|
|
|:------------------------|:---------|:--------|:-----------------------------------------|
|
||||||
| [`--builder`](#builder) | `string` | | Override the configured builder instance |
|
| [`--builder`](#builder) | `string` | | Override the configured builder instance |
|
||||||
|
| `-D`, `--debug` | `bool` | | Enable debug logging |
|
||||||
|
|
||||||
|
|
||||||
<!---MARKER_GEN_END-->
|
<!---MARKER_GEN_END-->
|
||||||
|
|
|
@ -12,6 +12,7 @@ Set the current builder instance
|
||||||
| Name | Type | Default | Description |
|
| Name | Type | Default | Description |
|
||||||
|:------------------------|:---------|:--------|:-------------------------------------------|
|
|:------------------------|:---------|:--------|:-------------------------------------------|
|
||||||
| [`--builder`](#builder) | `string` | | Override the configured builder instance |
|
| [`--builder`](#builder) | `string` | | Override the configured builder instance |
|
||||||
|
| `-D`, `--debug` | `bool` | | Enable debug logging |
|
||||||
| `--default` | `bool` | | Set builder as default for current context |
|
| `--default` | `bool` | | Set builder as default for current context |
|
||||||
| `--global` | `bool` | | Builder persists context changes |
|
| `--global` | `bool` | | Builder persists context changes |
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,12 @@ docker buildx version
|
||||||
<!---MARKER_GEN_START-->
|
<!---MARKER_GEN_START-->
|
||||||
Show buildx version information
|
Show buildx version information
|
||||||
|
|
||||||
|
### Options
|
||||||
|
|
||||||
|
| Name | Type | Default | Description |
|
||||||
|
|:----------------|:-------|:--------|:---------------------|
|
||||||
|
| `-D`, `--debug` | `bool` | | Enable debug logging |
|
||||||
|
|
||||||
|
|
||||||
<!---MARKER_GEN_END-->
|
<!---MARKER_GEN_END-->
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue