main.go 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. package main
  2. import (
  3. "fmt"
  4. "github.com/docker/cli/cli-plugins/manager"
  5. "github.com/docker/cli/cli-plugins/plugin"
  6. "github.com/docker/cli/cli/command"
  7. commands "github.com/docker/ecs-plugin/cmd/commands"
  8. "github.com/spf13/cobra"
  9. )
  10. const version = "0.0.1"
  11. func main() {
  12. plugin.Run(func(dockerCli command.Cli) *cobra.Command {
  13. cmd := NewRootCmd("ecs", dockerCli)
  14. return cmd
  15. }, manager.Metadata{
  16. SchemaVersion: "0.1.0",
  17. Vendor: "Docker Inc.",
  18. Version: version,
  19. Experimental: true,
  20. })
  21. }
  22. // NewRootCmd returns the base root command.
  23. func NewRootCmd(name string, dockerCli command.Cli) *cobra.Command {
  24. var opts commands.ClusterOptions
  25. cmd := &cobra.Command{
  26. Short: "Docker ECS",
  27. Long: `run multi-container applications on Amazon ECS.`,
  28. Use: name,
  29. Annotations: map[string]string{"experimentalCLI": "true"},
  30. }
  31. cmd.AddCommand(
  32. VersionCommand(),
  33. commands.ComposeCommand(&opts),
  34. commands.SecretCommand(&opts),
  35. )
  36. cmd.Flags().StringVarP(&opts.Profile, "profile", "p", "default", "AWS Profile")
  37. cmd.Flags().StringVarP(&opts.Cluster, "cluster", "c", "default", "ECS cluster")
  38. cmd.Flags().StringVarP(&opts.Region, "region", "r", "", "AWS region")
  39. return cmd
  40. }
  41. func VersionCommand() *cobra.Command {
  42. return &cobra.Command{
  43. Use: "version",
  44. Short: "Show version.",
  45. RunE: func(cmd *cobra.Command, args []string) error {
  46. fmt.Printf("Docker ECS plugin %s\n", version)
  47. return nil
  48. },
  49. }
  50. }