fixed dry run in install.go

Signed-off-by: Suleiman Dibirov <idsulik@gmail.com>
pull/13147/head
Suleiman Dibirov 1 year ago
parent cd68809edc
commit 9e37d20cc8

@ -228,7 +228,7 @@ func (i *Install) Run(chrt *chart.Chart, vals map[string]interface{}) (*release.
// proceeds in the background. // proceeds in the background.
func (i *Install) RunWithContext(ctx context.Context, chrt *chart.Chart, vals map[string]interface{}) (*release.Release, error) { func (i *Install) RunWithContext(ctx context.Context, chrt *chart.Chart, vals map[string]interface{}) (*release.Release, error) {
// Check reachability of cluster unless in client-only mode (e.g. `helm template` without `--validate`) // Check reachability of cluster unless in client-only mode (e.g. `helm template` without `--validate`)
if !i.ClientOnly { if i.canInteractRemote() {
if err := i.cfg.KubeClient.IsReachable(); err != nil { if err := i.cfg.KubeClient.IsReachable(); err != nil {
return nil, err return nil, err
} }
@ -247,11 +247,6 @@ func (i *Install) RunWithContext(ctx context.Context, chrt *chart.Chart, vals ma
return nil, err return nil, err
} }
var interactWithRemote bool
if !i.isDryRun() || i.DryRunOption == "server" || i.DryRunOption == "none" || i.DryRunOption == "false" {
interactWithRemote = true
}
// Pre-install anything in the crd/ directory. We do this before Helm // Pre-install anything in the crd/ directory. We do this before Helm
// contacts the upstream server and builds the capabilities object. // contacts the upstream server and builds the capabilities object.
if crds := chrt.CRDObjects(); !i.ClientOnly && !i.SkipCRDs && len(crds) > 0 { if crds := chrt.CRDObjects(); !i.ClientOnly && !i.SkipCRDs && len(crds) > 0 {
@ -310,7 +305,19 @@ func (i *Install) RunWithContext(ctx context.Context, chrt *chart.Chart, vals ma
rel := i.createRelease(chrt, vals, i.Labels) rel := i.createRelease(chrt, vals, i.Labels)
var manifestDoc *bytes.Buffer var manifestDoc *bytes.Buffer
rel.Hooks, manifestDoc, rel.Info.Notes, err = i.cfg.renderResources(chrt, valuesToRender, i.ReleaseName, i.OutputDir, i.SubNotes, i.UseReleaseName, i.IncludeCRDs, i.PostRenderer, interactWithRemote, i.EnableDNS, i.HideSecret) rel.Hooks, manifestDoc, rel.Info.Notes, err = i.cfg.renderResources(
chrt,
valuesToRender,
i.ReleaseName,
i.OutputDir,
i.SubNotes,
i.UseReleaseName,
i.IncludeCRDs,
i.PostRenderer,
i.canInteractRemote(),
i.EnableDNS,
i.HideSecret,
)
// Even for errors, attach this if available // Even for errors, attach this if available
if manifestDoc != nil { if manifestDoc != nil {
rel.Manifest = manifestDoc.String() rel.Manifest = manifestDoc.String()
@ -425,7 +432,15 @@ func (i *Install) performInstallCtx(ctx context.Context, rel *release.Release, t
} }
} }
// isDryRun returns true if Upgrade is set to run as a DryRun func (i *Install) canInteractRemote() bool {
if i.ClientOnly || i.DryRun || i.DryRunOption == "client" || i.DryRunOption == "true" {
return false
}
return true
}
// isDryRun returns true if Install is set to run as a DryRun
func (i *Install) isDryRun() bool { func (i *Install) isDryRun() bool {
if i.DryRun || i.DryRunOption == "client" || i.DryRunOption == "server" || i.DryRunOption == "true" { if i.DryRun || i.DryRunOption == "client" || i.DryRunOption == "server" || i.DryRunOption == "true" {
return true return true

Loading…
Cancel
Save