Skip to content
This repository has been archived by the owner on Dec 17, 2024. It is now read-only.

Commit

Permalink
Merge pull request #49 from vania-pooh/master
Browse files Browse the repository at this point in the history
Fixes of configDir value
  • Loading branch information
vania-pooh authored Jul 6, 2017
2 parents 6101d50 + d456246 commit db3fbe0
Show file tree
Hide file tree
Showing 15 changed files with 26 additions and 25 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions cmd/selenoid.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ var (
browsers string
browsersJSONUrl string
configDir string
uiConfigDir string
skipDownload bool
vnc bool
force bool
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions cmd/selenoid_cleanup.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion cmd/selenoid_configure.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions cmd/selenoid_download.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions cmd/selenoid_start.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion cmd/selenoid_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions cmd/selenoid_stop.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion cmd/selenoid_ui_cleanup.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})
},
Expand Down
2 changes: 1 addition & 1 deletion cmd/selenoid_ui_download.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})
},
Expand Down
2 changes: 1 addition & 1 deletion cmd/selenoid_ui_start.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
},
Expand Down
2 changes: 1 addition & 1 deletion cmd/selenoid_ui_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion cmd/selenoid_ui_stop.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})
},
Expand Down
2 changes: 1 addition & 1 deletion cmd/selenoid_ui_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
},
Expand Down
2 changes: 1 addition & 1 deletion cmd/selenoid_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
},
Expand Down

0 comments on commit db3fbe0

Please sign in to comment.