Skip to content

Commit

Permalink
bugfix: the generated resources are not in the correct order
Browse files Browse the repository at this point in the history
  • Loading branch information
ms-henglu committed Nov 17, 2023
1 parent 77fe05b commit 247f5ed
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ BUG FIXES:
- Fix the bug that resource types with same name but different casing are not handled correctly.
- Fix the bug that coverage reports are generated even if there are no valid test cases.
- Fix the bug that other dependency resolvers are not called when error occurs in the previous dependency resolver.
- Fix the bug that the generated resources are not in the correct order.

## v0.12.0
FEATURES:
Expand Down
22 changes: 16 additions & 6 deletions commands/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,20 +365,30 @@ func (c *GenerateCommand) generate(apiPaths []swagger.ApiPath) int {
}

func azapiDefinitionOrder(azapiDefinition types.AzapiDefinition) int {
// 0. resource.azapi_resource
// 1. resource.azapi_update_resource Note: Now it will not be generated
// 2. azapi_resource_action with empty action
// 3. azapi_resource_action with action
// 4. data.azapi_resource
// 5. azapi_resource_list

switch azapiDefinition.ResourceName {
case "azapi_resource":
return 0
if azapiDefinition.Kind == types.KindResource {
return 0
}
return 4
case "azapi_update_resource":
return 2
return 1
case "azapi_resource_action":
if actionField := azapiDefinition.AdditionalFields["action"]; actionField == nil || actionField.String() == "" {
return 1
if actionField := azapiDefinition.AdditionalFields["action"]; actionField == nil || actionField.String() == `""` {
return 2
}
return 3
case "azapi_resource_list":
return 4
return 5
}
return 5
return 6
}

func appendContent(filename string, hclContent string) error {
Expand Down

0 comments on commit 247f5ed

Please sign in to comment.