Introduce ResourceV2, DeploymentV2, and CheckpointV2 (#1578)

* Introduce ResourceV2, DeploymentV2, and CheckpointV2, to prepare for a breaking change to the deployment format

* Rename Read -> External
This commit is contained in:
Sean Gillespie 2018-07-11 09:16:53 -07:00 committed by GitHub
parent 4edd244a26
commit 9bf37cc40d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -67,6 +67,17 @@ type CheckpointV1 struct {
Latest *DeploymentV1 `json:"latest,omitempty" yaml:"latest,omitempty"`
}
// CheckpointV2 is the second version of the Checkpoint. It contains a newer version of
// the latest deployment.
type CheckpointV2 struct {
// Stack is the stack to update.
Stack tokens.QName `json:"stack" yaml:"stack"`
// Config contains a bag of optional configuration keys/values.
Config config.Map `json:"config,omitempty" yaml:"config,omitempty"`
// Latest is the latest/current deployment (if an update has occurred).
Latest *DeploymentV2 `json:"latest,omitempty" yaml:"latest,omitempty"`
}
// DeploymentV1 represents a deployment that has actually occurred. It is similar to the engine's snapshot structure,
// except that it flattens and rearranges a few data structures for serializability.
type DeploymentV1 struct {
@ -76,6 +87,15 @@ type DeploymentV1 struct {
Resources []ResourceV1 `json:"resources,omitempty" yaml:"resources,omitempty"`
}
// DeploymentV2 is the second version of the Deployment. It contains never versions of the
// Resource API type.
type DeploymentV2 struct {
// Manifest contains metadata about this deployment.
Manifest ManifestV1 `json:"manifest" yaml:"manifest"`
// Resources contains all resources that are currently part of this stack after this deployment has finished.
Resources []ResourceV2 `json:"resources,omitempty" yaml:"resources,omitempty"`
}
// UntypedDeployment contains an inner, untyped deployment structure.
type UntypedDeployment struct {
// Version indicates the schema of the encoded deployment.
@ -112,6 +132,42 @@ type ResourceV1 struct {
Dependencies []resource.URN `json:"dependencies" yaml:"dependencies,omitempty"`
}
// ResourceV2 is the second version of the Resource API type. It absorbs two breaking changes:
// 1. The deprecated `Defaults` field is removed because it is not used anywhere,
// 2. It adds an additional bool field, "External", which reflects whether or not this resource
// exists because of a call to `ReadResource`. This is motivated by a need to store
// resources that Pulumi does not own in the deployment.
//
// Migrating from ResourceV1 to ResourceV2 involves:
// 1. Dropping the `Defaults` field (it should be empty anyway)
// 2. Setting the `External` field to "false", since a ResourceV1 existing for a resource
// implies that it is owned by Pulumi. Note that since this is the default value for
// booleans in Go, no explicit assignment needs to be made.
type ResourceV2 struct {
// URN uniquely identifying this resource.
URN resource.URN `json:"urn" yaml:"urn"`
// Custom is true when it is managed by a plugin.
Custom bool `json:"custom" yaml:"custom"`
// Delete is true when the resource should be deleted during the next update.
Delete bool `json:"delete,omitempty" yaml:"delete,omitempty"`
// ID is the provider-assigned resource, if any, for custom resources.
ID resource.ID `json:"id,omitempty" yaml:"id,omitempty"`
// Type is the resource's full type token.
Type tokens.Type `json:"type" yaml:"type"`
// Inputs are the input properties supplied to the provider.
Inputs map[string]interface{} `json:"inputs,omitempty" yaml:"inputs,omitempty"`
// Outputs are the output properties returned by the provider after provisioning.
Outputs map[string]interface{} `json:"outputs,omitempty" yaml:"outputs,omitempty"`
// Parent is an optional parent URN if this resource is a child of it.
Parent resource.URN `json:"parent,omitempty" yaml:"parent,omitempty"`
// Protect is set to true when this resource is "protected" and may not be deleted.
Protect bool `json:"protect,omitempty" yaml:"protect,omitempty"`
// External is set to true when the lifecycle of this resource is not managed by Pulumi.
External bool `json:"external,omitempty" yaml:"external,omitempty"`
// Dependencies contains the dependency edges to other resources that this depends on.
Dependencies []resource.URN `json:"dependencies" yaml:"dependencies,omitempty"`
}
// ManifestV1 captures meta-information about this checkpoint file, such as versions of binaries, etc.
type ManifestV1 struct {
// Time of the update.