Display diff when Protect bit changes
It's useful to show a diff whenever a user toggles the protect bit on a
resource, so they can be sure that it has actually occured.
@@ -334,7 +334,11 @@ func (data *resourceRowData) getInfoColumn() string {
} else if step.Old.Inputs != nil && step.New.Inputs != nil {
diff = step.Old.Inputs.Diff(step.New.Inputs)
}
- if step.Old.Provider != step.New.Provider {
+
+ // Show a diff if either `provider` or `protect` changed; they might not show a diff via inputs or outputs, but
+ // it is still useful to show that these changed in output.
+ recordMetadataDiff := func(name string, old, new resource.PropertyValue) {
+ if old != new {
if diff == nil {
diff = &resource.ObjectDiff{
Adds: make(resource.PropertyMap),
@@ -343,12 +347,16 @@ func (data *resourceRowData) getInfoColumn() string {
Updates: make(map[resource.PropertyKey]resource.ValueDiff),
}
}
- diff.Updates["provider"] = resource.ValueDiff{
- Old: resource.NewStringProperty(step.Old.Provider),
- New: resource.NewStringProperty(step.New.Provider),
+
+ diff.Updates[resource.PropertyKey(name)] = resource.ValueDiff{Old: old, New: new}
}
}
+ recordMetadataDiff("provider",
+ resource.NewStringProperty(step.Old.Provider), resource.NewStringProperty(step.New.Provider))
+ recordMetadataDiff("protect",
+ resource.NewBoolProperty(step.Old.Protect), resource.NewBoolProperty(step.New.Protect))
+
if diff != nil {
writeString(changesBuf, "changes:")
