command/jsonconfig: Use correct provider address to access schema
There was a remaining TODO in this package to find the true provider FQN when looking up the schema for a resource type. We now have that data available in the Provider field of configs.Resource, so we can now complete that change. The tests for this functionality actually live in the parent "command" package as part of the tests for the "terraform show" command, so this fix is verified by all of the TestShow... tests now passing except one, and that remaining one is failing for some other reason which we'll address in a later commit.
This commit is contained in:
parent
69cae48a11
commit
fcb8c53454
|
@ -303,15 +303,13 @@ func marshalResources(resources map[string]*configs.Resource, schemas *terraform
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: get actual providerFqn
|
|
||||||
providerFqn := addrs.NewLegacyProvider(v.ProviderConfigAddr().LocalName)
|
|
||||||
schema, schemaVer := schemas.ResourceTypeConfig(
|
schema, schemaVer := schemas.ResourceTypeConfig(
|
||||||
providerFqn,
|
v.Provider,
|
||||||
v.Mode,
|
v.Mode,
|
||||||
v.Type,
|
v.Type,
|
||||||
)
|
)
|
||||||
if schema == nil {
|
if schema == nil {
|
||||||
return nil, fmt.Errorf("no schema found for %s", v.Addr().String())
|
return nil, fmt.Errorf("no schema found for %s (in provider %s)", v.Addr().String(), v.Provider)
|
||||||
}
|
}
|
||||||
r.SchemaVersion = schemaVer
|
r.SchemaVersion = schemaVer
|
||||||
|
|
||||||
|
|
|
@ -183,7 +183,7 @@ func (p *plan) marshalResourceChanges(changes *plans.Changes, schemas *terraform
|
||||||
addr.Resource.Resource.Type,
|
addr.Resource.Resource.Type,
|
||||||
)
|
)
|
||||||
if schema == nil {
|
if schema == nil {
|
||||||
return fmt.Errorf("no schema found for %s", r.Address)
|
return fmt.Errorf("no schema found for %s (in provider %s)", r.Address, rc.ProviderAddr.Provider)
|
||||||
}
|
}
|
||||||
|
|
||||||
changeV, err := rc.Decode(schema.ImpliedType())
|
changeV, err := rc.Decode(schema.ImpliedType())
|
||||||
|
|
|
@ -291,7 +291,7 @@ func marshalResources(resources map[string]*states.Resource, module addrs.Module
|
||||||
current.SchemaVersion = ri.Current.SchemaVersion
|
current.SchemaVersion = ri.Current.SchemaVersion
|
||||||
|
|
||||||
if schema == nil {
|
if schema == nil {
|
||||||
return nil, fmt.Errorf("no schema found for %s", resAddr.String())
|
return nil, fmt.Errorf("no schema found for %s (in provider %s)", resAddr.String(), r.ProviderConfig.Provider)
|
||||||
}
|
}
|
||||||
riObj, err := ri.Current.Decode(schema.ImpliedType())
|
riObj, err := ri.Current.Decode(schema.ImpliedType())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue