Skip to content

Commit 7d73ba0

Browse files
committed
fix: check argo helm repo
Signed-off-by: Bird <[email protected]>
1 parent bf41217 commit 7d73ba0

File tree

3 files changed

+45
-9
lines changed

3 files changed

+45
-9
lines changed

internal/pkg/start/start.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package start
22

33
import (
44
"fmt"
5+
56
"github.com/devstream-io/devstream/internal/pkg/start/tool"
67
)
78

@@ -18,13 +19,13 @@ func Start() error {
1819
}
1920

2021
func installToolsIfNotExist() error {
21-
for _, t := range tool.Tools {
22+
for _, t := range tool.GetTools() {
2223
if !t.IfExists() {
2324
if err := t.Install(); err != nil {
2425
return err
2526
}
2627
}
27-
if t.IfStopped != nil && !t.IfStopped() {
28+
if t.IfStopped != nil && t.IfStopped() {
2829
if err := t.Start(); err != nil {
2930
return err
3031
}

internal/pkg/start/tool/argocd.go

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
package tool
22

3-
import "fmt"
3+
import (
4+
"fmt"
5+
6+
"github.com/devstream-io/devstream/internal/pkg/plugin/installer/helm"
7+
helmCommon "github.com/devstream-io/devstream/pkg/util/helm"
8+
"github.com/devstream-io/devstream/pkg/util/k8s"
9+
"github.com/devstream-io/devstream/pkg/util/types"
10+
11+
helmUtil "github.com/devstream-io/devstream/pkg/util/helm"
12+
)
413

514
var toolArgocd = tool{
615
Name: "Argo CD",
@@ -14,12 +23,40 @@ var toolArgocd = tool{
1423
return fmt.Errorf("user cancelled")
1524
}
1625

17-
if err := execCommand([]string{"helm", "repo", "add", "argo", "https://argoproj.github.io/argo-helm"}); err != nil {
26+
// create namespace if not exist
27+
kubeClient, err := k8s.NewClient()
28+
if err != nil {
1829
return err
1930
}
20-
if err := execCommand([]string{"helm", "install", "argo/argo-cd", "-n", "argocd", "--create-namespace"}); err != nil {
31+
if err = kubeClient.UpsertNameSpace("argocd"); err != nil {
2132
return err
2233
}
34+
35+
// install argocd by helm
36+
argocdHelmOpts := &helm.Options{
37+
Chart: helmCommon.Chart{
38+
ChartPath: "",
39+
ChartName: "argo/argo-cd",
40+
Version: "",
41+
Timeout: "10m",
42+
Wait: types.Bool(true),
43+
UpgradeCRDs: types.Bool(true),
44+
ReleaseName: "argocd",
45+
Namespace: "argocd",
46+
},
47+
Repo: helmCommon.Repo{
48+
URL: "https://argoproj.github.io/argo-helm",
49+
Name: "argo",
50+
},
51+
}
52+
h, err := helmUtil.NewHelm(argocdHelmOpts.GetHelmParam())
53+
if err != nil {
54+
return err
55+
}
56+
if err = h.InstallOrUpgradeChart(); err != nil {
57+
return err
58+
}
59+
2360
return nil
2461
},
2562
}

internal/pkg/start/tool/tool.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ type tool struct {
1414
Start startFunc
1515
}
1616

17-
var Tools []tool
18-
19-
func init() {
20-
Tools = []tool{toolDocker, toolMinikube, toolHelm, toolArgocd}
17+
func GetTools() []tool {
18+
return []tool{toolDocker, toolMinikube, toolHelm, toolArgocd}
2119
}

0 commit comments

Comments
 (0)