compose: updates from 2.17

This commit is contained in:
rsteube 2023-02-27 21:39:37 +01:00
parent a41b9bad33
commit 6228dad089
22 changed files with 79 additions and 47 deletions

View File

@ -15,6 +15,7 @@ var buildCmd = &cobra.Command{
func init() {
carapace.Gen(buildCmd).Standalone()
buildCmd.Flags().StringArray("build-arg", []string{}, "Set build-time variables for services.")
buildCmd.Flags().Bool("compress", true, "Compress the build context using gzip. DEPRECATED")
buildCmd.Flags().Bool("force-rm", true, "Always remove intermediate containers. DEPRECATED")
@ -24,6 +25,7 @@ func init() {
buildCmd.Flags().Bool("parallel", true, "Build images in parallel. DEPRECATED")
buildCmd.Flags().String("progress", "auto", "Set type of progress output (auto, tty, plain, quiet)")
buildCmd.Flags().Bool("pull", false, "Always attempt to pull a newer version of the image.")
buildCmd.Flags().Bool("push", false, "Push service images.")
buildCmd.Flags().BoolP("quiet", "q", false, "Don't print anything to STDOUT")
buildCmd.Flags().String("ssh", "", "Set SSH authentications used when building service images. (use 'default' for using your default SSH Agent)")
rootCmd.AddCommand(buildCmd)

View File

@ -0,0 +1,44 @@
package cmd
import (
"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bin/completers/docker-compose_completer/cmd/action"
"github.com/spf13/cobra"
)
var configCmd = &cobra.Command{
Use: "config [OPTIONS] [SERVICE...]",
Short: "Parse, resolve and render compose file in canonical format",
Aliases: []string{"convert"},
Run: func(cmd *cobra.Command, args []string) {},
}
func init() {
carapace.Gen(configCmd).Standalone()
configCmd.Flags().String("format", "yaml", "Format the output. Values: [yaml | json]")
configCmd.Flags().String("hash", "", "Print the service config hash, one per line.")
configCmd.Flags().Bool("images", false, "Print the image names, one per line.")
configCmd.Flags().Bool("no-consistency", false, "Don't check model consistency - warning: may produce invalid Compose output")
configCmd.Flags().Bool("no-interpolate", false, "Don't interpolate environment variables.")
configCmd.Flags().Bool("no-normalize", false, "Don't normalize compose model.")
configCmd.Flags().StringP("output", "o", "", "Save to file (default to stdout)")
configCmd.Flags().Bool("profiles", false, "Print the profile names, one per line.")
configCmd.Flags().BoolP("quiet", "q", false, "Only validate the configuration, don't print anything.")
configCmd.Flags().Bool("resolve-image-digests", false, "Pin image tags to digests.")
configCmd.Flags().Bool("services", false, "Print the service names, one per line.")
configCmd.Flags().Bool("volumes", false, "Print the volume names, one per line.")
rootCmd.AddCommand(configCmd)
carapace.Gen(configCmd).FlagCompletion(carapace.ActionMap{
"format": carapace.ActionValues("yaml", "json"),
"hash": action.ActionServices(configCmd),
"output": carapace.ActionFiles(),
})
carapace.Gen(configCmd).PositionalCompletion(
carapace.ActionCallback(func(c carapace.Context) carapace.Action {
return action.ActionServices(configCmd).Invoke(c).Filter(c.Args).ToA()
}),
)
}

View File

@ -1,43 +0,0 @@
package cmd
import (
"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bin/completers/docker-compose_completer/cmd/action"
"github.com/spf13/cobra"
)
var convertCmd = &cobra.Command{
Use: "convert [OPTIONS] [SERVICE...]",
Short: "Converts the compose file to platform's canonical format",
Aliases: []string{"config"},
Run: func(cmd *cobra.Command, args []string) {},
}
func init() {
carapace.Gen(convertCmd).Standalone()
convertCmd.Flags().String("format", "yaml", "Format the output. Values: [yaml | json]")
convertCmd.Flags().String("hash", "", "Print the service config hash, one per line.")
convertCmd.Flags().Bool("images", false, "Print the image names, one per line.")
convertCmd.Flags().Bool("no-consistency", false, "Don't check model consistency - warning: may produce invalid Compose output")
convertCmd.Flags().Bool("no-interpolate", false, "Don't interpolate environment variables.")
convertCmd.Flags().Bool("no-normalize", false, "Don't normalize compose model.")
convertCmd.Flags().StringP("output", "o", "", "Save to file (default to stdout)")
convertCmd.Flags().Bool("profiles", false, "Print the profile names, one per line.")
convertCmd.Flags().BoolP("quiet", "q", false, "Only validate the configuration, don't print anything.")
convertCmd.Flags().Bool("resolve-image-digests", false, "Pin image tags to digests.")
convertCmd.Flags().Bool("services", false, "Print the service names, one per line.")
convertCmd.Flags().Bool("volumes", false, "Print the volume names, one per line.")
rootCmd.AddCommand(convertCmd)
carapace.Gen(convertCmd).FlagCompletion(carapace.ActionMap{
"format": carapace.ActionValues("yaml", "json"),
"hash": action.ActionServices(convertCmd),
"output": carapace.ActionFiles(),
})
carapace.Gen(convertCmd).PositionalCompletion(
carapace.ActionCallback(func(c carapace.Context) carapace.Action {
return action.ActionServices(convertCmd).Invoke(c).Filter(c.Args).ToA()
}),
)
}

View File

@ -15,6 +15,7 @@ var cpCmd = &cobra.Command{
func init() {
carapace.Gen(cpCmd).Standalone()
cpCmd.Flags().BoolP("archive", "a", false, "Archive mode (copy all uid/gid information)")
cpCmd.Flags().BoolP("follow-link", "L", false, "Always follow symbol link in SRC_PATH")
cpCmd.Flags().Int("index", 0, "Index of the container if there are multiple instances of a service .")

View File

@ -15,11 +15,14 @@ var createCmd = &cobra.Command{
func init() {
carapace.Gen(createCmd).Standalone()
createCmd.Flags().Bool("build", false, "Build images before starting containers.")
createCmd.Flags().Bool("force-recreate", false, "Recreate containers even if their configuration and image haven't changed.")
createCmd.Flags().Bool("no-build", false, "Don't build an image, even if it's missing.")
createCmd.Flags().Bool("no-recreate", false, "If containers already exist, don't recreate them. Incompatible with --force-recreate.")
createCmd.Flags().String("pull", "missing", "Pull image before running (\"always\"|\"missing\"|\"never\")")
createCmd.Flags().Bool("remove-orphans", false, "Remove containers for services not defined in the Compose file.")
createCmd.Flags().StringArray("scale", []string{}, "Scale SERVICE to NUM instances. Overrides the `scale` setting in the Compose file if present.")
rootCmd.AddCommand(createCmd)
carapace.Gen(createCmd).FlagCompletion(carapace.ActionMap{

View File

@ -13,6 +13,7 @@ var downCmd = &cobra.Command{
func init() {
carapace.Gen(downCmd).Standalone()
downCmd.Flags().Bool("remove-orphans", false, "Remove containers for services not defined in the Compose file.")
downCmd.Flags().String("rmi", "", "Remove images used by services. \"local\" remove only images that don't have a custom tag (\"local\"|\"all\")")
downCmd.Flags().IntP("timeout", "t", 10, "Specify a shutdown timeout in seconds")

View File

@ -14,6 +14,7 @@ var eventsCmd = &cobra.Command{
func init() {
carapace.Gen(eventsCmd).Standalone()
eventsCmd.Flags().Bool("json", false, "Output events as a stream of json objects")
rootCmd.AddCommand(eventsCmd)

View File

@ -14,6 +14,7 @@ var execCmd = &cobra.Command{
func init() {
carapace.Gen(execCmd).Standalone()
execCmd.Flags().BoolP("detach", "d", false, "Detached mode: Run command in the background.")
execCmd.Flags().StringArrayP("env", "e", []string{}, "Set environment variables")
execCmd.Flags().Int("index", 1, "index of the container if there are multiple instances of a service [default: 1].")

View File

@ -14,10 +14,15 @@ var imagesCmd = &cobra.Command{
func init() {
carapace.Gen(imagesCmd).Standalone()
imagesCmd.Flags().String("format", "table", "Format the output. Values: [table | json].")
imagesCmd.Flags().BoolP("quiet", "q", false, "Only display IDs")
rootCmd.AddCommand(imagesCmd)
carapace.Gen(imagesCmd).FlagCompletion(carapace.ActionMap{
"format": carapace.ActionValues("table", "json"),
})
carapace.Gen(imagesCmd).PositionalAnyCompletion(
carapace.ActionCallback(func(c carapace.Context) carapace.Action {
return action.ActionServices(imagesCmd).Invoke(c).Filter(c.Args).ToA()

View File

@ -15,6 +15,7 @@ var killCmd = &cobra.Command{
func init() {
carapace.Gen(killCmd).Standalone()
killCmd.Flags().Bool("remove-orphans", false, "Remove containers for services not defined in the Compose file.")
killCmd.Flags().StringP("signal", "s", "SIGKILL", "SIGNAL to send to the container.")
rootCmd.AddCommand(killCmd)

View File

@ -14,11 +14,12 @@ var logsCmd = &cobra.Command{
func init() {
carapace.Gen(logsCmd).Standalone()
logsCmd.Flags().BoolP("follow", "f", false, "Follow log output.")
logsCmd.Flags().Bool("no-color", false, "Produce monochrome output.")
logsCmd.Flags().Bool("no-log-prefix", false, "Don't print prefix in logs.")
logsCmd.Flags().String("since", "", "Show logs since timestamp (e.g. 2013-01-02T13:23:37Z) or relative (e.g. 42m for 42 minutes)")
logsCmd.Flags().String("tail", "all", "Number of lines to show from the end of the logs for each container.")
logsCmd.Flags().StringP("tail", "n", "all", "Number of lines to show from the end of the logs for each container.")
logsCmd.Flags().BoolP("timestamps", "t", false, "Show timestamps.")
logsCmd.Flags().String("until", "", "Show logs before a timestamp (e.g. 2013-01-02T13:23:37Z) or relative (e.g. 42m for 42 minutes)")
rootCmd.AddCommand(logsCmd)

View File

@ -13,6 +13,7 @@ var lsCmd = &cobra.Command{
func init() {
carapace.Gen(lsCmd).Standalone()
lsCmd.Flags().BoolP("all", "a", false, "Show all stopped Compose projects")
lsCmd.Flags().String("filter", "", "Filter output based on conditions provided.")
lsCmd.Flags().String("format", "table", "Format the output. Values: [table | json].")
@ -20,6 +21,6 @@ func init() {
rootCmd.AddCommand(lsCmd)
carapace.Gen(lsCmd).FlagCompletion(carapace.ActionMap{
"format": carapace.ActionValues("pretty", "json"),
"format": carapace.ActionValues("table", "json"),
})
}

View File

@ -14,6 +14,7 @@ var portCmd = &cobra.Command{
func init() {
carapace.Gen(portCmd).Standalone()
portCmd.Flags().Int("index", 1, "index of the container if service has multiple replicas")
portCmd.Flags().String("protocol", "tcp", "tcp or udp")
rootCmd.AddCommand(portCmd)

View File

@ -14,6 +14,7 @@ var psCmd = &cobra.Command{
func init() {
carapace.Gen(psCmd).Standalone()
psCmd.Flags().BoolP("all", "a", false, "Show all stopped containers (including those created by the run command)")
psCmd.Flags().String("filter", "", "Filter services by a property (supported filters: status).")
psCmd.Flags().String("format", "table", "Format the output. Values: [table | json]")
@ -23,7 +24,7 @@ func init() {
rootCmd.AddCommand(psCmd)
carapace.Gen(psCmd).FlagCompletion(carapace.ActionMap{
"format": carapace.ActionValues("pretty", "json"),
"format": carapace.ActionValues("table", "json"),
"status": carapace.ActionValues("paused", "restarting", "removing", "running", "dead", "created", "exited"),
})

View File

@ -14,6 +14,7 @@ var pullCmd = &cobra.Command{
func init() {
carapace.Gen(pullCmd).Standalone()
pullCmd.Flags().Bool("ignore-buildable", false, "Ignore images that can be built.")
pullCmd.Flags().Bool("ignore-pull-failures", false, "Pull what it can and ignores images with pull failures.")
pullCmd.Flags().Bool("include-deps", false, "Also pull services declared as dependencies.")

View File

@ -14,6 +14,7 @@ var pushCmd = &cobra.Command{
func init() {
carapace.Gen(pushCmd).Standalone()
pushCmd.Flags().Bool("ignore-push-failures", false, "Push what it can and ignores images with push failures")
pushCmd.Flags().Bool("include-deps", false, "Also push images of services declared as dependencies")
pushCmd.Flags().BoolP("quiet", "q", false, "Push without printing progress information")

View File

@ -14,6 +14,8 @@ var restartCmd = &cobra.Command{
func init() {
carapace.Gen(restartCmd).Standalone()
restartCmd.Flags().Bool("no-deps", false, "Don't restart dependent services.")
restartCmd.Flags().IntP("timeout", "t", 10, "Specify a shutdown timeout in seconds")
rootCmd.AddCommand(restartCmd)

View File

@ -14,6 +14,7 @@ var rmCmd = &cobra.Command{
func init() {
carapace.Gen(rmCmd).Standalone()
rmCmd.Flags().BoolP("all", "a", false, "Deprecated - no effect")
rmCmd.Flags().BoolP("force", "f", false, "Don't ask to confirm removal")
rmCmd.Flags().BoolP("stop", "s", false, "Stop the containers, if required, before removing")

View File

@ -14,6 +14,7 @@ var runCmd = &cobra.Command{
func init() {
carapace.Gen(runCmd).Standalone()
runCmd.Flags().Bool("build", false, "Build image before starting container.")
runCmd.Flags().BoolP("detach", "d", false, "Run container in background and print container ID")
runCmd.Flags().String("entrypoint", "", "Override the entrypoint of the image")
@ -25,6 +26,7 @@ func init() {
runCmd.Flags().Bool("no-deps", false, "Don't start linked services.")
runCmd.Flags().StringArrayP("publish", "p", []string{}, "Publish a container's port(s) to the host.")
runCmd.Flags().Bool("quiet-pull", false, "Pull without printing progress information.")
runCmd.Flags().Bool("remove-orphans", false, "Remove containers for services not defined in the Compose file.")
runCmd.Flags().Bool("rm", false, "Automatically remove the container when it exits")
runCmd.Flags().Bool("service-ports", false, "Run command with the service's ports enabled and mapped to the host.")
runCmd.Flags().BoolP("tty", "t", true, "Allocate a pseudo-TTY.")

View File

@ -14,6 +14,7 @@ var stopCmd = &cobra.Command{
func init() {
carapace.Gen(stopCmd).Standalone()
stopCmd.Flags().IntP("timeout", "t", 10, "Specify a shutdown timeout in seconds")
rootCmd.AddCommand(stopCmd)

View File

@ -15,6 +15,7 @@ var upCmd = &cobra.Command{
func init() {
carapace.Gen(upCmd).Standalone()
upCmd.Flags().Bool("abort-on-container-exit", false, "Stops all containers if any container was stopped. Incompatible with -d")
upCmd.Flags().Bool("always-recreate-deps", false, "Recreate dependent containers. Incompatible with --no-recreate.")
upCmd.Flags().StringArray("attach", []string{}, "Attach to service output.")
@ -35,9 +36,11 @@ func init() {
upCmd.Flags().Bool("remove-orphans", false, "Remove containers for services not defined in the Compose file.")
upCmd.Flags().BoolP("renew-anon-volumes", "V", false, "Recreate anonymous volumes instead of retrieving data from the previous containers.")
upCmd.Flags().StringArray("scale", []string{}, "Scale SERVICE to NUM instances. Overrides the `scale` setting in the Compose file if present.")
upCmd.Flags().IntP("timeout", "t", 10, "Use this timeout in seconds for container shutdown when attached or when containers are already running.")
upCmd.Flags().Bool("timestamps", false, "Show timestamps.")
upCmd.Flags().Bool("wait", false, "Wait for services to be running|healthy. Implies detached mode.")
upCmd.Flags().Int("wait-timeout", 0, "timeout waiting for application to be running|healthy.")
upCmd.Flags().IntP("waitTimeout", "t", 10, "Use this waitTimeout in seconds for container shutdown when attached or when containers are already running.")
rootCmd.AddCommand(upCmd)
carapace.Gen(upCmd).FlagCompletion(carapace.ActionMap{

View File

@ -13,6 +13,7 @@ var versionCmd = &cobra.Command{
func init() {
carapace.Gen(versionCmd).Standalone()
versionCmd.Flags().StringP("format", "f", "", "Format the output. Values: [pretty | json]. (Default: pretty)")
versionCmd.Flags().Bool("short", false, "Shows only Compose's version number.")
rootCmd.AddCommand(versionCmd)