- 
                Notifications
    
You must be signed in to change notification settings  - Fork 208
 
chore: Support LRO value from response in autogen resources #3829
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR improves the autogenerated resource code generation toolchain to support LRO (Long Running Operations) value from response and enhances error handling. It also generates a new search_index_api resource based on the MongoDB Atlas Search Index API.
- Enhanced code generation with better error handling and surface previously ignored errors
 - Updated log message format to be consistent with INFO/WARN/ERROR prefixes
 - Improved LRO handling by making CallParams functions accept generic models instead of specific types
 
Reviewed Changes
Copilot reviewed 31 out of 31 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description | 
|---|---|
| tools/codegen/models/search_index_api.yaml | New autogenerated resource model for search index API | 
| tools/codegen/main.go | Updated log messages to use standardized ERROR/WARN/INFO prefixes | 
| tools/codegen/codespec/api_to_provider_spec_mapper.go | Enhanced error handling and propagation for better debugging | 
| tools/codegen/codespec/api_spec.go | Added schema type inference for objects without explicit types | 
| tools/codegen/gofilegen/resource/testdata/ | Updated generated code to use function-based CallParams | 
| tools/codegen/gofilegen/codetemplate/resource-file.go.tmpl | Modified template to generate function-based CallParams handlers | 
| internal/serviceapi/searchindexapi/ | New generated search index API resource implementation | 
| internal/common/autogen/handle_operations.go | Updated LRO handling to support function-based CallParams | 
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
        
          
                tools/codegen/config.yml
              
                Outdated
          
        
      | method: DELETE | ||
| version_header: application/vnd.atlas.2024-05-30+json | ||
| schema: | ||
| use_custom_nested_types: false # TODO: investigate, prevents a panic in basetypes.ListValue.ToTerraformValue while creating the index | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in: #3833
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
enabled here: d0c8298
| MinTimeout: time.Duration(wait.MinTimeoutSeconds) * time.Second, | ||
| Delay: time.Duration(wait.DelaySeconds) * time.Second, | ||
| Refresh: refreshFunc(ctx, wait, client), | ||
| Refresh: refreshFunc(ctx, wait, client, model), | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. Wonder if we will ever need to expose retry.StateChangeConf{ContinuousTargetOccurence: {CUSTOM_VALUE}} in the future. I can imagine it will improve some of our acceptance tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure I understand, can you explain in more detail?
| 
               | 
          ||
| type WaitReq struct { | ||
| CallParams *config.APICallParams | ||
| CallParams func(model any) *config.APICallParams | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this any cannot be replaced with TFModel, but will always be TFModel? Maybe worth documenting
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
| aliases: | ||
| indexId: IndexID # path param name does not match the API response property | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch
| // Infer object type when type is not explicitly defined but properties exist. | ||
| // This handles cases like BaseSearchIndexCreateRequestDefinition and BaseSearchIndexResponseLatestDefinition which have properties but no explicit type. | ||
| // This case can be removed after CLOUDP-355777 is done. | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
| } | ||
| 
               | 
          ||
| func opRequestToAttributes(op *high.Operation, useCustomNestedTypes bool) Attributes { | ||
| func opRequestToAttributes(op *high.Operation, useCustomNestedTypes bool) (Attributes, error) { | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good! We need to keep changing all these warns to errors and just fail the generation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, see the PR description for more info
Description
Support LRO value from response in autogen resources.
index_is, for Get and Delete operations from Createsearch_index_apiresourceLink to any related issue(s): CLOUDP-352320
Type of change:
Required Checklist:
Further comments