chore: allow deserialise resource sources

main
Elie 2022-02-22 14:37:36 +01:00
parent 2116470ffa
commit 3e550b6a68
No known key found for this signature in database
GPG Key ID: 399AF69092C727B6
1 changed files with 14 additions and 2 deletions

View File

@ -128,10 +128,22 @@ func (a *Analysis) UnmarshalJSON(bytes []byte) error {
}) })
} }
for _, m := range bla.Managed { for _, m := range bla.Managed {
a.AddManaged(&resource.Resource{ res := &resource.Resource{
Id: m.Id, Id: m.Id,
Type: m.Type, Type: m.Type,
}) }
if m.Source != nil {
// We loose the source type in the serialization process, for now everything is serialized back to a
// TerraformStateSource.
// TODO: Add a discriminator field to be able to serialize back to the right type
// when we'll introduce a new source type
res.Source = &resource.TerraformStateSource{
State: m.Source.S,
Module: m.Source.Ns,
Name: m.Source.Name,
}
}
a.AddManaged(res)
} }
for _, di := range bla.Differences { for _, di := range bla.Differences {
a.AddDifference(Difference{ a.AddDifference(Difference{