From f960fe077d23a6f21226583e63163c24aad3124b Mon Sep 17 00:00:00 2001 From: Ivan Krutov Date: Thu, 6 Jul 2017 19:53:26 +0300 Subject: [PATCH 1/2] Showing tag in version command --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3c4ebc7..1c7419a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,8 +9,8 @@ services: script: - go test -race -v github.com/aerokube/cm/selenoid -coverprofile=coverage.txt -covermode=atomic -coverpkg github.com/aerokube/cm/selenoid - - GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags "-X github.com/aerokube/cm/cmd.buildStamp=`date -u '+%Y-%m-%d_%I:%M:%S%p'` -X github.com/aerokube/cm/cmd.gitRevision=`git rev-parse HEAD`" - - gox -os "linux darwin windows" -arch "amd64" -osarch="windows/386" -output "dist/{{.Dir}}_{{.OS}}_{{.Arch}}" -ldflags "-X github.com/aerokube/cm/cmd.buildStamp=`date -u '+%Y-%m-%d_%I:%M:%S%p'` -X github.com/aerokube/cm/cmd.gitRevision=`git rev-parse HEAD`" + - GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags "-X github.com/aerokube/cm/cmd.buildStamp=`date -u '+%Y-%m-%d_%I:%M:%S%p'` -X github.com/aerokube/cm/cmd.gitRevision=`git describe --tags || git rev-parse HEAD`" + - gox -os "linux darwin windows" -arch "amd64" -osarch="windows/386" -output "dist/{{.Dir}}_{{.OS}}_{{.Arch}}" -ldflags "-X github.com/aerokube/cm/cmd.buildStamp=`date -u '+%Y-%m-%d_%I:%M:%S%p'` -X github.com/aerokube/cm/cmd.gitRevision=`git describe --tags || git rev-parse HEAD`" before_install: - go get -u github.com/kardianos/govendor From d45624600159f8915a41a77013abe9d7257abe5a Mon Sep 17 00:00:00 2001 From: Ivan Krutov Date: Thu, 6 Jul 2017 20:00:35 +0300 Subject: [PATCH 2/2] Fixed issue with overwritten configDir value --- cmd/selenoid.go | 5 +++-- cmd/selenoid_cleanup.go | 6 +++--- cmd/selenoid_configure.go | 2 +- cmd/selenoid_download.go | 6 +++--- cmd/selenoid_start.go | 6 +++--- cmd/selenoid_status.go | 2 +- cmd/selenoid_stop.go | 6 +++--- cmd/selenoid_ui_cleanup.go | 2 +- cmd/selenoid_ui_download.go | 2 +- cmd/selenoid_ui_start.go | 2 +- cmd/selenoid_ui_status.go | 2 +- cmd/selenoid_ui_stop.go | 2 +- cmd/selenoid_ui_update.go | 2 +- cmd/selenoid_update.go | 2 +- 14 files changed, 24 insertions(+), 23 deletions(-) diff --git a/cmd/selenoid.go b/cmd/selenoid.go index 5d7708b..1031df4 100644 --- a/cmd/selenoid.go +++ b/cmd/selenoid.go @@ -24,6 +24,7 @@ var ( browsers string browsersJSONUrl string configDir string + uiConfigDir string skipDownload bool vnc bool force bool @@ -82,7 +83,7 @@ func initFlags() { selenoidCleanupUICmd, selenoidUIStatusCmd, } { - c.Flags().StringVarP(&configDir, "config-dir", "c", getSelenoidUIConfigDir(), "directory to save files") + c.Flags().StringVarP(&uiConfigDir, "config-dir", "c", getSelenoidUIConfigDir(), "directory to save files") } for _, c := range []*cobra.Command{ @@ -139,7 +140,7 @@ func initFlags() { } } -func createLifecycle() (*selenoid.Lifecycle, error) { +func createLifecycle(configDir string) (*selenoid.Lifecycle, error) { config := selenoid.LifecycleConfig{ Quiet: quiet, Force: force, diff --git a/cmd/selenoid_cleanup.go b/cmd/selenoid_cleanup.go index 3a2383c..6908057 100644 --- a/cmd/selenoid_cleanup.go +++ b/cmd/selenoid_cleanup.go @@ -10,14 +10,14 @@ var selenoidCleanupCmd = &cobra.Command{ Use: "cleanup", Short: "Remove Selenoid traces", Run: func(cmd *cobra.Command, args []string) { - cleanupImpl(func(lc *selenoid.Lifecycle) error { + cleanupImpl(configDir, func(lc *selenoid.Lifecycle) error { return lc.Stop() }) }, } -func cleanupImpl(stopAction func(*selenoid.Lifecycle) error) { - lifecycle, err := createLifecycle() +func cleanupImpl(configDir string, stopAction func(*selenoid.Lifecycle) error) { + lifecycle, err := createLifecycle(configDir) if err != nil { stderr("Failed to initialize: %v\n", err) os.Exit(1) diff --git a/cmd/selenoid_configure.go b/cmd/selenoid_configure.go index 4b12bd8..0204857 100644 --- a/cmd/selenoid_configure.go +++ b/cmd/selenoid_configure.go @@ -9,7 +9,7 @@ var selenoidConfigureCmd = &cobra.Command{ Use: "configure", Short: "Create Selenoid configuration file and download dependencies", Run: func(cmd *cobra.Command, args []string) { - lifecycle, err := createLifecycle() + lifecycle, err := createLifecycle(configDir) if err != nil { stderr("Failed to initialize: %v\n", err) os.Exit(1) diff --git a/cmd/selenoid_download.go b/cmd/selenoid_download.go index f3dec40..0b72e9c 100644 --- a/cmd/selenoid_download.go +++ b/cmd/selenoid_download.go @@ -10,14 +10,14 @@ var selenoidDownloadCmd = &cobra.Command{ Use: "download", Short: "Download Selenoid latest or specified release", Run: func(cmd *cobra.Command, args []string) { - downloadImpl(func(lc *selenoid.Lifecycle) error { + downloadImpl(configDir, func(lc *selenoid.Lifecycle) error { return lc.Download() }) }, } -func downloadImpl(downloadAction func(*selenoid.Lifecycle) error) { - lifecycle, err := createLifecycle() +func downloadImpl(configDir string, downloadAction func(*selenoid.Lifecycle) error) { + lifecycle, err := createLifecycle(configDir) if err != nil { stderr("Failed to initialize: %v\n", err) os.Exit(1) diff --git a/cmd/selenoid_start.go b/cmd/selenoid_start.go index e698d63..76d248c 100644 --- a/cmd/selenoid_start.go +++ b/cmd/selenoid_start.go @@ -10,14 +10,14 @@ var selenoidStartCmd = &cobra.Command{ Use: "start", Short: "Start Selenoid", Run: func(cmd *cobra.Command, args []string) { - startImpl(func(lc *selenoid.Lifecycle) error { + startImpl(configDir, func(lc *selenoid.Lifecycle) error { return lc.Start() }, force) }, } -func startImpl(startAction func(*selenoid.Lifecycle) error, force bool) { - lifecycle, err := createLifecycle() +func startImpl(configDir string, startAction func(*selenoid.Lifecycle) error, force bool) { + lifecycle, err := createLifecycle(configDir) if err != nil { stderr("Failed to initialize: %v\n", err) os.Exit(1) diff --git a/cmd/selenoid_status.go b/cmd/selenoid_status.go index be924e9..285d348 100644 --- a/cmd/selenoid_status.go +++ b/cmd/selenoid_status.go @@ -9,7 +9,7 @@ var selenoidStatusCmd = &cobra.Command{ Use: "status", Short: "Shows Selenoid configuration status", Run: func(cmd *cobra.Command, args []string) { - lifecycle, err := createLifecycle() + lifecycle, err := createLifecycle(configDir) if err != nil { stderr("Failed to initialize: %v\n", err) os.Exit(1) diff --git a/cmd/selenoid_stop.go b/cmd/selenoid_stop.go index e448575..e5fa042 100644 --- a/cmd/selenoid_stop.go +++ b/cmd/selenoid_stop.go @@ -10,14 +10,14 @@ var selenoidStopCmd = &cobra.Command{ Use: "stop", Short: "Stop Selenoid", Run: func(cmd *cobra.Command, args []string) { - stopImpl(func(lc *selenoid.Lifecycle) error { + stopImpl(configDir, func(lc *selenoid.Lifecycle) error { return lc.Stop() }) }, } -func stopImpl(stopAction func(*selenoid.Lifecycle) error) { - lifecycle, err := createLifecycle() +func stopImpl(configDir string, stopAction func(*selenoid.Lifecycle) error) { + lifecycle, err := createLifecycle(configDir) if err != nil { stderr("Failed to initialize: %v\n", err) os.Exit(1) diff --git a/cmd/selenoid_ui_cleanup.go b/cmd/selenoid_ui_cleanup.go index c3b019c..5175da7 100644 --- a/cmd/selenoid_ui_cleanup.go +++ b/cmd/selenoid_ui_cleanup.go @@ -9,7 +9,7 @@ var selenoidCleanupUICmd = &cobra.Command{ Use: "cleanup", Short: "Remove Selenoid UI traces", Run: func(cmd *cobra.Command, args []string) { - cleanupImpl(func(lc *selenoid.Lifecycle) error { + cleanupImpl(uiConfigDir, func(lc *selenoid.Lifecycle) error { return lc.StopUI() }) }, diff --git a/cmd/selenoid_ui_download.go b/cmd/selenoid_ui_download.go index 2ca18ed..d9c80a4 100644 --- a/cmd/selenoid_ui_download.go +++ b/cmd/selenoid_ui_download.go @@ -9,7 +9,7 @@ var selenoidDownloadUICmd = &cobra.Command{ Use: "download", Short: "Download latest or specified release of Selenoid UI", Run: func(cmd *cobra.Command, args []string) { - downloadImpl(func(lc *selenoid.Lifecycle) error { + downloadImpl(uiConfigDir, func(lc *selenoid.Lifecycle) error { return lc.DownloadUI() }) }, diff --git a/cmd/selenoid_ui_start.go b/cmd/selenoid_ui_start.go index 8be53e0..77f5d9d 100644 --- a/cmd/selenoid_ui_start.go +++ b/cmd/selenoid_ui_start.go @@ -9,7 +9,7 @@ var selenoidStartUICmd = &cobra.Command{ Use: "start", Short: "Start Selenoid UI", Run: func(cmd *cobra.Command, args []string) { - startImpl(func(lc *selenoid.Lifecycle) error { + startImpl(uiConfigDir, func(lc *selenoid.Lifecycle) error { return lc.StartUI() }, force) }, diff --git a/cmd/selenoid_ui_status.go b/cmd/selenoid_ui_status.go index cea7aac..fd4769d 100644 --- a/cmd/selenoid_ui_status.go +++ b/cmd/selenoid_ui_status.go @@ -9,7 +9,7 @@ var selenoidUIStatusCmd = &cobra.Command{ Use: "status", Short: "Shows Selenoid UI status", Run: func(cmd *cobra.Command, args []string) { - lifecycle, err := createLifecycle() + lifecycle, err := createLifecycle(uiConfigDir) if err != nil { stderr("Failed to initialize: %v\n", err) os.Exit(1) diff --git a/cmd/selenoid_ui_stop.go b/cmd/selenoid_ui_stop.go index a2b7edc..fca06cc 100644 --- a/cmd/selenoid_ui_stop.go +++ b/cmd/selenoid_ui_stop.go @@ -9,7 +9,7 @@ var selenoidStopUICmd = &cobra.Command{ Use: "stop", Short: "Stop Selenoid UI", Run: func(cmd *cobra.Command, args []string) { - stopImpl(func(lc *selenoid.Lifecycle) error { + stopImpl(uiConfigDir, func(lc *selenoid.Lifecycle) error { return lc.StopUI() }) }, diff --git a/cmd/selenoid_ui_update.go b/cmd/selenoid_ui_update.go index 0940792..bd0d9de 100644 --- a/cmd/selenoid_ui_update.go +++ b/cmd/selenoid_ui_update.go @@ -9,7 +9,7 @@ var selenoidUpdateUICmd = &cobra.Command{ Use: "update", Short: "Update Selenoid UI (download latest Selenoid UI and start)", Run: func(cmd *cobra.Command, args []string) { - startImpl(func(lc *selenoid.Lifecycle) error { + startImpl(uiConfigDir, func(lc *selenoid.Lifecycle) error { return lc.StartUI() }, true) }, diff --git a/cmd/selenoid_update.go b/cmd/selenoid_update.go index ce0eff3..eb8e6e6 100644 --- a/cmd/selenoid_update.go +++ b/cmd/selenoid_update.go @@ -9,7 +9,7 @@ var selenoidUpdateCmd = &cobra.Command{ Use: "update", Short: "Update Selenoid (download latest Selenoid, configure and start)", Run: func(cmd *cobra.Command, args []string) { - startImpl(func(lc *selenoid.Lifecycle) error { + startImpl(configDir, func(lc *selenoid.Lifecycle) error { return lc.Start() }, true) },