Incrementally update the checkpoint file during `pulumi update`.
Simply write the current snapshot after each step. We should probably be
more clever about this in the future (i.e. write only the changes rather
than the entire file).
@@ -92,6 +92,7 @@ func (eng *Engine) deployLatest(info *envCmdInfo, opts deployOptions) error {
actions := &deployActions{
Ops: make(map[deploy.StepOp]int),
Opts: opts,
+ Target: result.Info.Target,
Engine: eng,
}
summary, _, _, err := result.Walk(actions)
@@ -115,10 +116,9 @@ func (eng *Engine) deployLatest(info *envCmdInfo, opts deployOptions) error {
colors.SpecAttention, colors.Reset))
}
- // Now save the updated snapshot Notee that if a failure has occurred, the Apply routine above will
+ // Now save the updated snapshot Note that if a failure has occurred, the Apply routine above will
// have returned a safe checkpoint.
- targ := result.Info.Target
- _ = eng.Environment.SaveEnvironment(targ, summary.Snap())
+ _ = eng.Environment.SaveEnvironment(actions.Target, summary.Snap())
fmt.Fprint(eng.Stdout, colors.Colorize(&footer))
if err != nil {
@@ -139,6 +139,7 @@ type deployActions struct {
Ops map[deploy.StepOp]int
MaybeCorrupt bool
Opts deployOptions
+ Target *deploy.Target
Engine *Engine
}
@@ -192,4 +193,8 @@ func (acts *deployActions) After(step deploy.Step, status resource.Status, err e
fmt.Fprint(acts.Engine.Stdout, colors.Colorize(&b))
}
}
+
+ // Write out the current snapshot. Note that even if a failure has occurred, we should still have
+ // a safe checkpoint.
+ _ = acts.Engine.Environment.SaveEnvironment(acts.Target, step.Iterator().Snap())
}
