Always prompt for confirmation after a preview.
An empty preview is not a guarantee that a subsequent update will cause no changes. As such, we should always offer the user the option to perform an update even if the preview proposes no changes. Note that this indirectly fixes #1410 by masking the effects of #1429.
This commit is contained in:
parent
a2c30f75ed
commit
31739c8840
1 changed files with 9 additions and 11 deletions
|
@ -536,7 +536,7 @@ func createDiff(events []engine.Event, displayOpts backend.DisplayOptions) strin
|
||||||
func (b *cloudBackend) PreviewThenPrompt(
|
func (b *cloudBackend) PreviewThenPrompt(
|
||||||
ctx context.Context, updateKind client.UpdateKind, stack backend.Stack, pkg *workspace.Project, root string,
|
ctx context.Context, updateKind client.UpdateKind, stack backend.Stack, pkg *workspace.Project, root string,
|
||||||
m backend.UpdateMetadata, opts backend.UpdateOptions,
|
m backend.UpdateMetadata, opts backend.UpdateOptions,
|
||||||
scopes backend.CancellationScopeSource) (engine.ResourceChanges, bool, error) {
|
scopes backend.CancellationScopeSource) (engine.ResourceChanges, error) {
|
||||||
|
|
||||||
// create a channel to hear about the update events from the engine. this will be used so that
|
// create a channel to hear about the update events from the engine. this will be used so that
|
||||||
// we can build up the diff display in case the user asks to see the details of the diff
|
// we can build up the diff display in case the user asks to see the details of the diff
|
||||||
|
@ -559,25 +559,23 @@ func (b *cloudBackend) PreviewThenPrompt(
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// Perform the update operations, passing true for dryRun, so that we get a preview.
|
// Perform the update operations, passing true for dryRun, so that we get a preview.
|
||||||
changes, hasChanges := engine.ResourceChanges(nil), true
|
changes := engine.ResourceChanges(nil)
|
||||||
if !opts.SkipPreview {
|
if !opts.SkipPreview {
|
||||||
c, err := b.updateStack(
|
c, err := b.updateStack(
|
||||||
ctx, updateKind, stack, pkg, root, m, opts, eventsChannel, true /*dryRun*/, scopes)
|
ctx, updateKind, stack, pkg, root, m, opts, eventsChannel, true /*dryRun*/, scopes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return c, false, err
|
return c, err
|
||||||
}
|
}
|
||||||
|
changes = c
|
||||||
// TODO(ellismg)[pulumi/pulumi#1347]: Work around 1347 by forcing a choice when running a preview against a PPC
|
|
||||||
changes, hasChanges = c, c.HasChanges() || !stack.(Stack).RunLocally()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there are no changes, or we're auto-approving or just previewing, we can skip the confirmation prompt.
|
// If there are no changes, or we're auto-approving or just previewing, we can skip the confirmation prompt.
|
||||||
if !hasChanges || opts.AutoApprove || updateKind == client.UpdateKindPreview {
|
if opts.AutoApprove || updateKind == client.UpdateKindPreview {
|
||||||
return changes, hasChanges, nil
|
return changes, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise, ensure the user wants to proceed.
|
// Otherwise, ensure the user wants to proceed.
|
||||||
return changes, hasChanges, confirmBeforeUpdating(updateKind, stack, events, opts)
|
return changes, confirmBeforeUpdating(updateKind, stack, events, opts)
|
||||||
}
|
}
|
||||||
|
|
||||||
// confirmBeforeUpdating asks the user whether to proceed. A nil error means yes.
|
// confirmBeforeUpdating asks the user whether to proceed. A nil error means yes.
|
||||||
|
@ -649,8 +647,8 @@ func (b *cloudBackend) PreviewThenPromptThenExecute(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Preview the operation to the user and ask them if they want to proceed.
|
// Preview the operation to the user and ask them if they want to proceed.
|
||||||
changes, hasChanges, err := b.PreviewThenPrompt(ctx, updateKind, stack, pkg, root, m, opts, scopes)
|
changes, err := b.PreviewThenPrompt(ctx, updateKind, stack, pkg, root, m, opts, scopes)
|
||||||
if err != nil || !hasChanges || updateKind == client.UpdateKindPreview {
|
if err != nil || updateKind == client.UpdateKindPreview {
|
||||||
return changes, err
|
return changes, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue