This change implements a `pulumi refresh` command. It operates a bit like `pulumi update`, and friends, in that it supports `--preview` and `--diff`, along with the usual flags, and will update your checkpoint. It works through substitution of the deploy.Source abstraction, which generates a sequence of resource registration events. This new deploy.RefreshSource takes in a prior checkpoint and will walk it, refreshing the state via the associated resource providers by invoking Read for each resource encountered, and merging the resulting state with the prior checkpoint, to yield a new resource.Goal state. This state is then fed through the engine in the usual ways with a few minor caveats: namely, although the engine must generate steps for the logical operations (permitting us to get nice summaries, progress, and diffs), it mustn't actually carry them out because the state being imported already reflects reality (a deleted resource has *already* been deleted, so of course the engine need not perform the deletion). The diffing logic also needs to know how to treat the case of refresh slightly differently, because we are going to be diffing outputs and not inputs. Note that support for managed stacks is not yet complete, since that requires updates to the service to support a refresh endpoint. That will be coming soon ...
33 lines
1.2 KiB
Go
33 lines
1.2 KiB
Go
// Copyright 2016-2018, Pulumi Corporation. All rights reserved.
|
|
|
|
package resource
|
|
|
|
import (
|
|
"github.com/pulumi/pulumi/pkg/tokens"
|
|
)
|
|
|
|
// Goal is a desired state for a resource object. Normally it represents a subset of the resource's state expressed by
|
|
// a program, however if Output is true, it represents a more complete, post-deployment view of the state.
|
|
type Goal struct {
|
|
Type tokens.Type // the type of resource.
|
|
Name tokens.QName // the name for the resource's URN.
|
|
Custom bool // true if this resource is custom, managed by a plugin.
|
|
Properties PropertyMap // the resource's property state.
|
|
Parent URN // an optional parent URN for this resource.
|
|
Protect bool // true to protect this resource from deletion.
|
|
Dependencies []URN // dependencies of this resource object.
|
|
}
|
|
|
|
// NewGoal allocates a new resource goal state.
|
|
func NewGoal(t tokens.Type, name tokens.QName, custom bool, props PropertyMap,
|
|
parent URN, protect bool, dependencies []URN) *Goal {
|
|
return &Goal{
|
|
Type: t,
|
|
Name: name,
|
|
Custom: custom,
|
|
Properties: props,
|
|
Parent: parent,
|
|
Protect: protect,
|
|
Dependencies: dependencies,
|
|
}
|
|
}
|