Skip to content

Commit

Permalink
fix: add function for helm upgrade
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 f1dde8f commit a0de016
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions apps/helm_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,3 +187,20 @@ func GetHelmValues(releaseName, namespace string, filePath string) error {
}
return nil
}

func UpgradeHelmChartfromValues(helmChart, namespace, releaseName string, values map[string]interface{}, filePath string, version string) error {
var vals []string
for k, v := range values {
vals = append(vals, fmt.Sprintf("%s=%v", k, v))
}
setVals := strings.Join(vals, ",")
logf.Log.Info("executing helm upgrade ", "releaseName: ", releaseName, ", chart: ", helmChart, ", namespace: ", namespace, ", old-values: ", filePath, ", version: ", version, ", values: ", setVals)
// Define the Helm installation command.
cmd := exec.Command("helm", "upgrade", releaseName, helmChart, "-n", namespace, "-f", filePath, "--version", version,"--set", setVals)
// Execute the command.
output, err := cmd.CombinedOutput()
if err != nil {
return fmt.Errorf("failed to upgrade with Helm: %v\n%s", err, output)
}
return nil
}

0 comments on commit a0de016

Please sign in to comment.