mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-20 11:48:24 -06:00
Change the signature of map writer to take a map that isn't a pointer. Force the use of ToMap()
to retrieve the created map[string]interface{}
.
This commit is contained in:
parent
15fb969f3e
commit
db2f217f25
@ -8,10 +8,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type _AttrWriterMap struct {
|
type _AttrWriterMap struct {
|
||||||
m *map[string]interface{}
|
m map[string]interface{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func _NewMapWriter(m *map[string]interface{}) *_AttrWriterMap {
|
func _NewMapWriter(m map[string]interface{}) *_AttrWriterMap {
|
||||||
return &_AttrWriterMap{
|
return &_AttrWriterMap{
|
||||||
m: m,
|
m: m,
|
||||||
}
|
}
|
||||||
@ -37,12 +37,12 @@ func (w *_AttrWriterMap) Set(name _SchemaAttr, v interface{}) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (w *_AttrWriterMap) SetBool(name _SchemaAttr, b bool) error {
|
func (w *_AttrWriterMap) SetBool(name _SchemaAttr, b bool) error {
|
||||||
(*w.m)[string(name)] = fmt.Sprintf("%t", b)
|
w.m[string(name)] = fmt.Sprintf("%t", b)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *_AttrWriterMap) SetFloat64(name _SchemaAttr, f float64) error {
|
func (w *_AttrWriterMap) SetFloat64(name _SchemaAttr, f float64) error {
|
||||||
(*w.m)[string(name)] = strconv.FormatFloat(f, 'g', -1, 64)
|
w.m[string(name)] = strconv.FormatFloat(f, 'g', -1, 64)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,6 +51,8 @@ func (w *_AttrWriterMap) SetList(name _SchemaAttr, l []interface{}) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (w *_AttrWriterMap) SetMap(name _SchemaAttr, m map[string]interface{}) error {
|
func (w *_AttrWriterMap) SetMap(name _SchemaAttr, m map[string]interface{}) error {
|
||||||
|
w.m[string(name)] = m
|
||||||
|
return nil
|
||||||
panic(fmt.Sprintf("PROVIDER BUG: Cat set a map within a map for %s", name))
|
panic(fmt.Sprintf("PROVIDER BUG: Cat set a map within a map for %s", name))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,6 +61,10 @@ func (w *_AttrWriterMap) SetSet(name _SchemaAttr, s *schema.Set) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (w *_AttrWriterMap) SetString(name _SchemaAttr, s string) error {
|
func (w *_AttrWriterMap) SetString(name _SchemaAttr, s string) error {
|
||||||
(*w.m)[string(name)] = s
|
w.m[string(name)] = s
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (w *_AttrWriterMap) ToMap() map[string]interface{} {
|
||||||
|
return w.m
|
||||||
|
}
|
||||||
|
@ -242,8 +242,7 @@ func _APIToStateMap(e *_TypeEntry, v interface{}, w _AttrWriter) error {
|
|||||||
return fmt.Errorf("PROVIDER BUG: unable to cast %s to a map", e.SchemaName)
|
return fmt.Errorf("PROVIDER BUG: unable to cast %s to a map", e.SchemaName)
|
||||||
}
|
}
|
||||||
|
|
||||||
m := make(map[string]interface{}, len(rawMap))
|
mWriter := _NewMapWriter(make(map[string]interface{}, len(rawMap)))
|
||||||
mWriter := _NewMapWriter(&m)
|
|
||||||
|
|
||||||
// Make a lookup map by API Schema Name
|
// Make a lookup map by API Schema Name
|
||||||
var setMembersLen int
|
var setMembersLen int
|
||||||
@ -271,7 +270,7 @@ func _APIToStateMap(e *_TypeEntry, v interface{}, w _AttrWriter) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return w.SetMap(e.SchemaName, m)
|
return w.SetMap(e.SchemaName, mWriter.ToMap())
|
||||||
}
|
}
|
||||||
|
|
||||||
func _APIToStateSet(e *_TypeEntry, v interface{}, w _AttrWriter) error {
|
func _APIToStateSet(e *_TypeEntry, v interface{}, w _AttrWriter) error {
|
||||||
|
Loading…
Reference in New Issue
Block a user