Skip to content

Commit

Permalink
fix: add get values function
Browse files Browse the repository at this point in the history
Signed-off-by: Ranjith M P <[email protected]>
  • Loading branch information
r1jt authored Oct 15, 2024
1 parent 977d6ef commit f1dde8f
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion apps/helm_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"os/exec"
"strings"
"io/ioutil"

logf "sigs.k8s.io/controller-runtime/pkg/log"
)
Expand Down Expand Up @@ -161,7 +162,7 @@ func GetLatestHelmChartVersion(helmChart string) (Chart, error) {

func UninstallHelmRelease(releaseName, namespace string) error {
// Define the Helm installation command.
cmd := exec.Command("helm", "uninstall", releaseName, "-n", namespace)
cmd := exec.Command("helm", "uninstall", releaseName, "-n", namespace, "-o", "yaml")
// Execute the command.
output, err := cmd.CombinedOutput()
if err != nil {
Expand All @@ -171,3 +172,18 @@ func UninstallHelmRelease(releaseName, namespace string) error {
return nil

}

func GetHelmValues(releaseName, namespace string, filePath string) error {
// Define the Helm installation command.
cmd := exec.Command("helm", "get", "values", releaseName, "-n", namespace)
// Execute the command.
output, err := cmd.CombinedOutput()
if err != nil {
return fmt.Errorf("failed to uninstall release %s with Helm: %v\n%s", releaseName, err, output)
}
// Write the output to a YAML file.
if err := ioutil.WriteFile(filePath, output, 0644); err != nil {
return fmt.Errorf("failed to write output to file %s: %v", filePath, err)
}
return nil
}

0 comments on commit f1dde8f

Please sign in to comment.