helper/schema: Simplify setDiff, remove exported SetDiff mentions
setDiff does not make use of its new parameter anymore, so it has been removed. Also, as there is no more SetDiff (exported) function, mentions of that have been removed from comments too.
This commit is contained in:
parent
3ac0cdf0c0
commit
f5bdbc0911
|
@ -131,10 +131,9 @@ type ResourceDiff struct {
|
||||||
// A writer that writes overridden new fields.
|
// A writer that writes overridden new fields.
|
||||||
newWriter *newValueWriter
|
newWriter *newValueWriter
|
||||||
|
|
||||||
// Tracks which keys have been updated by SetNew, SetNewComputed, and SetDiff
|
// Tracks which keys have been updated by ResourceDiff to ensure that the
|
||||||
// to ensure that the diff does not get re-run on keys that were not touched,
|
// diff does not get re-run on keys that were not touched, or diffs that were
|
||||||
// or diffs that were just removed (re-running on the latter would just roll
|
// just removed (re-running on the latter would just roll back the removal).
|
||||||
// back the removal).
|
|
||||||
updatedKeys map[string]bool
|
updatedKeys map[string]bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -198,8 +197,8 @@ func newResourceDiff(schema map[string]*Schema, config *terraform.ResourceConfig
|
||||||
return d
|
return d
|
||||||
}
|
}
|
||||||
|
|
||||||
// UpdatedKeys returns the keys that were updated by SetNew, SetNewComputed, or
|
// UpdatedKeys returns the keys that were updated by this ResourceDiff run.
|
||||||
// SetDiff. These are the only keys that a diff should be re-calculated for.
|
// These are the only keys that a diff should be re-calculated for.
|
||||||
func (d *ResourceDiff) UpdatedKeys() []string {
|
func (d *ResourceDiff) UpdatedKeys() []string {
|
||||||
var s []string
|
var s []string
|
||||||
for k := range d.updatedKeys {
|
for k := range d.updatedKeys {
|
||||||
|
@ -208,9 +207,9 @@ func (d *ResourceDiff) UpdatedKeys() []string {
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear wipes the diff for a particular key. It is called by SetDiff to remove
|
// Clear wipes the diff for a particular key. It is called by ResourceDiff's
|
||||||
// any possibility of conflicts, but can be called on its own to just remove a
|
// functionality to remove any possibility of conflicts, but can be called on
|
||||||
// specific key from the diff completely.
|
// its own to just remove a specific key from the diff completely.
|
||||||
//
|
//
|
||||||
// Note that this does not wipe an override. This function is only allowed on
|
// Note that this does not wipe an override. This function is only allowed on
|
||||||
// computed keys.
|
// computed keys.
|
||||||
|
@ -260,7 +259,7 @@ func (d *ResourceDiff) SetNew(key string, value interface{}) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return d.setDiff(key, d.get(strings.Split(key, "."), "state").Value, value, false)
|
return d.setDiff(key, value, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetNewComputed functions like SetNew, except that it blanks out a new value
|
// SetNewComputed functions like SetNew, except that it blanks out a new value
|
||||||
|
@ -272,11 +271,11 @@ func (d *ResourceDiff) SetNewComputed(key string) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return d.setDiff(key, d.get(strings.Split(key, "."), "state").Value, nil, true)
|
return d.setDiff(key, nil, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
// setDiff performs common diff setting behaviour.
|
// setDiff performs common diff setting behaviour.
|
||||||
func (d *ResourceDiff) setDiff(key string, old, new interface{}, computed bool) error {
|
func (d *ResourceDiff) setDiff(key string, new interface{}, computed bool) error {
|
||||||
if err := d.clear(key); err != nil {
|
if err := d.clear(key); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -300,9 +299,9 @@ func (d *ResourceDiff) ForceNew(key string) error {
|
||||||
return fmt.Errorf("ForceNew: No changes for %s", key)
|
return fmt.Errorf("ForceNew: No changes for %s", key)
|
||||||
}
|
}
|
||||||
|
|
||||||
old, new := d.GetChange(key)
|
_, new := d.GetChange(key)
|
||||||
d.schema[key].ForceNew = true
|
d.schema[key].ForceNew = true
|
||||||
return d.setDiff(key, old, new, false)
|
return d.setDiff(key, new, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get hands off to ResourceData.Get.
|
// Get hands off to ResourceData.Get.
|
||||||
|
|
Loading…
Reference in New Issue