Skip to content

Commit 70974d6

Browse files
fix tests
1 parent e18d775 commit 70974d6

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

pkg/tfbridge/rawstate.go

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -643,30 +643,31 @@ func (ih *rawStateDeltaHelper) computeDeltaAt(
643643
}
644644
}
645645

646-
tfs, ps, err := LookupSchemas(path, ih.schemaMap, ih.schemaInfos)
647-
contract.AssertNoErrorf(err, "LookupSchemas failed")
646+
tfs, _, err := LookupSchemas(path, ih.schemaMap, ih.schemaInfos)
647+
if err == nil {
648+
if tfs.Type() == shim.TypeDynamic {
649+
relevantSchemaType, err := walk.LookupType(path, ih.schemaType)
650+
contract.AssertNoErrorf(err, "LookupType failed")
651+
652+
return RawStateDelta{Replace: &replaceDelta{Raw: newRawStateFromValue(relevantSchemaType, v)}}, nil
653+
}
654+
}
648655

649656
// For assets and archives, save their AssetTranslation, so that at read time this AssetTranslation can be
650657
// invoked to TranslateAsset or TranslateArchive.
651658
if pv.IsAsset() || pv.IsArchive() {
652-
contract.Assertf(ps != nil && ps.Asset != nil,
659+
schemaInfo := LookupSchemaInfoMapPath(path, ih.schemaInfos)
660+
contract.Assertf(schemaInfo != nil && schemaInfo.Asset != nil,
653661
"Assets must be matched with SchemaInfo with AssetTranslation [%q]",
654662
path.MustEncodeSchemaPath())
655-
at := ps.Asset
663+
at := schemaInfo.Asset
656664
return RawStateDelta{Asset: &assetDelta{
657665
Kind: at.Kind,
658666
Format: at.Format,
659667
HashField: at.HashField,
660668
}}, nil
661669
}
662670

663-
if tfs.Type() == shim.TypeDynamic {
664-
relevantSchemaType, err := walk.LookupType(path, ih.schemaType)
665-
contract.AssertNoErrorf(err, "LookupType failed")
666-
667-
return RawStateDelta{Replace: &replaceDelta{Raw: newRawStateFromValue(relevantSchemaType, v)}}, nil
668-
}
669-
670671
switch {
671672
case v.IsNull() && pv.IsNull():
672673
return RawStateDelta{}, nil

0 commit comments

Comments
 (0)