crossplane / terrajet

Generate Crossplane Providers from any Terraform Provider
https://crossplane.io
Apache License 2.0
290 stars 38 forks source link

types: add type name to scope earlier #184

Closed muvaf closed 2 years ago

muvaf commented 2 years ago

Description of your changes

I ran into a case where the resource name is aws_cloudfront_monitoring_subscription and it has a field called monitoring_subscription. The type builder generated MonitoringSubscriptionParameters and MonitoringSubscriptionObservation fields for both the main type and also its field. During printing, only one of them was printed which had no fields, hence we end up in the case where there is a single MonitoringSubscriptionObservation that has no ID field, which broke GetID function.

This change ensures that we add the generated type name to the package scope earlier so that look-ups in the recursive calls of the same type consider the name of the upper level type as well.

I have:

How has this code been tested

Manually with Jet AWS.