File tree Expand file tree Collapse file tree 6 files changed +23
-23
lines changed
Expand file tree Collapse file tree 6 files changed +23
-23
lines changed Original file line number Diff line number Diff line change @@ -19,12 +19,12 @@ func Start() error {
1919
2020func installToolsIfNotExist () error {
2121 for _ , t := range tool .Tools {
22- if ! t .Exists () {
22+ if ! t .IfExists () {
2323 if err := t .Install (); err != nil {
2424 return err
2525 }
2626 }
27- if t .Stopped != nil && ! t .Stopped () {
27+ if t .IfStopped != nil && ! t .IfStopped () {
2828 if err := t .Start (); err != nil {
2929 return err
3030 }
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ import "fmt"
44
55var toolArgocd = tool {
66 Name : "Argo CD" ,
7- Exists : func () bool {
7+ IfExists : func () bool {
88 // TODO(dh)
99 return false
1010 },
Original file line number Diff line number Diff line change @@ -11,16 +11,11 @@ import (
1111var toolDocker = tool {
1212 Name : "Docker" ,
1313
14- Exists : func () bool {
14+ IfExists : func () bool {
1515 _ , err := exec .LookPath ("docker" )
1616 return err == nil
1717 },
1818
19- Stopped : func () bool {
20- cmd := exec .Command ("docker" , "version" )
21- return cmd .Run () != nil
22- },
23-
2419 Install : func () error {
2520 if ! confirm ("Docker" ) {
2621 return fmt .Errorf ("user cancelled" )
@@ -32,6 +27,11 @@ var toolDocker = tool{
3227 return nil
3328 },
3429
30+ IfStopped : func () bool {
31+ cmd := exec .Command ("docker" , "version" )
32+ return cmd .Run () != nil
33+ },
34+
3535 Start : func () error {
3636 if err := execCommand ([]string {"open" , "-a" , "Docker" }); err != nil {
3737 return err
Original file line number Diff line number Diff line change 88var toolHelm = tool {
99 Name : "Helm" ,
1010
11- Exists : func () bool {
11+ IfExists : func () bool {
1212 _ , err := exec .LookPath ("helm" )
1313 return err == nil
1414 },
Original file line number Diff line number Diff line change @@ -8,16 +8,11 @@ import (
88var toolMinikube = tool {
99 Name : "Minikube" ,
1010
11- Exists : func () bool {
11+ IfExists : func () bool {
1212 _ , err := exec .LookPath ("minikube" )
1313 return err == nil
1414 },
1515
16- Stopped : func () bool {
17- cmd := exec .Command ("minikube" , "status" )
18- return cmd .Run () != nil
19- },
20-
2116 Install : func () error {
2217 if ! confirm ("Minikube" ) {
2318 return fmt .Errorf ("user cancelled" )
@@ -29,6 +24,11 @@ var toolMinikube = tool{
2924 return nil
3025 },
3126
27+ IfStopped : func () bool {
28+ cmd := exec .Command ("minikube" , "status" )
29+ return cmd .Run () != nil
30+ },
31+
3232 Start : func () error {
3333 if err := execCommand ([]string {"minikube" , "start" }); err != nil {
3434 return err
Original file line number Diff line number Diff line change @@ -5,13 +5,13 @@ type stopedFunc func() bool
55type installFunc func () error
66type startFunc func () error
77type tool struct {
8- Name string
9- Exists existsFunc
10- // Stopped can be nil if it is not needed.
11- // if Stopped != nil -> Start can't be nil too
12- Stopped stopedFunc
13- Install installFunc
14- Start startFunc
8+ Name string
9+ IfExists existsFunc
10+ Install installFunc
11+ // IfStopped can be nil if it is not needed.
12+ // if IfStopped != nil -> Start can't be nil too
13+ IfStopped stopedFunc
14+ Start startFunc
1515}
1616
1717var Tools []tool
You can’t perform that action at this time.
0 commit comments