VSChina / magic-modules

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

MM shouldn't generate redundant name for expand and flatten function #60

Closed neil-yechenwei closed 5 years ago

neil-yechenwei commented 5 years ago

Current Name : expandArmPrivateLinkServicePrivateLinkServicePropertiesAutoApproval Expect Name : expandArmPrivateLinkServicePropertiesAutoApproval Current Name : flattenArmPrivateLinkServicePrivateLinkServicePropertiesAutoApproval Expect Name : flattenArmPrivateLinkServicePropertiesAutoApproval

houkms commented 5 years ago

Coding style issue, we need to shorten the function name.

magodo commented 5 years ago

The rule used here is defined here, illustrated below:

<%= sdk_marshal.resource -%><%= descriptor.func_name -%>

Where:

From my understanding, this naming convention make sense. Because currently the folder structure of azure provider code is using flatten pattern, i.e., all resource source files are within same package. Hence:

For this specific case, the private link service api.yaml is illustrated below:

...
objects:
  - !ruby/object:Api::Resource
    name: PrivateLinkService
    ...
    azure_sdk_definition: !ruby/object:Api::Azure::SDKDefinition
      create: !ruby/object:Api::Azure::SDKOperationDefinition
          ...
          '/properties/autoApproval': !ruby/object:Api::Azure::SDKTypeDefinition::ComplexObject
            ...
            go_type_name: PrivateLinkServicePropertiesAutoApproval

IMHO, I think we can introduce a toggle in TF override logic, which is on by default, which will will concat function name in a compact way. In case of a resource has several similar type, one of which has prefix as resource name so as to avoid conflict, then we should turn this toggle off.

@houkms how do you think?

houkms commented 5 years ago

@magodo Makes sense.