VSChina / magic-modules

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

MM should concat the property names together when it is doing flatten_object #68

Closed ArcturusZhang closed 5 years ago

ArcturusZhang commented 5 years ago

For instance, we have a definition:

      - !ruby/object:Api::Type::NestedObject
        name: 'virtualMachineScaleSet'
        description: 'Specifies information about the virtual machine scale set that the virtual machine should be assigned to. Virtual machines specified in the same virtual machine scale set are allocated to different nodes to maximize availability. Currently, a VM can only be added to virtual machine scale set at creation time. An existing VM cannot be added to a virtual machine scale set. <br><br>This property cannot exist along with a non-null properties.availabilitySet reference. <br><br>Minimum api‐version: 2019‐03‐01'
        required: false
        azure_sdk_references: ['/virtualMachineScaleSet', '/properties/virtualMachineScaleSet']
        properties:
          - !ruby/object:Api::Type::String
            name: 'id'
            description: 'Resource Id'
            required: false
            azure_sdk_references: ['/virtualMachineScaleSet/id', '/properties/virtualMachineScaleSet/id']

I can conveniently flatten this object by writing a terraform.yaml:

      virtualMachineScaleSet: !ruby/object:Provider::Azure::Terraform::PropertyOverride
        flatten_object: true

But by doing this, the schema name will only contain id, the name of virtualMachineScaleSet is lost. This behaviour will easily cause conflict of the same keys in schema.

ArcturusZhang commented 5 years ago

Actually, this could be done by adding another entry in terraform.yaml:

      virtualMachineScaleSet.id: !ruby/object:Provider::Azure::Terraform::PropertyOverride
        name: 'virtualMachineScaleSetId'