Skip to content

Commit

Permalink
added docker image subcommand
Browse files Browse the repository at this point in the history
  • Loading branch information
rsteube committed Sep 4, 2020
1 parent 04349a6 commit 420449f
Show file tree
Hide file tree
Showing 13 changed files with 355 additions and 0 deletions.
18 changes: 18 additions & 0 deletions completers/docker_completer/cmd/image.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var imageCmd = &cobra.Command{
Use: "image",
Short: "Manage images",
Run: func(cmd *cobra.Command, args []string) {},
}

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

rootCmd.AddCommand(imageCmd)
}
65 changes: 65 additions & 0 deletions completers/docker_completer/cmd/image_build.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var image_buildCmd = &cobra.Command{
Use: "build",
Short: "Build an image from a Dockerfile",
Run: func(cmd *cobra.Command, args []string) {},
}

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

image_buildCmd.Flags().String("add-host", "", "Add a custom host-to-IP mapping (host:ip)")
image_buildCmd.Flags().String("build-arg", "", "Set build-time variables")
image_buildCmd.Flags().String("cache-from", "", "Images to consider as cache sources")
image_buildCmd.Flags().String("cgroup-parent", "", "Optional parent cgroup for the container")
image_buildCmd.Flags().Bool("compress", false, "Compress the build context using gzip")
image_buildCmd.Flags().String("cpu-period", "", "Limit the CPU CFS (Completely Fair Scheduler) period")
image_buildCmd.Flags().String("cpu-quota", "", "Limit the CPU CFS (Completely Fair Scheduler) quota")
image_buildCmd.Flags().StringP("cpu-shares", "c", "", "CPU shares (relative weight)")
image_buildCmd.Flags().String("cpuset-cpus", "", "CPUs in which to allow execution (0-3, 0,1)")
image_buildCmd.Flags().String("cpuset-mems", "", "MEMs in which to allow execution (0-3, 0,1)")
image_buildCmd.Flags().Bool("disable-content-trust", false, "Skip image verification (default true)")
image_buildCmd.Flags().StringP("file", "f", "", "Name of the Dockerfile (Default is 'PATH/Dockerfile')")
image_buildCmd.Flags().Bool("force-rm", false, "Always remove intermediate containers")
image_buildCmd.Flags().String("iidfile", "", "Write the image ID to the file")
image_buildCmd.Flags().String("isolation", "", "Container isolation technology")
image_buildCmd.Flags().String("label", "", "Set metadata for an image")
image_buildCmd.Flags().StringP("memory", "m", "", "Memory limit")
image_buildCmd.Flags().String("memory-swap", "", "Swap limit equal to memory plus swap: '-1' to enable unlimited swap")
image_buildCmd.Flags().String("network", "", "Set the networking mode for the RUN instructions during build")
image_buildCmd.Flags().Bool("no-cache", false, "Do not use cache when building the image")
image_buildCmd.Flags().StringP("output", "o", "", "Output destination (format: type=local,dest=path)")
image_buildCmd.Flags().String("platform", "", "Set platform if server is multi-platform capable")
image_buildCmd.Flags().String("progress", "", "Set type of progress output (auto, plain, tty). Use plain to")
image_buildCmd.Flags().Bool("pull", false, "Always attempt to pull a newer version of the image")
image_buildCmd.Flags().BoolP("quiet", "q", false, "Suppress the build output and print image ID on success")
image_buildCmd.Flags().Bool("rm", false, "Remove intermediate containers after a successful build")
image_buildCmd.Flags().String("secret", "", "Secret file to expose to the build (only if BuildKit enabled):")
image_buildCmd.Flags().String("security-opt", "", "Security options")
image_buildCmd.Flags().String("shm-size", "", "Size of /dev/shm")
image_buildCmd.Flags().Bool("squash", false, "Squash newly built layers into a single new layer")
image_buildCmd.Flags().String("ssh", "", "SSH agent socket or keys to expose to the build (only if")
image_buildCmd.Flags().Bool("stream", false, "Stream attaches to server to negotiate build context")
image_buildCmd.Flags().StringP("tag", "t", "", "Name and optionally a tag in the 'name:tag' format")
image_buildCmd.Flags().String("target", "", "Set the target build stage to build.")
image_buildCmd.Flags().String("ulimit", "", "Ulimit options (default [])")
imageCmd.AddCommand(image_buildCmd)

