|
|
@@ -20,6 +20,7 @@ import (
|
|
|
"bytes"
|
|
|
"fmt"
|
|
|
"os/exec"
|
|
|
+ "path/filepath"
|
|
|
|
|
|
. "github.com/onsi/ginkgo/v2"
|
|
|
corev1 "k8s.io/api/core/v1"
|
|
|
@@ -61,12 +62,22 @@ func (c *HelmChart) Setup(cfg *Config) error {
|
|
|
|
|
|
// Install adds the chart repo and installs the helm chart.
|
|
|
func (c *HelmChart) Install() error {
|
|
|
- err := c.addRepo()
|
|
|
+ args := []string{
|
|
|
+ "dependency", "update", filepath.Join(AssetDir(), "deploy/charts/external-secrets"),
|
|
|
+ }
|
|
|
+ log.Logf("updating chart dependencies with args: %+q", args)
|
|
|
+ cmd := exec.Command("helm", args...)
|
|
|
+ output, err := cmd.CombinedOutput()
|
|
|
+ if err != nil {
|
|
|
+ return fmt.Errorf("unable to run update cmd: %w: %s", err, string(output))
|
|
|
+ }
|
|
|
+
|
|
|
+ err = c.addRepo()
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
|
|
|
- args := []string{"install", c.ReleaseName, c.Chart,
|
|
|
+ args = []string{"install", c.ReleaseName, c.Chart,
|
|
|
"--dependency-update",
|
|
|
"--debug",
|
|
|
"--wait",
|
|
|
@@ -89,28 +100,25 @@ func (c *HelmChart) Install() error {
|
|
|
|
|
|
args = append(args, c.Args...)
|
|
|
|
|
|
- var sout, serr bytes.Buffer
|
|
|
log.Logf("installing chart with args: %+q", args)
|
|
|
- cmd := exec.Command("helm", args...)
|
|
|
- cmd.Stdout = &sout
|
|
|
- cmd.Stderr = &serr
|
|
|
- err = cmd.Run()
|
|
|
+ cmd = exec.Command("helm", args...)
|
|
|
+ output, err = cmd.CombinedOutput()
|
|
|
if err != nil {
|
|
|
- return fmt.Errorf("unable to run cmd: %w: %s %s", err, sout.String(), serr.String())
|
|
|
+ return fmt.Errorf("unable to run cmd: %w: %s", err, string(output))
|
|
|
}
|
|
|
+
|
|
|
+ log.Logf("finished running chart install")
|
|
|
+
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
// Uninstall removes the chart aswell as the repo.
|
|
|
func (c *HelmChart) Uninstall() error {
|
|
|
- var sout, serr bytes.Buffer
|
|
|
args := []string{"uninstall", "--namespace", c.Namespace, c.ReleaseName, "--wait"}
|
|
|
cmd := exec.Command("helm", args...)
|
|
|
- cmd.Stdout = &sout
|
|
|
- cmd.Stderr = &serr
|
|
|
- err := cmd.Run()
|
|
|
+ output, err := cmd.CombinedOutput()
|
|
|
if err != nil {
|
|
|
- return fmt.Errorf("unable to uninstall helm release: %w: %s, %s", err, sout.String(), serr.String())
|
|
|
+ return fmt.Errorf("unable to uninstall helm release: %w: %s", err, string(output))
|
|
|
}
|
|
|
return c.removeRepo()
|
|
|
}
|
|
|
@@ -135,14 +143,12 @@ func (c *HelmChart) removeRepo() error {
|
|
|
if c.Repo.Name == "" || c.Repo.URL == "" {
|
|
|
return nil
|
|
|
}
|
|
|
- var sout, serr bytes.Buffer
|
|
|
+
|
|
|
args := []string{"repo", "remove", c.Repo.Name}
|
|
|
cmd := exec.Command("helm", args...)
|
|
|
- cmd.Stdout = &sout
|
|
|
- cmd.Stderr = &serr
|
|
|
- err := cmd.Run()
|
|
|
+ output, err := cmd.CombinedOutput()
|
|
|
if err != nil {
|
|
|
- return fmt.Errorf("unable to remove repo: %w: %s, %s", err, sout.String(), serr.String())
|
|
|
+ return fmt.Errorf("unable to remove repo: %w: %s", err, string(output))
|
|
|
}
|
|
|
return nil
|
|
|
}
|