From 9e6eefab29ae9533a7d387cc62247a77a9ec07ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20P=C3=A9rez-Aradros=20Herce?= Date: Thu, 30 Jul 2020 11:05:45 +0200 Subject: [PATCH] Move `main.go` to repo root folder (#29) * Move `main.go` to repo root folder This change simplifies go getting this package by moving `main.go` to the root folder. The new command to download this tool will be: ``` go get github.com/elastic/elastic-package ``` This should be the only thing needed by a user that doesn't want to implement changes to this tool --- Makefile | 2 +- README.md | 2 +- cmd/{elastic-package => }/build.go | 2 +- cmd/{elastic-package => }/cluster.go | 2 +- cmd/root.go | 19 +++++++++++++++++++ cmd/{elastic-package => }/testrunner.go | 2 +- cmd/elastic-package/main.go => main.go | 12 ++---------- 7 files changed, 26 insertions(+), 15 deletions(-) rename cmd/{elastic-package => }/build.go (97%) rename cmd/{elastic-package => }/cluster.go (99%) create mode 100644 cmd/root.go rename cmd/{elastic-package => }/testrunner.go (96%) rename cmd/elastic-package/main.go => main.go (51%) diff --git a/Makefile b/Makefile index bc60f0776..f4469b510 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ build: - go get github.com/elastic/elastic-package/cmd/elastic-package + go get github.com/elastic/elastic-package format: gofmt -s -w . diff --git a/README.md b/README.md index e0238f3ce..196ae1771 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ TODO Download and build the `elastic-package` binary: ```bash -go get github.com/elastic/elastic-package/cmd/elastic-package +go get github.com/elastic/elastic-package ``` Change directory to the integration under development diff --git a/cmd/elastic-package/build.go b/cmd/build.go similarity index 97% rename from cmd/elastic-package/build.go rename to cmd/build.go index 425fe111c..5f6441dec 100644 --- a/cmd/elastic-package/build.go +++ b/cmd/build.go @@ -1,4 +1,4 @@ -package main +package cmd import ( "github.com/pkg/errors" diff --git a/cmd/elastic-package/cluster.go b/cmd/cluster.go similarity index 99% rename from cmd/elastic-package/cluster.go rename to cmd/cluster.go index b01ab224e..f80a57557 100644 --- a/cmd/elastic-package/cluster.go +++ b/cmd/cluster.go @@ -1,4 +1,4 @@ -package main +package cmd import ( "github.com/pkg/errors" diff --git a/cmd/root.go b/cmd/root.go new file mode 100644 index 000000000..a44cc2c77 --- /dev/null +++ b/cmd/root.go @@ -0,0 +1,19 @@ +package cmd + +import ( + "github.com/spf13/cobra" +) + +// RootCmd creates and returns root cmd for elastic-package +func RootCmd() *cobra.Command { + rootCmd := &cobra.Command{ + Use: "elastic-package", + Short: "elastic-package - Command line tool for developing Elastic Integrations", + } + rootCmd.AddCommand( + setupClusterCommand(), + setupBuildCommand(), + setupTestCommand()) + + return rootCmd +} diff --git a/cmd/elastic-package/testrunner.go b/cmd/testrunner.go similarity index 96% rename from cmd/elastic-package/testrunner.go rename to cmd/testrunner.go index 3ecb8f6ea..5023fa9ea 100644 --- a/cmd/elastic-package/testrunner.go +++ b/cmd/testrunner.go @@ -1,4 +1,4 @@ -package main +package cmd import "github.com/spf13/cobra" diff --git a/cmd/elastic-package/main.go b/main.go similarity index 51% rename from cmd/elastic-package/main.go rename to main.go index c06af1ebf..9b385a510 100644 --- a/cmd/elastic-package/main.go +++ b/main.go @@ -5,21 +5,13 @@ import ( "os" "github.com/pkg/errors" - "github.com/spf13/cobra" + "github.com/elastic/elastic-package/cmd" "github.com/elastic/elastic-package/internal/install" ) func main() { - rootCmd := &cobra.Command{ - Use: "elastic-package", - Short: "elastic-package - Command line tool for developing Elastic Integrations", - SilenceUsage: true, - } - rootCmd.AddCommand( - setupBuildCommand(), - setupClusterCommand(), - setupTestCommand()) + rootCmd := cmd.RootCmd() err := install.EnsureInstalled() if err != nil {