carapace.Gen(image_buildCmd).FlagCompletion(carapace.ActionMap{
"file": carapace.ActionFiles(""),
"iidfile": carapace.ActionFiles(""),
"isolation": carapace.ActionValues("default", "hyperv", "process"),
"network": carapace.ActionValues("bridge", "container", "host", "none"),
"progress": carapace.ActionValues("auto", "plain", "tty"),
})

carapace.Gen(image_buildCmd).PositionalCompletion(
carapace.ActionFiles(""),
)
}
27 changes: 27 additions & 0 deletions completers/docker_completer/cmd/image_history.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bin/completers/docker_completer/cmd/action"
"github.com/spf13/cobra"
)

var image_historyCmd = &cobra.Command{
Use: "history",
Short: "Show the history of an image",
Run: func(cmd *cobra.Command, args []string) {},
}

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

image_historyCmd.Flags().String("format", "", "Pretty-print images using a Go template")
image_historyCmd.Flags().BoolP("human", "H", false, "Print sizes and dates in human readable format (default true)")
image_historyCmd.Flags().Bool("no-trunc", false, "Don't truncate output")
image_historyCmd.Flags().BoolP("quiet", "q", false, "Only show numeric IDs")
imageCmd.AddCommand(image_historyCmd)

carapace.Gen(image_historyCmd).PositionalCompletion(
action.ActionRepositoryTags(),
)
}
27 changes: 27 additions & 0 deletions completers/docker_completer/cmd/image_import.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bin/completers/docker_completer/cmd/action"
"github.com/spf13/cobra"
)

var image_importCmd = &cobra.Command{
Use: "import",
Short: "Import the contents from a tarball to create a filesystem image",
Run: func(cmd *cobra.Command, args []string) {},
}

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

image_importCmd.Flags().StringP("change", "c", "", "Apply Dockerfile instruction to the created image")
image_importCmd.Flags().StringP("message", "m", "", "Set commit message for imported image")
image_importCmd.Flags().String("platform", "", "Set platform if server is multi-platform capable")
imageCmd.AddCommand(image_importCmd)

carapace.Gen(image_importCmd).PositionalCompletion(
carapace.ActionFiles(""),
action.ActionRepositoryTags(),
)
}
22 changes: 22 additions & 0 deletions completers/docker_completer/cmd/image_inspect.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bin/completers/docker_completer/cmd/action"
"github.com/spf13/cobra"
)

var image_inspectCmd = &cobra.Command{
Use: "inspect",
Short: "Display detailed information on one or more images",
Run: func(cmd *cobra.Command, args []string) {},
}

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

image_inspectCmd.Flags().StringP("format", "f", "", "Format the output using the given Go template")
imageCmd.AddCommand(image_inspectCmd)

carapace.Gen(image_inspectCmd).PositionalAnyCompletion(action.ActionRepositoryTags())
}
24 changes: 24 additions & 0 deletions completers/docker_completer/cmd/image_load.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var image_loadCmd = &cobra.Command{
Use: "load",
Short: "Load an image from a tar archive or STDIN",
Run: func(cmd *cobra.Command, args []string) {},
}

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

image_loadCmd.Flags().StringP("input", "i", "", "Read from tar archive file, instead of STDIN")
image_loadCmd.Flags().BoolP("quiet", "q", false, "Suppress the load output")
imageCmd.AddCommand(image_loadCmd)

carapace.Gen(image_loadCmd).FlagCompletion(carapace.ActionMap{
"input": carapace.ActionFiles(""),
})
}
29 changes: 29 additions & 0 deletions completers/docker_completer/cmd/image_ls.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bin/completers/docker_completer/cmd/action"
"github.com/spf13/cobra"
)

var image_lsCmd = &cobra.Command{
Use: "ls",
Short: "List image",
Run: func(cmd *cobra.Command, args []string) {},
}

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

image_lsCmd.Flags().BoolP("all", "a", false, "Show all images (default hides intermediate images)")
image_lsCmd.Flags().Bool("digests", false, "Show digests")
image_lsCmd.Flags().StringP("filter", "f", "", "Filter output based on conditions provided")
image_lsCmd.Flags().String("format", "", "Pretty-print images using a Go template")
image_lsCmd.Flags().Bool("no-trunc", false, "Don't truncate output")
image_lsCmd.Flags().BoolP("quiet", "q", false, "Only show numeric IDs")
imageCmd.AddCommand(image_lsCmd)

