@@ -3,18 +3,23 @@ package tool
3
3
import (
4
4
"fmt"
5
5
"os/exec"
6
+ "strings"
6
7
7
- "github.com/devstream-io/devstream/internal/pkg/plugin/installer/helm"
8
- helmCommon "github.com/devstream-io/devstream/pkg/util/helm"
9
- helmUtil "github.com/devstream-io/devstream/pkg/util/helm"
10
8
"github.com/devstream-io/devstream/pkg/util/k8s"
11
- "github.com/devstream-io/devstream/pkg/util/types"
9
+ )
10
+
11
+ const (
12
+ argocdRepoName = "argo"
13
+ argocdRepoURL = "https://argoproj.github.io/argo-helm"
14
+ argocdNamespace = "argocd"
15
+ argocdChartReleaseName = "argocd"
16
+ argocdChartName = argocdRepoName + "/" + "argo-cd"
12
17
)
13
18
14
19
var toolArgocd = tool {
15
20
Name : "Argo CD" ,
16
21
IfExists : func () bool {
17
- cmd := exec .Command ("helm" , "status" , "argocd" , "-n" , "argocd" )
22
+ cmd := exec .Command ("helm" , "status" , argocdChartReleaseName , "-n" , argocdNamespace )
18
23
return cmd .Run () == nil
19
24
},
20
25
@@ -28,32 +33,17 @@ var toolArgocd = tool{
28
33
if err != nil {
29
34
return err
30
35
}
31
- if err = kubeClient .UpsertNameSpace ("argocd" ); err != nil {
36
+ if err = kubeClient .UpsertNameSpace (argocdNamespace ); err != nil {
32
37
return err
33
38
}
34
39
35
40
// 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 {
41
+ err = execCommand ([]string {"helm" , "repo" , "add" , argocdRepoName , argocdRepoURL })
42
+ if err != nil && ! strings .Contains (err .Error (), "already exists" ) {
54
43
return err
55
44
}
56
- if err = h .InstallOrUpgradeChart (); err != nil {
45
+
46
+ if err = execCommand ([]string {"helm" , "install" , argocdChartReleaseName , argocdChartName , "-n" , argocdNamespace }); err != nil {
57
47
return err
58
48
}
59
49
0 commit comments