Skip to content

Commit bf41217

Browse files
committed
chore: steps with tools in dtm start command reorder
Signed-off-by: Daniel Hu <[email protected]>
1 parent 3a4be22 commit bf41217

File tree

6 files changed

+23
-23
lines changed

6 files changed

+23
-23
lines changed

internal/pkg/start/start.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ func Start() error {
1919

2020
func 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
}

internal/pkg/start/tool/argocd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import "fmt"
44

55
var toolArgocd = tool{
66
Name: "Argo CD",
7-
Exists: func() bool {
7+
IfExists: func() bool {
88
// TODO(dh)
99
return false
1010
},

internal/pkg/start/tool/docker.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,11 @@ import (
1111
var 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

internal/pkg/start/tool/helm.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
var toolHelm = tool{
99
Name: "Helm",
1010

11-
Exists: func() bool {
11+
IfExists: func() bool {
1212
_, err := exec.LookPath("helm")
1313
return err == nil
1414
},

internal/pkg/start/tool/minikube.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,11 @@ import (
88
var 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

internal/pkg/start/tool/tool.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ type stopedFunc func() bool
55
type installFunc func() error
66
type startFunc func() error
77
type 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

1717
var Tools []tool

0 commit comments

Comments
 (0)