11package 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
514var 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}
0 commit comments