Skip to content

Commit 15582ec

Browse files
committed
feat:support --dependency-update before upgrade
Signed-off-by: kamilswiec <[email protected]>
1 parent 53a039d commit 15582ec

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

cmd/helm3.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ func getRelease(release, namespace string) ([]byte, error) {
7474
return outputWithRichError(cmd)
7575
}
7676

77+
func updateDependencies(chart string) ([]byte, error) {
78+
args := []string{"dependency", "update", chart}
79+
cmd := exec.Command(os.Getenv("HELM_BIN"), args...)
80+
return outputWithRichError(cmd)
81+
}
82+
7783
func getHooks(release, namespace string) ([]byte, error) {
7884
args := []string{"get", "hooks", release}
7985
if namespace != "" {

cmd/upgrade.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ type diffCmd struct {
5151
resetValues bool
5252
resetThenReuseValues bool
5353
allowUnreleased bool
54+
dependencyUpdate bool
5455
noHooks bool
5556
includeTests bool
5657
includeCRDs bool
@@ -240,6 +241,7 @@ func newChartCommand() *cobra.Command {
240241
f.BoolVar(&diff.resetThenReuseValues, "reset-then-reuse-values", false, "reset the values to the ones built into the chart, apply the last release's values and merge in any new values. If '--reset-values' or '--reuse-values' is specified, this is ignored")
241242
f.BoolVar(&diff.allowUnreleased, "allow-unreleased", false, "enables diffing of releases that are not yet deployed via Helm")
242243
f.BoolVar(&diff.install, "install", false, "enables diffing of releases that are not yet deployed via Helm (equivalent to --allow-unreleased, added to match \"helm upgrade --install\" command")
244+
f.BoolVar(&diff.dependencyUpdate, "dependency-update", false, "update dependencies if they are missing before diffing")
243245
f.BoolVar(&diff.noHooks, "no-hooks", false, "disable diffing of hooks")
244246
f.BoolVar(&diff.includeTests, "include-tests", false, "enable the diffing of the helm test hooks")
245247
f.BoolVar(&diff.includeCRDs, "include-crds", false, "include CRDs in the diffing")
@@ -271,6 +273,16 @@ func (d *diffCmd) runHelm3() error {
271273

272274
var err error
273275

276+
if d.dependencyUpdate {
277+
var output []byte
278+
output, err = updateDependencies(d.chart)
279+
if err != nil {
280+
return err
281+
} else {
282+
fmt.Println(string(output))
283+
}
284+
}
285+
274286
if d.takeOwnership {
275287
// We need to do a three way merge between the manifests of the new
276288
// release, the manifests of the old release and what is currently deployed

0 commit comments

Comments
 (0)