consistent reciever names
This commit is contained in:
parent
c5299b5745
commit
729c9b6f10
|
@ -101,18 +101,18 @@ func (rs *Resource) DeepCopy() *Resource {
|
||||||
// is the caller's responsibility to ensure mutual exclusion for the duration
|
// is the caller's responsibility to ensure mutual exclusion for the duration
|
||||||
// of the operation, but may then freely modify the receiver and the returned
|
// of the operation, but may then freely modify the receiver and the returned
|
||||||
// copy independently once this method returns.
|
// copy independently once this method returns.
|
||||||
func (is *ResourceInstance) DeepCopy() *ResourceInstance {
|
func (i *ResourceInstance) DeepCopy() *ResourceInstance {
|
||||||
if is == nil {
|
if i == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
deposed := make(map[DeposedKey]*ResourceInstanceObjectSrc, len(is.Deposed))
|
deposed := make(map[DeposedKey]*ResourceInstanceObjectSrc, len(i.Deposed))
|
||||||
for k, obj := range is.Deposed {
|
for k, obj := range i.Deposed {
|
||||||
deposed[k] = obj.DeepCopy()
|
deposed[k] = obj.DeepCopy()
|
||||||
}
|
}
|
||||||
|
|
||||||
return &ResourceInstance{
|
return &ResourceInstance{
|
||||||
Current: is.Current.DeepCopy(),
|
Current: i.Current.DeepCopy(),
|
||||||
Deposed: deposed,
|
Deposed: deposed,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -125,54 +125,54 @@ func (is *ResourceInstance) DeepCopy() *ResourceInstance {
|
||||||
// It is the caller's responsibility to ensure mutual exclusion for the duration
|
// It is the caller's responsibility to ensure mutual exclusion for the duration
|
||||||
// of the operation, but may then freely modify the receiver and the returned
|
// of the operation, but may then freely modify the receiver and the returned
|
||||||
// copy independently once this method returns.
|
// copy independently once this method returns.
|
||||||
func (obj *ResourceInstanceObjectSrc) DeepCopy() *ResourceInstanceObjectSrc {
|
func (os *ResourceInstanceObjectSrc) DeepCopy() *ResourceInstanceObjectSrc {
|
||||||
if obj == nil {
|
if os == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var attrsFlat map[string]string
|
var attrsFlat map[string]string
|
||||||
if obj.AttrsFlat != nil {
|
if os.AttrsFlat != nil {
|
||||||
attrsFlat = make(map[string]string, len(obj.AttrsFlat))
|
attrsFlat = make(map[string]string, len(os.AttrsFlat))
|
||||||
for k, v := range obj.AttrsFlat {
|
for k, v := range os.AttrsFlat {
|
||||||
attrsFlat[k] = v
|
attrsFlat[k] = v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var attrsJSON []byte
|
var attrsJSON []byte
|
||||||
if obj.AttrsJSON != nil {
|
if os.AttrsJSON != nil {
|
||||||
attrsJSON = make([]byte, len(obj.AttrsJSON))
|
attrsJSON = make([]byte, len(os.AttrsJSON))
|
||||||
copy(attrsJSON, obj.AttrsJSON)
|
copy(attrsJSON, os.AttrsJSON)
|
||||||
}
|
}
|
||||||
|
|
||||||
var attrPaths []cty.PathValueMarks
|
var attrPaths []cty.PathValueMarks
|
||||||
if obj.AttrSensitivePaths != nil {
|
if os.AttrSensitivePaths != nil {
|
||||||
attrPaths = make([]cty.PathValueMarks, len(obj.AttrSensitivePaths))
|
attrPaths = make([]cty.PathValueMarks, len(os.AttrSensitivePaths))
|
||||||
copy(attrPaths, obj.AttrSensitivePaths)
|
copy(attrPaths, os.AttrSensitivePaths)
|
||||||
}
|
}
|
||||||
|
|
||||||
var private []byte
|
var private []byte
|
||||||
if obj.Private != nil {
|
if os.Private != nil {
|
||||||
private = make([]byte, len(obj.Private))
|
private = make([]byte, len(os.Private))
|
||||||
copy(private, obj.Private)
|
copy(private, os.Private)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Some addrs.Referencable implementations are technically mutable, but
|
// Some addrs.Referencable implementations are technically mutable, but
|
||||||
// we treat them as immutable by convention and so we don't deep-copy here.
|
// we treat them as immutable by convention and so we don't deep-copy here.
|
||||||
var dependencies []addrs.ConfigResource
|
var dependencies []addrs.ConfigResource
|
||||||
if obj.Dependencies != nil {
|
if os.Dependencies != nil {
|
||||||
dependencies = make([]addrs.ConfigResource, len(obj.Dependencies))
|
dependencies = make([]addrs.ConfigResource, len(os.Dependencies))
|
||||||
copy(dependencies, obj.Dependencies)
|
copy(dependencies, os.Dependencies)
|
||||||
}
|
}
|
||||||
|
|
||||||
return &ResourceInstanceObjectSrc{
|
return &ResourceInstanceObjectSrc{
|
||||||
Status: obj.Status,
|
Status: os.Status,
|
||||||
SchemaVersion: obj.SchemaVersion,
|
SchemaVersion: os.SchemaVersion,
|
||||||
Private: private,
|
Private: private,
|
||||||
AttrsFlat: attrsFlat,
|
AttrsFlat: attrsFlat,
|
||||||
AttrsJSON: attrsJSON,
|
AttrsJSON: attrsJSON,
|
||||||
AttrSensitivePaths: attrPaths,
|
AttrSensitivePaths: attrPaths,
|
||||||
Dependencies: dependencies,
|
Dependencies: dependencies,
|
||||||
CreateBeforeDestroy: obj.CreateBeforeDestroy,
|
CreateBeforeDestroy: os.CreateBeforeDestroy,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,28 +184,28 @@ func (obj *ResourceInstanceObjectSrc) DeepCopy() *ResourceInstanceObjectSrc {
|
||||||
// is the caller's responsibility to ensure mutual exclusion for the duration
|
// is the caller's responsibility to ensure mutual exclusion for the duration
|
||||||
// of the operation, but may then freely modify the receiver and the returned
|
// of the operation, but may then freely modify the receiver and the returned
|
||||||
// copy independently once this method returns.
|
// copy independently once this method returns.
|
||||||
func (obj *ResourceInstanceObject) DeepCopy() *ResourceInstanceObject {
|
func (o *ResourceInstanceObject) DeepCopy() *ResourceInstanceObject {
|
||||||
if obj == nil {
|
if o == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var private []byte
|
var private []byte
|
||||||
if obj.Private != nil {
|
if o.Private != nil {
|
||||||
private = make([]byte, len(obj.Private))
|
private = make([]byte, len(o.Private))
|
||||||
copy(private, obj.Private)
|
copy(private, o.Private)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Some addrs.Referenceable implementations are technically mutable, but
|
// Some addrs.Referenceable implementations are technically mutable, but
|
||||||
// we treat them as immutable by convention and so we don't deep-copy here.
|
// we treat them as immutable by convention and so we don't deep-copy here.
|
||||||
var dependencies []addrs.ConfigResource
|
var dependencies []addrs.ConfigResource
|
||||||
if obj.Dependencies != nil {
|
if o.Dependencies != nil {
|
||||||
dependencies = make([]addrs.ConfigResource, len(obj.Dependencies))
|
dependencies = make([]addrs.ConfigResource, len(o.Dependencies))
|
||||||
copy(dependencies, obj.Dependencies)
|
copy(dependencies, o.Dependencies)
|
||||||
}
|
}
|
||||||
|
|
||||||
return &ResourceInstanceObject{
|
return &ResourceInstanceObject{
|
||||||
Value: obj.Value,
|
Value: o.Value,
|
||||||
Status: obj.Status,
|
Status: o.Status,
|
||||||
Private: private,
|
Private: private,
|
||||||
Dependencies: dependencies,
|
Dependencies: dependencies,
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,18 +76,18 @@ func (s *State) String() string {
|
||||||
|
|
||||||
// testString is used to produce part of the output of State.String. It should
|
// testString is used to produce part of the output of State.String. It should
|
||||||
// never be used directly.
|
// never be used directly.
|
||||||
func (m *Module) testString() string {
|
func (ms *Module) testString() string {
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
|
|
||||||
if len(m.Resources) == 0 {
|
if len(ms.Resources) == 0 {
|
||||||
buf.WriteString("<no state>")
|
buf.WriteString("<no state>")
|
||||||
}
|
}
|
||||||
|
|
||||||
// We use AbsResourceInstance here, even though everything belongs to
|
// We use AbsResourceInstance here, even though everything belongs to
|
||||||
// the same module, just because we have a sorting behavior defined
|
// the same module, just because we have a sorting behavior defined
|
||||||
// for those but not for just ResourceInstance.
|
// for those but not for just ResourceInstance.
|
||||||
addrsOrder := make([]addrs.AbsResourceInstance, 0, len(m.Resources))
|
addrsOrder := make([]addrs.AbsResourceInstance, 0, len(ms.Resources))
|
||||||
for _, rs := range m.Resources {
|
for _, rs := range ms.Resources {
|
||||||
for ik := range rs.Instances {
|
for ik := range rs.Instances {
|
||||||
addrsOrder = append(addrsOrder, rs.Addr.Instance(ik))
|
addrsOrder = append(addrsOrder, rs.Addr.Instance(ik))
|
||||||
}
|
}
|
||||||
|
@ -99,8 +99,8 @@ func (m *Module) testString() string {
|
||||||
|
|
||||||
for _, fakeAbsAddr := range addrsOrder {
|
for _, fakeAbsAddr := range addrsOrder {
|
||||||
addr := fakeAbsAddr.Resource
|
addr := fakeAbsAddr.Resource
|
||||||
rs := m.Resource(addr.ContainingResource())
|
rs := ms.Resource(addr.ContainingResource())
|
||||||
is := m.ResourceInstance(addr)
|
is := ms.ResourceInstance(addr)
|
||||||
|
|
||||||
// Here we need to fake up a legacy-style address as the old state
|
// Here we need to fake up a legacy-style address as the old state
|
||||||
// types would've used, since that's what our tests against those
|
// types would've used, since that's what our tests against those
|
||||||
|
@ -204,17 +204,17 @@ func (m *Module) testString() string {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(m.OutputValues) > 0 {
|
if len(ms.OutputValues) > 0 {
|
||||||
buf.WriteString("\nOutputs:\n\n")
|
buf.WriteString("\nOutputs:\n\n")
|
||||||
|
|
||||||
ks := make([]string, 0, len(m.OutputValues))
|
ks := make([]string, 0, len(ms.OutputValues))
|
||||||
for k := range m.OutputValues {
|
for k := range ms.OutputValues {
|
||||||
ks = append(ks, k)
|
ks = append(ks, k)
|
||||||
}
|
}
|
||||||
sort.Strings(ks)
|
sort.Strings(ks)
|
||||||
|
|
||||||
for _, k := range ks {
|
for _, k := range ks {
|
||||||
v := m.OutputValues[k]
|
v := ms.OutputValues[k]
|
||||||
lv := hcl2shim.ConfigValueFromHCL2(v.Value)
|
lv := hcl2shim.ConfigValueFromHCL2(v.Value)
|
||||||
switch vTyped := lv.(type) {
|
switch vTyped := lv.(type) {
|
||||||
case string:
|
case string:
|
||||||
|
|
Loading…
Reference in New Issue