VSChina / magic-modules

Magic Modules: Automagically generate Google Cloud Platform support for OSS
Apache License 2.0
1 stars 4 forks source link

SDKTypeDefinitionOverride support sublcass with concrete type definition #69

Closed magodo closed 4 years ago

magodo commented 4 years ago

Previously all overriden attribute under request/response is of SDKTypeDefinitionOverride type.

However, sometimes the overriden field's type contain some special attribute, which might need the capability to be overriden, then you will need to export this field as attribute in SDKTypeDefinitionOverride (otherwise, you will end up with errros complaining your override has extraneous instance variable).

This might work at first, however, when this kind of request increase, your SDKTypeDefinitionOverride will end up to be a mess.

So I choose to inherit SDKTypeDefinitionOverride and define concrete SDK Type's override class (the same way as concrete SDK type against SDKTypeDefinition). Once you need to export some field to be overridable, you just export them in the concrete type override class. And furthermore, you need to define the merge_overrides! in concrete type class (not the override class), so that when merging overriden to overridee class, your exported field will got merged.

This change extend the syntax in terraform.yaml/ansible.yaml in way that you can specify the concrete type for fields under request/response (e.g. you will have to specify the type in above example). On the otherhand, this change should hopefully has no impact to existing override yamls (so no change is needed for existing ones).

houkms commented 4 years ago

LGTM.