add CreateBeforeDestroy to state

Added to src and object, but still need serialization and tests.
This commit is contained in:
James Bardin 2019-12-12 14:59:18 -05:00
parent ded207f3b8
commit dd8ab5812e
3 changed files with 25 additions and 15 deletions

View File

@ -36,6 +36,13 @@ type ResourceInstanceObject struct {
// altogether, or is now deposed.
Dependencies []addrs.AbsResource
// CreateBeforeDestroy reflects the status of the lifecycle
// create_before_destroy option when this instance was last updated.
// Because create_before_destroy also effects the overall ordering of the
// destroy operations, we need to record the status to ensure a resource
// removed from the config will still be destroyed in the same manner.
CreateBeforeDestroy bool
// DependsOn corresponds to the deprecated `depends_on` field in the state.
// This field contained the configuration `depends_on` values, and some of
// the references from within a single module.

View File

@ -51,9 +51,10 @@ type ResourceInstanceObjectSrc struct {
// These fields all correspond to the fields of the same name on
// ResourceInstanceObject.
Private []byte
Status ObjectStatus
Dependencies []addrs.AbsResource
Private []byte
Status ObjectStatus
Dependencies []addrs.AbsResource
CreateBeforeDestroy bool
// deprecated
DependsOn []addrs.Referenceable
}
@ -85,11 +86,12 @@ func (os *ResourceInstanceObjectSrc) Decode(ty cty.Type) (*ResourceInstanceObjec
}
return &ResourceInstanceObject{
Value: val,
Status: os.Status,
Dependencies: os.Dependencies,
DependsOn: os.DependsOn,
Private: os.Private,
Value: val,
Status: os.Status,
Dependencies: os.Dependencies,
DependsOn: os.DependsOn,
Private: os.Private,
CreateBeforeDestroy: os.CreateBeforeDestroy,
}, nil
}

View File

@ -166,13 +166,14 @@ func (obj *ResourceInstanceObjectSrc) DeepCopy() *ResourceInstanceObjectSrc {
}
return &ResourceInstanceObjectSrc{
Status: obj.Status,
SchemaVersion: obj.SchemaVersion,
Private: private,
AttrsFlat: attrsFlat,
AttrsJSON: attrsJSON,
Dependencies: dependencies,
DependsOn: dependsOn,
Status: obj.Status,
SchemaVersion: obj.SchemaVersion,
Private: private,
AttrsFlat: attrsFlat,
AttrsJSON: attrsJSON,
Dependencies: dependencies,
DependsOn: dependsOn,
CreateBeforeDestroy: obj.CreateBeforeDestroy,
}
}