hashicorp / pandora

A suite of single-purpose tools enabling automation for Terraform/Azure
Mozilla Public License 2.0
65 stars 46 forks source link

config - add network `2024-01-01-preview` #4374

Open teowa opened 3 weeks ago

teowa commented 3 weeks ago

To onboard network manager ipam pool resource: https://github.com/Azure/azure-rest-api-specs/blob/5f24fa2aa4966a7d11892e22c0114f63ee617945/specification/network/resource-manager/Microsoft.Network/preview/2024-01-01-preview/ipAddressManager.json#L90-L91

confirmed no breaking change between this version to future stable version.

teowa commented 3 weeks ago

Building fails with below error while running importer-rest-api-specs

2024-08-22T02:39:47.780Z [INFO]  Importer for Service "Network"
2024-08-22T02:41:50.202Z [INFO]  ❌ Service "Network" - Api Version "2024-01-01-preview"
Error: -22T02:41:50.202Z [ERROR]      💥 Error: parsing Swagger files: parsing files in "../../submodules/rest-api-specs/specification/network/resource-manager/Microsoft.Network/preview/2024-01-01-preview": parsing definition: finding resources for tag "AdminRules": finding nested items yet to be parsed: appending model: appending constants: conflicting constant "ProvisioningState" with different values. First: map[Canceled:Canceled Creating:Creating Deleting:Deleting Failed:Failed Succeeded:Succeeded Updating:Updating]. Second: map[Deleting:Deleting Failed:Failed Succeeded:Succeeded Updating:Updating]

because there is more than one ProvisioningState in two swagger json files under network@2024-01-01-preview https://github.com/Azure/azure-rest-api-specs/blob/ba268c5654f002bc17914e0bc157f19529f1fec1/specification/network/resource-manager/Microsoft.Network/preview/2024-01-01-preview/network.json#L464

https://github.com/Azure/azure-rest-api-specs/blob/ba268c5654f002bc17914e0bc157f19529f1fec1/specification/network/resource-manager/Microsoft.Network/preview/2024-01-01-preview/ipAddressManager.json#L994

Is there any way we can resolve this?

teowa commented 2 weeks ago

After some debug, this is because after analysis.Flatten https://github.com/hashicorp/pandora/blob/49c3c7a9da36b3fea35e96c4112e0071bf2b41b3/tools/importer-rest-api-specs/components/parser/flattener.go#L34-L46 in below code block, there will be one provisioningState and one ProvisioningState in d.swaggerSpecRaw.Definitions

ProvisioningState [Failed Succeeded Canceled Creating Updating Deleting]
provisioningState [Succeeded Updating Deleting Failed]

ProvisioningState with 6 values is used in networkManagerSecurityAdminConfiguration.json but provisioningState with 4 values is never used in the file. Below shows model name and its Enum values before and after analysis.Flatten

parsing ../../submodules/rest-api-specs/specification/network/resource-manager/Microsoft.Network/preview/2024-01-01-preview /networkManagerSecurityAdminConfiguration.json

--- before flatten /networkManagerSecurityAdminConfiguration.json ---
Access [Allow Deny]
AddressPrefixItem []
AddressSpaceAggregationOption [None Manual]
AdminPropertiesFormat []
AdminRule []
AdminRuleCollection []
AdminRuleCollectionListResult []
AdminRuleCollectionPropertiesFormat []
AdminRuleListResult []
AuthenticationMethod [EAPTLS EAPMSCHAPv2]
AzureAsyncOperationResult []
BaseAdminRule []
ChildResource []
CloudError []
CloudErrorBody []
CommonErrorAdditionalInfo []
CommonErrorDetail []
CommonErrorResponse []
CommonProxyResource []
CommonResource []
CommonTrackedResource []
ConfigurationType [SecurityAdmin Connectivity]
CrossTenantScopes []
DefaultAdminPropertiesFormat []
DefaultAdminRule []
Error []
ErrorDetails []
ExtendedLocation []
ExtendedLocationType [EdgeZone]
IPAllocationMethod [Static Dynamic]
IPVersion [IPv4 IPv6]
ManagedServiceIdentity []
NetworkIntentPolicyBasedService [None All AllowRulesOnly]
NetworkManager []
NetworkManagerCommit []
NetworkManagerDeploymentStatus []
NetworkManagerDeploymentStatusListResult []
NetworkManagerDeploymentStatusParameter []
NetworkManagerListResult []
NetworkManagerProperties []
NetworkManagerSecurityGroupItem []
PatchObject []
ProvisioningState [Failed Succeeded Canceled Creating Updating Deleting]
Resource []
RuleProtocol [Tcp Udp Icmp Esp Any Ah]
SecurityAdminConfiguration []
SecurityAdminConfigurationListResult []
SecurityAdminConfigurationPropertiesFormat []
SecurityConfigurationRuleAccess [Allow Deny AlwaysAllow]
SecurityConfigurationRuleDirection [Inbound Outbound]
SubResource []
SystemData []
TagsObject []

--- after flatten /networkManagerSecurityAdminConfiguration.json ---
Access [Allow Deny]
AddressPrefixItem []
AddressSpaceAggregationOption [None Manual]
AdminPropertiesFormat []
AdminRule []
AdminRuleCollection []
AdminRuleCollectionListResult []
AdminRuleCollectionPropertiesFormat []
AdminRuleListResult []
AuthenticationMethod [EAPTLS EAPMSCHAPv2]
AzureAsyncOperationResult []
BaseAdminRule []
ChildResource []
CloudError []
CloudErrorBody []
CommonErrorAdditionalInfo []
CommonErrorDetail []
CommonErrorResponse []
CommonProxyResource []
CommonResource []
CommonTrackedResource []
ConfigurationType [SecurityAdmin Connectivity]
CrossTenantScopes []
DefaultAdminPropertiesFormat []
DefaultAdminRule []
Error []
ErrorDetails []
ExtendedLocation []
ExtendedLocationType [EdgeZone]
IPAllocationMethod [Static Dynamic]
IPVersion [IPv4 IPv6]
ManagedServiceIdentity []
NetworkIntentPolicyBasedService [None All AllowRulesOnly]
NetworkManager []
NetworkManagerCommit []
NetworkManagerDeploymentStatus []
NetworkManagerDeploymentStatusListResult []
NetworkManagerDeploymentStatusParameter []
NetworkManagerListResult []
NetworkManagerProperties []
NetworkManagerSecurityGroupItem []
PatchObject []
ProvisioningState [Failed Succeeded Canceled Creating Updating Deleting]
Resource []
RuleProtocol [Tcp Udp Icmp Esp Any Ah]
SecurityAdminConfiguration []
SecurityAdminConfigurationListResult []
SecurityAdminConfigurationPropertiesFormat []
SecurityConfigurationRuleAccess [Allow Deny AlwaysAllow]
SecurityConfigurationRuleDirection [Inbound Outbound]
SubResource []
SystemData []
TagsObject []
+cloudError []
+cloudErrorBody []
+commonErrorAdditionalInfo []
+commonErrorDetail []
+commonErrorResponse []
+commonProxyResource []
+commonResource []
+provisioningState [Succeeded Updating Deleting Failed]
+resource []
+systemData []

NOTE the green part is generated by analysis.Flatten Not sure if there is bug in upstream package https://github.com/go-openapi/analysis Then in https://github.com/hashicorp/pandora/blob/49c3c7a9da36b3fea35e96c4112e0071bf2b41b3/tools/importer-rest-api-specs/components/parser/models.go#L363-L369, strings.EqualFold(modelName, name) is used, thus may lead to two conflict enum.