Skip to content

Commit

Permalink
Merge pull request #1662 from rsteube/docker-v23.0.0
Browse files Browse the repository at this point in the history
docker: updates from v23.0.0
  • Loading branch information
rsteube authored Apr 13, 2023
2 parents cad0b86 + 8df59f0 commit 457d926
Show file tree
Hide file tree
Showing 162 changed files with 875 additions and 475 deletions.
25 changes: 25 additions & 0 deletions completers/docker_completer/cmd/build.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bridge/pkg/actions/bridge"
"github.com/spf13/cobra"
)

var buildCmd = &cobra.Command{
Use: "build [OPTIONS] PATH | URL | -",
Short: "Build an image from a Dockerfile",
Run: func(cmd *cobra.Command, args []string) {},
GroupID: "common",
DisableFlagParsing: true,
}

func init() {
carapace.Gen(buildCmd).Standalone()

rootCmd.AddCommand(buildCmd)

carapace.Gen(buildCmd).PositionalAnyCompletion(
bridge.ActionCarapaceBin("docker", "buildx", "build"),
)
}
19 changes: 13 additions & 6 deletions completers/docker_completer/cmd/builder_build.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ var builder_buildCmd = &cobra.Command{

func init() {
carapace.Gen(builder_buildCmd).Standalone()
builder_buildCmd.Flags().String("add-host", "", "Add a custom host-to-IP mapping (host:ip)")

builder_buildCmd.Flags().String("add-host", "", "Add a custom host-to-IP mapping (\"host:ip\")")
builder_buildCmd.Flags().String("build-arg", "", "Set build-time variables")
builder_buildCmd.Flags().StringSlice("cache-from", []string{}, "Images to consider as cache sources")
builder_buildCmd.Flags().String("cgroup-parent", "", "Optional parent cgroup for the container")
Expand All @@ -24,24 +25,30 @@ func init() {
builder_buildCmd.Flags().String("cpuset-cpus", "", "CPUs in which to allow execution (0-3, 0,1)")
builder_buildCmd.Flags().String("cpuset-mems", "", "MEMs in which to allow execution (0-3, 0,1)")
builder_buildCmd.Flags().Bool("disable-content-trust", true, "Skip image verification")
builder_buildCmd.Flags().StringP("file", "f", "", "Name of the Dockerfile (Default is 'PATH/Dockerfile')")
builder_buildCmd.Flags().StringP("file", "f", "", "Name of the Dockerfile (Default is \"PATH/Dockerfile\")")
builder_buildCmd.Flags().Bool("force-rm", false, "Always remove intermediate containers")
builder_buildCmd.Flags().String("iidfile", "", "Write the image ID to the file")
builder_buildCmd.Flags().String("isolation", "", "Container isolation technology")
builder_buildCmd.Flags().String("label", "", "Set metadata for an image")
builder_buildCmd.Flags().IntP("memory", "m", 0, "Memory limit")
builder_buildCmd.Flags().Int("memory-swap", 0, "Swap limit equal to memory plus swap: '-1' to enable unlimited swap")
builder_buildCmd.Flags().StringP("memory", "m", "", "Memory limit")
builder_buildCmd.Flags().String("memory-swap", "", "Swap limit equal to memory plus swap: -1 to enable unlimited swap")
builder_buildCmd.Flags().String("network", "default", "Set the networking mode for the RUN instructions during build")
builder_buildCmd.Flags().Bool("no-cache", false, "Do not use cache when building the image")
builder_buildCmd.Flags().String("platform", "", "Set platform if server is multi-platform capable")
builder_buildCmd.Flags().Bool("pull", false, "Always attempt to pull a newer version of the image")
builder_buildCmd.Flags().BoolP("quiet", "q", false, "Suppress the build output and print image ID on success")
builder_buildCmd.Flags().Bool("rm", true, "Remove intermediate containers after a successful build")
builder_buildCmd.Flags().StringSlice("security-opt", []string{}, "Security options")
builder_buildCmd.Flags().Int("shm-size", 0, "Size of /dev/shm")
builder_buildCmd.Flags().String("shm-size", "", "Size of \"/dev/shm\"")
builder_buildCmd.Flags().Bool("squash", false, "Squash newly built layers into a single new layer")
builder_buildCmd.Flags().StringP("tag", "t", "", "Name and optionally a tag in the 'name:tag' format")
builder_buildCmd.Flags().StringP("tag", "t", "", "Name and optionally a tag in the \"name:tag\" format")
builder_buildCmd.Flags().String("target", "", "Set the target build stage to build.")
builder_buildCmd.Flags().String("ulimit", "", "Ulimit options")
builderCmd.AddCommand(builder_buildCmd)

// TODO flag completion

carapace.Gen(builder_buildCmd).PositionalCompletion(
carapace.ActionFiles(),
)
}
5 changes: 3 additions & 2 deletions completers/docker_completer/cmd/builder_prune.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ var builder_pruneCmd = &cobra.Command{

func init() {
carapace.Gen(builder_pruneCmd).Standalone()

builder_pruneCmd.Flags().BoolP("all", "a", false, "Remove all unused build cache, not just dangling ones")
builder_pruneCmd.Flags().String("filter", "", "Provide filter values (e.g. 'until=24h')")
builder_pruneCmd.Flags().String("filter", "", "Provide filter values (e.g. \"until=24h\")")
builder_pruneCmd.Flags().BoolP("force", "f", false, "Do not prompt for confirmation")
builder_pruneCmd.Flags().Int("keep-storage", 0, "Amount of disk space to keep for cache")
builder_pruneCmd.Flags().String("keep-storage", "", "Amount of disk space to keep for cache")
builderCmd.AddCommand(builder_pruneCmd)
}
1 change: 1 addition & 0 deletions completers/docker_completer/cmd/checkpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ var checkpointCmd = &cobra.Command{

func init() {
carapace.Gen(checkpointCmd).Standalone()

rootCmd.AddCommand(checkpointCmd)
}
1 change: 1 addition & 0 deletions completers/docker_completer/cmd/checkpoint_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ var checkpoint_createCmd = &cobra.Command{

func init() {
carapace.Gen(checkpoint_createCmd).Standalone()

checkpoint_createCmd.Flags().String("checkpoint-dir", "", "Use a custom checkpoint storage directory")
checkpoint_createCmd.Flags().Bool("leave-running", false, "Leave the container running after checkpoint")
checkpointCmd.AddCommand(checkpoint_createCmd)
Expand Down
1 change: 1 addition & 0 deletions completers/docker_completer/cmd/checkpoint_ls.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ var checkpoint_lsCmd = &cobra.Command{

func init() {
carapace.Gen(checkpoint_lsCmd).Standalone()

checkpoint_lsCmd.Flags().String("checkpoint-dir", "", "Use a custom checkpoint storage directory")
checkpointCmd.AddCommand(checkpoint_lsCmd)

Expand Down
1 change: 1 addition & 0 deletions completers/docker_completer/cmd/checkpoint_rm.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ var checkpoint_rmCmd = &cobra.Command{

func init() {
carapace.Gen(checkpoint_rmCmd).Standalone()

checkpoint_rmCmd.Flags().String("checkpoint-dir", "", "Use a custom checkpoint storage directory")
checkpointCmd.AddCommand(checkpoint_rmCmd)

Expand Down
3 changes: 2 additions & 1 deletion completers/docker_completer/cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ import (
var configCmd = &cobra.Command{
Use: "config",
Short: "Manage Swarm configs",
GroupID: "management",
GroupID: "swarm",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(configCmd).Standalone()

rootCmd.AddCommand(configCmd)
}
1 change: 1 addition & 0 deletions completers/docker_completer/cmd/config_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ var config_createCmd = &cobra.Command{

func init() {
carapace.Gen(config_createCmd).Standalone()

config_createCmd.Flags().StringP("label", "l", "", "Config labels")
config_createCmd.Flags().String("template-driver", "", "Template driver")
configCmd.AddCommand(config_createCmd)
Expand Down
1 change: 1 addition & 0 deletions completers/docker_completer/cmd/config_inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ var config_inspectCmd = &cobra.Command{

func init() {
carapace.Gen(config_inspectCmd).Standalone()

config_inspectCmd.Flags().StringP("format", "f", "", "Format output using a custom template:")
config_inspectCmd.Flags().Bool("pretty", false, "Print the information in a human friendly format")
configCmd.AddCommand(config_inspectCmd)
Expand Down
1 change: 1 addition & 0 deletions completers/docker_completer/cmd/config_ls.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ var config_lsCmd = &cobra.Command{

func init() {
carapace.Gen(config_lsCmd).Standalone()

config_lsCmd.Flags().StringP("filter", "f", "", "Filter output based on conditions provided")
config_lsCmd.Flags().String("format", "", "Format output using a custom template:")
config_lsCmd.Flags().BoolP("quiet", "q", false, "Only display IDs")
Expand Down
1 change: 1 addition & 0 deletions completers/docker_completer/cmd/config_rm.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ var config_rmCmd = &cobra.Command{

func init() {
carapace.Gen(config_rmCmd).Standalone()

configCmd.AddCommand(config_rmCmd)

carapace.Gen(config_rmCmd).PositionalAnyCompletion(docker.ActionConfigs())
Expand Down
1 change: 1 addition & 0 deletions completers/docker_completer/cmd/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ var containerCmd = &cobra.Command{

func init() {
carapace.Gen(containerCmd).Standalone()

rootCmd.AddCommand(containerCmd)
}
15 changes: 7 additions & 8 deletions completers/docker_completer/cmd/container_attach.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,17 @@ var container_attachCmd = &cobra.Command{

func init() {
carapace.Gen(container_attachCmd).Standalone()

container_attachCmd.Flags().String("detach-keys", "", "Override the key sequence for detaching a container")
container_attachCmd.Flags().Bool("no-stdin", false, "Do not attach STDIN")
container_attachCmd.Flags().Bool("sig-proxy", true, "Proxy all received signals to the process")
containerCmd.AddCommand(container_attachCmd)

rootAlias(container_attachCmd, func(cmd *cobra.Command, isAlias bool) {
carapace.Gen(cmd).FlagCompletion(carapace.ActionMap{
"detach-keys": docker.ActionDetachKeys(),
})

carapace.Gen(cmd).PositionalCompletion(
docker.ActionContainers(),
)
carapace.Gen(container_attachCmd).FlagCompletion(carapace.ActionMap{
"detach-keys": docker.ActionDetachKeys(),
})

carapace.Gen(container_attachCmd).PositionalCompletion(
docker.ActionContainers(),
)
}
17 changes: 8 additions & 9 deletions completers/docker_completer/cmd/container_commit.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,19 @@ var container_commitCmd = &cobra.Command{

func init() {
carapace.Gen(container_commitCmd).Standalone()

container_commitCmd.Flags().StringP("author", "a", "", "Author (e.g., \"John Hannibal Smith <hannibal@a-team.com>\")")
container_commitCmd.Flags().StringP("change", "c", "", "Apply Dockerfile instruction to the created image")
container_commitCmd.Flags().StringP("message", "m", "", "Commit message")
container_commitCmd.Flags().BoolP("pause", "p", true, "Pause container during commit")
containerCmd.AddCommand(container_commitCmd)

rootAlias(container_commitCmd, func(cmd *cobra.Command, isAlias bool) {
carapace.Gen(cmd).FlagCompletion(carapace.ActionMap{
"change": carapace.ActionFiles(),
})

carapace.Gen(cmd).PositionalCompletion(
docker.ActionContainers(),
docker.ActionRepositoryTags(),
)
carapace.Gen(container_commitCmd).FlagCompletion(carapace.ActionMap{
"change": carapace.ActionFiles(),
})

carapace.Gen(container_commitCmd).PositionalCompletion(
docker.ActionContainers(),
docker.ActionRepositoryTags(),
)
}
29 changes: 14 additions & 15 deletions completers/docker_completer/cmd/container_cp.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,24 @@ var container_cpCmd = &cobra.Command{

func init() {
carapace.Gen(container_cpCmd).Standalone()

container_cpCmd.Flags().BoolP("archive", "a", false, "Archive mode (copy all uid/gid information)")
container_cpCmd.Flags().BoolP("follow-link", "L", false, "Always follow symbol link in SRC_PATH")
container_cpCmd.Flags().BoolP("quiet", "q", false, "Suppress progress output during copy. Progress output is automatically suppressed if no terminal is attached")
containerCmd.AddCommand(container_cpCmd)

rootAlias(container_cpCmd, func(cmd *cobra.Command, isAlias bool) {
carapace.Gen(cmd).PositionalCompletion(
carapace.ActionCallback(func(c carapace.Context) carapace.Action {
if util.HasPathPrefix(c.Value) {
return carapace.ActionFiles()
}
return docker.ActionContainerPath()
}),
carapace.ActionCallback(func(c carapace.Context) carapace.Action {
if util.HasPathPrefix(c.Args[0]) {
return docker.ActionContainerPath()
}
carapace.Gen(container_cpCmd).PositionalCompletion(
carapace.ActionCallback(func(c carapace.Context) carapace.Action {
if util.HasPathPrefix(c.Value) {
return carapace.ActionFiles()
}),
)
})
}
return docker.ActionContainerPath()
}),
carapace.ActionCallback(func(c carapace.Context) carapace.Action {
if util.HasPathPrefix(c.Args[0]) {
return docker.ActionContainerPath()
}
return carapace.ActionFiles()
}),
)
}
61 changes: 31 additions & 30 deletions completers/docker_completer/cmd/container_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ var container_createCmd = &cobra.Command{

func init() {
carapace.Gen(container_createCmd).Standalone()

container_createCmd.Flags().String("add-host", "", "Add a custom host-to-IP mapping (host:ip)")
container_createCmd.Flags().StringP("attach", "a", "", "Attach to STDIN, STDOUT or STDERR")
container_createCmd.Flags().Uint16("blkio-weight", 0, "Block IO (relative weight), between 10 and 1000, or 0 to disable (default 0)")
Expand All @@ -31,7 +32,7 @@ func init() {
container_createCmd.Flags().Int64("cpu-rt-period", 0, "Limit CPU real-time period in microseconds")
container_createCmd.Flags().Int64("cpu-rt-runtime", 0, "Limit CPU real-time runtime in microseconds")
container_createCmd.Flags().Int64P("cpu-shares", "c", 0, "CPU shares (relative weight)")
container_createCmd.Flags().Int("cpus", 0, "Number of CPUs")
container_createCmd.Flags().String("cpus", "", "Number of CPUs")
container_createCmd.Flags().String("cpuset-cpus", "", "CPUs in which to allow execution (0-3, 0,1)")
container_createCmd.Flags().String("cpuset-mems", "", "MEMs in which to allow execution (0-3, 0,1)")
container_createCmd.Flags().String("device", "", "Add a host device to the container")
Expand Down Expand Up @@ -61,26 +62,28 @@ func init() {
container_createCmd.Flags().StringP("hostname", "h", "", "Container host name")
container_createCmd.Flags().Bool("init", false, "Run an init inside the container that forwards signals and reaps processes")
container_createCmd.Flags().BoolP("interactive", "i", false, "Keep STDIN open even if not attached")
container_createCmd.Flags().Int("io-maxbandwidth", 0, "Maximum IO bandwidth limit for the system drive (Windows only)")
container_createCmd.Flags().String("io-maxbandwidth", "", "Maximum IO bandwidth limit for the system drive (Windows only)")
container_createCmd.Flags().Uint64("io-maxiops", 0, "Maximum IOps limit for the system drive (Windows only)")
container_createCmd.Flags().String("ip", "", "IPv4 address (e.g., 172.30.100.104)")
container_createCmd.Flags().String("ip6", "", "IPv6 address (e.g., 2001:db8::33)")
container_createCmd.Flags().String("ipc", "", "IPC mode to use")
container_createCmd.Flags().String("isolation", "", "Container isolation technology")
container_createCmd.Flags().Int("kernel-memory", 0, "Kernel memory limit")
container_createCmd.Flags().String("kernel-memory", "", "Kernel memory limit")
container_createCmd.Flags().StringP("label", "l", "", "Set meta data on a container")
container_createCmd.Flags().String("label-file", "", "Read in a line delimited file of labels")
container_createCmd.Flags().String("link", "", "Add link to another container")
container_createCmd.Flags().String("link-local-ip", "", "Container IPv4/IPv6 link-local addresses")
container_createCmd.Flags().String("log-driver", "", "Logging driver for the container")
container_createCmd.Flags().String("log-opt", "", "Log driver options")
container_createCmd.Flags().String("mac-address", "", "Container MAC address (e.g., 92:d0:c6:0a:29:33)")
container_createCmd.Flags().IntP("memory", "m", 0, "Memory limit")
container_createCmd.Flags().Int("memory-reservation", 0, "Memory soft limit")
container_createCmd.Flags().Int("memory-swap", 0, "Swap limit equal to memory plus swap: '-1' to enable unlimited swap")
container_createCmd.Flags().Int64("memory-swappiness", -1, "Tune container memory swappiness (0 to 100)")
container_createCmd.Flags().StringP("memory", "m", "", "Memory limit")
container_createCmd.Flags().String("memory-reservation", "", "Memory soft limit")
container_createCmd.Flags().String("memory-swap", "", "Swap limit equal to memory plus swap: '-1' to enable unlimited swap")
container_createCmd.Flags().Int64("memory-swappiness", 0, "Tune container memory swappiness (0 to 100)")
container_createCmd.Flags().String("mount", "", "Attach a filesystem mount to the container")
container_createCmd.Flags().String("name", "", "Assign a name to the container")
container_createCmd.Flags().String("net", "", "Connect a container to a network")
container_createCmd.Flags().String("net-alias", "", "Add network-scoped alias for the container")
container_createCmd.Flags().String("network", "", "Connect a container to a network")
container_createCmd.Flags().String("network-alias", "", "Add network-scoped alias for the container")
container_createCmd.Flags().Bool("no-healthcheck", false, "Disable any container-specified HEALTHCHECK")
Expand All @@ -92,14 +95,14 @@ func init() {
container_createCmd.Flags().Bool("privileged", false, "Give extended privileges to this container")
container_createCmd.Flags().StringP("publish", "p", "", "Publish a container's port(s) to the host")
container_createCmd.Flags().BoolP("publish-all", "P", false, "Publish all exposed ports to random ports")
container_createCmd.Flags().String("pull", "missing", "Pull image before creating (\"always\"|\"missing\"|\"never\")")
container_createCmd.Flags().String("pull", "missing", "Pull image before creating (\"always\", \"|missing\", \"never\")")
container_createCmd.Flags().BoolP("quiet", "q", false, "Suppress the pull output")
container_createCmd.Flags().Bool("read-only", false, "Mount the container's root filesystem as read only")
container_createCmd.Flags().String("restart", "no", "Restart policy to apply when a container exits")
container_createCmd.Flags().Bool("rm", false, "Automatically remove the container when it exits")
container_createCmd.Flags().String("runtime", "", "Runtime to use for this container")
container_createCmd.Flags().String("security-opt", "", "Security Options")
container_createCmd.Flags().Int("shm-size", 0, "Size of /dev/shm")
container_createCmd.Flags().String("shm-size", "", "Size of /dev/shm")
container_createCmd.Flags().String("stop-signal", "", "Signal to stop the container")
container_createCmd.Flags().Int("stop-timeout", 0, "Timeout (in seconds) to stop a container")
container_createCmd.Flags().String("storage-opt", "", "Storage driver options for the container")
Expand All @@ -116,26 +119,24 @@ func init() {
container_createCmd.Flags().StringP("workdir", "w", "", "Working directory inside the container")
containerCmd.AddCommand(container_createCmd)

rootAlias(container_createCmd, func(cmd *cobra.Command, isAlias bool) {
carapace.Gen(cmd).FlagCompletion(carapace.ActionMap{
"attach": carapace.ActionValues("STDERR", "STDIN", "STDOUT"),
"blkio-weight": carapace.ActionValues("10", "100", "500", "1000"),
"cidfile": carapace.ActionFiles(),
"cgroupns": carapace.ActionValues("host", "private"),
"cpu-shares": carapace.ActionValues("0", "10", "100", "200", "500", "800", "1000"),
"device": carapace.ActionFiles(),
"env-file": carapace.ActionFiles(),
"group-add": os.ActionGroups(),
"isolation": carapace.ActionValues("default", "hyperv", "process"),
"label-file": carapace.ActionFiles(),
"log-driver": docker.ActionLogDrivers(),
"network": carapace.ActionValues("bridge", "container", "host", "none"),
"pid": carapace.ActionValues("container", "host"),
"user": os.ActionUsers(),
})

carapace.Gen(cmd).PositionalCompletion(
docker.ActionRepositoryTags(),
)
carapace.Gen(container_createCmd).FlagCompletion(carapace.ActionMap{
"attach": carapace.ActionValues("STDERR", "STDIN", "STDOUT"),
"blkio-weight": carapace.ActionValues("10", "100", "500", "1000"),
"cgroupns": carapace.ActionValues("host", "private"),
"cidfile": carapace.ActionFiles(),
"cpu-shares": carapace.ActionValues("0", "10", "100", "200", "500", "800", "1000"),
"device": carapace.ActionFiles(),
"env-file": carapace.ActionFiles(),
"group-add": os.ActionGroups(),
"isolation": carapace.ActionValues("default", "hyperv", "process"),
"label-file": carapace.ActionFiles(),
"log-driver": docker.ActionLogDrivers(),
"network": carapace.ActionValues("bridge", "container", "host", "none"),
"pid": carapace.ActionValues("container", "host"),
"user": os.ActionUsers(),
})

carapace.Gen(container_createCmd).PositionalCompletion(
docker.ActionRepositoryTags(),
)
}
5 changes: 2 additions & 3 deletions completers/docker_completer/cmd/container_diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ var container_diffCmd = &cobra.Command{

func init() {
carapace.Gen(container_diffCmd).Standalone()

containerCmd.AddCommand(container_diffCmd)

rootAlias(container_diffCmd, func(cmd *cobra.Command, isAlias bool) {
carapace.Gen(cmd).PositionalCompletion(docker.ActionContainers())
})
carapace.Gen(container_diffCmd).PositionalCompletion(docker.ActionContainers())
}
Loading

0 comments on commit 457d926

Please sign in to comment.