Skip to content

Commit

Permalink
add SkipCRDs helm flag (#551)
Browse files Browse the repository at this point in the history
Signed-off-by: Mikhail Scherba <[email protected]>
  • Loading branch information
miklezzzz authored Jan 20, 2025
1 parent b19d19c commit c793bbf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions pkg/helm/helm3/helm3.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ func (h *Helm3Client) UpgradeRelease(releaseName string, chart string, valuesPat
args := []string{
"upgrade", releaseName, chart,
"--install",
"--skip-crds",
"--history-max", fmt.Sprintf("%d", Options.HistoryMax),
"--timeout", Options.Timeout.String(),
"--post-renderer", "./post-renderer",
Expand Down
8 changes: 5 additions & 3 deletions pkg/helm/helm3lib/helm3lib.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ func (h *LibClient) upgradeRelease(releaseName string, chartName string, valuesP
}

upg.Install = true
upg.SkipCRDs = true
upg.MaxHistory = int(options.HistoryMax)
upg.Timeout = options.Timeout

Expand Down Expand Up @@ -235,6 +236,7 @@ func (h *LibClient) upgradeRelease(releaseName string, chartName string, valuesP
if helmPostRenderer != nil {
instClient.PostRenderer = helmPostRenderer
}
instClient.SkipCRDs = true
instClient.Timeout = options.Timeout
instClient.ReleaseName = releaseName
instClient.UseReleaseName = true
Expand Down Expand Up @@ -434,14 +436,14 @@ func (h *LibClient) Render(releaseName, chartName string, valuesPaths, setValues
slog.String("chart", chartName),
slog.String("namespace", namespace))

inst := newInstAction(namespace, releaseName)
inst := newDryRunInstAction(namespace, releaseName)

rs, err := inst.Run(chart, resultValues)
if err != nil {
// helm render can fail because the CRD were previously created
// handling this case we can reinitialize RESTClient and repeat one more time by backoff
_ = h.actionConfigInit()
inst = newInstAction(namespace, releaseName)
inst = newDryRunInstAction(namespace, releaseName)

rs, err = inst.Run(chart, resultValues)
}
Expand All @@ -462,7 +464,7 @@ func (h *LibClient) Render(releaseName, chartName string, valuesPaths, setValues
return rs.Manifest, nil
}

func newInstAction(namespace, releaseName string) *action.Install {
func newDryRunInstAction(namespace, releaseName string) *action.Install {
inst := action.NewInstall(actionConfig)
inst.DryRun = true

Expand Down

0 comments on commit c793bbf

Please sign in to comment.