helper/schema: Add schemaMap.DeepCopy
This provides a deep copy of a schemaMap, which will be needed for the diff customization process as ResourceDiff will be able to flag fields as ForceNew - we don't want to affect the source schema.
This commit is contained in:
parent
6a4f7b0dce
commit
a5fc664ea6
|
@ -21,6 +21,7 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
"github.com/mitchellh/copystructure"
|
||||
"github.com/mitchellh/mapstructure"
|
||||
)
|
||||
|
||||
|
@ -370,6 +371,16 @@ func (m schemaMap) Data(
|
|||
}, nil
|
||||
}
|
||||
|
||||
// DeepCopy returns a copy of this schemaMap. The copy can be safely modified
|
||||
// without affecting the original.
|
||||
func (m *schemaMap) DeepCopy() schemaMap {
|
||||
copy, err := copystructure.Config{Lock: true}.Copy(m)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return copy.(schemaMap)
|
||||
}
|
||||
|
||||
// Diff returns the diff for a resource given the schema map,
|
||||
// state, and configuration.
|
||||
func (m schemaMap) Diff(
|
||||
|
|
Loading…
Reference in New Issue