Make use of existing modules and functions in order to output the merged configs. Added skip interpolation flag of variables, so that you can pipe the output back to stack deploy without much hassle. Signed-off-by: Stoica-Marcu Floris-Andrei <floris.sm@gmail.com> Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
44 lines
1.1 KiB
Go
44 lines
1.1 KiB
Go
package stack
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/docker/cli/cli"
|
|
"github.com/docker/cli/cli/command"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
// NewStackCommand returns a cobra command for `stack` subcommands
|
|
func NewStackCommand(dockerCli command.Cli) *cobra.Command {
|
|
cmd := &cobra.Command{
|
|
Use: "stack [OPTIONS]",
|
|
Short: "Manage Docker stacks",
|
|
Args: cli.NoArgs,
|
|
RunE: command.ShowHelp(dockerCli.Err()),
|
|
Annotations: map[string]string{
|
|
"version": "1.25",
|
|
},
|
|
}
|
|
defaultHelpFunc := cmd.HelpFunc()
|
|
cmd.SetHelpFunc(func(c *cobra.Command, args []string) {
|
|
if err := cmd.Root().PersistentPreRunE(c, args); err != nil {
|
|
fmt.Fprintln(dockerCli.Err(), err)
|
|
return
|
|
}
|
|
defaultHelpFunc(c, args)
|
|
})
|
|
cmd.AddCommand(
|
|
newDeployCommand(dockerCli),
|
|
newListCommand(dockerCli),
|
|
newPsCommand(dockerCli),
|
|
newRemoveCommand(dockerCli),
|
|
newServicesCommand(dockerCli),
|
|
newConfigCommand(dockerCli),
|
|
)
|
|
flags := cmd.PersistentFlags()
|
|
flags.String("orchestrator", "", "Orchestrator to use (swarm|all)")
|
|
flags.SetAnnotation("orchestrator", "deprecated", nil)
|
|
flags.MarkDeprecated("orchestrator", "option will be ignored")
|
|
return cmd
|
|
}
|