carapace.Gen(image_lsCmd).PositionalCompletion(
action.ActionRepositoryTags(),
)
}
21 changes: 21 additions & 0 deletions completers/docker_completer/cmd/image_prune.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var image_pruneCmd = &cobra.Command{
Use: "prune",
Short: "Remove unused images",
Run: func(cmd *cobra.Command, args []string) {},
}

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

image_pruneCmd.Flags().BoolP("all", "a", false, "Remove all unused images, not just dangling ones")
image_pruneCmd.Flags().String("filter", "", "Provide filter values (e.g. 'until=<timestamp>')")
image_pruneCmd.Flags().BoolP("force", "f", false, "Do not prompt for confirmation")
imageCmd.AddCommand(image_pruneCmd)
}
25 changes: 25 additions & 0 deletions completers/docker_completer/cmd/image_pull.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-bin/completers/docker_completer/cmd/action"
"github.com/spf13/cobra"
)

var image_pullCmd = &cobra.Command{
Use: "pull",
Short: "Pull an image or a repository from a registry",
Run: func(cmd *cobra.Command, args []string) {},
}

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

image_pullCmd.Flags().BoolP("all-tags", "a", false, "Download all tagged images in the repository")
image_pullCmd.Flags().Bool("disable-content-trust", false, "Skip image verification (default true)")
image_pullCmd.Flags().String("platform", "", "Set platform if server is multi-platform capable")
image_pullCmd.Flags().BoolP("quiet", "q", false, "Suppress verbose output")
imageCmd.AddCommand(image_pullCmd)

carapace.Gen(image_pullCmd).PositionalCompletion(action.ActionRepositoryTags())
}
24 changes: 24 additions & 0 deletions completers/docker_completer/cmd/image_push.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bin/completers/docker_completer/cmd/action"
"github.com/spf13/cobra"
)

var image_pushCmd = &cobra.Command{
Use: "push",
Short: "Push an image or a repository to a registry",
Run: func(cmd *cobra.Command, args []string) {},
}

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

image_pushCmd.Flags().Bool("disable-content-trust", false, "Skip image signing (default true)")
imageCmd.AddCommand(image_pushCmd)

carapace.Gen(image_pushCmd).PositionalCompletion(
action.ActionRepositoryTags(),
)
}
23 changes: 23 additions & 0 deletions completers/docker_completer/cmd/image_rm.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bin/completers/docker_completer/cmd/action"
"github.com/spf13/cobra"
)

var image_rmCmd = &cobra.Command{
Use: "rm",
Short: "Remove one or more images",
Run: func(cmd *cobra.Command, args []string) {},
}

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

image_rmCmd.Flags().BoolP("force", "f", false, "Force removal of the image")
image_rmCmd.Flags().Bool("no-prune", false, "Do not delete untagged parents")
imageCmd.AddCommand(image_rmCmd)

carapace.Gen(image_rmCmd).PositionalAnyCompletion(action.ActionRepositoryTags())
}
26 changes: 26 additions & 0 deletions completers/docker_completer/cmd/image_save.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bin/completers/docker_completer/cmd/action"
"github.com/spf13/cobra"
)

var image_saveCmd = &cobra.Command{
Use: "save",
Short: "Save one or more images to a tar archive (streamed to STDOUT by default)",
Run: func(cmd *cobra.Command, args []string) {},
}

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

image_saveCmd.Flags().StringP("output", "o", "", "Write to a file, instead of STDOUT")
imageCmd.AddCommand(image_saveCmd)

carapace.Gen(image_saveCmd).FlagCompletion(carapace.ActionMap{
"output": carapace.ActionFiles(""),
})

carapace.Gen(image_saveCmd).PositionalAnyCompletion(action.ActionRepositoryTags())
}
24 changes: 24 additions & 0 deletions completers/docker_completer/cmd/image_tag.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bin/completers/docker_completer/cmd/action"
"github.com/spf13/cobra"
)

var image_tagCmd = &cobra.Command{
Use: "tag",
Short: "Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE",
Run: func(cmd *cobra.Command, args []string) {},
}

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

imageCmd.AddCommand(image_tagCmd)

carapace.Gen(image_tagCmd).PositionalCompletion(
action.ActionRepositoryTags(),
action.ActionRepositoryTags(),
)
}

0 comments on commit 420449f

Please sign in to comment.