Skip to content

Commit 634aeb5

Browse files
authored
Merge pull request #1459 from aFlyBird0/check-helm-argo
fix: check argo helm repo
2 parents f53bfb2 + 7d73ba0 commit 634aeb5

File tree

3 files changed

+44
-9
lines changed

3 files changed

+44
-9
lines changed

internal/pkg/start/start.go

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

2121
func installToolsIfNotExist() error {
22-
for _, t := range tool.Tools {
22+
for _, t := range tool.GetTools() {
2323
if !t.IfExists() {
2424
if err := t.Install(); err != nil {
2525
return err
2626
}
2727
}
28-
if t.IfStopped != nil && !t.IfStopped() {
28+
if t.IfStopped != nil && t.IfStopped() {
2929
if err := t.Start(); err != nil {
3030
return err
3131
}

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)