Skip to content

Commit 0a6239c

Browse files
authored
Merge pull request #1460 from aFlyBird0/chore_reduce-helm-log
chore: use exec to reduce helm log
2 parents 727e6a2 + 9a5a78d commit 0a6239c

File tree

1 file changed

+15
-25
lines changed

1 file changed

+15
-25
lines changed

internal/pkg/start/tool/argocd.go

+15-25
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,23 @@ package tool
33
import (
44
"fmt"
55
"os/exec"
6+
"strings"
67

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"
108
"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"
1217
)
1318

1419
var toolArgocd = tool{
1520
Name: "Argo CD",
1621
IfExists: func() bool {
17-
cmd := exec.Command("helm", "status", "argocd", "-n", "argocd")
22+
cmd := exec.Command("helm", "status", argocdChartReleaseName, "-n", argocdNamespace)
1823
return cmd.Run() == nil
1924
},
2025

@@ -28,32 +33,17 @@ var toolArgocd = tool{
2833
if err != nil {
2934
return err
3035
}
31-
if err = kubeClient.UpsertNameSpace("argocd"); err != nil {
36+
if err = kubeClient.UpsertNameSpace(argocdNamespace); err != nil {
3237
return err
3338
}
3439

3540
// 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") {
5443
return err
5544
}
56-
if err = h.InstallOrUpgradeChart(); err != nil {
45+
46+
if err = execCommand([]string{"helm", "install", argocdChartReleaseName, argocdChartName, "-n", argocdNamespace}); err != nil {
5747
return err
5848
}
5949

0 commit comments

Comments
 (0)