-
Notifications
You must be signed in to change notification settings - Fork 209
chore: Adds provider_meta support to all data sources #3868
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
base: master
Are you sure you want to change the base?
Conversation
Adds provider_meta support to all data sources (TPF and SDKv2) for module usage tracking via User-Agent headers. Follows the same pattern as resources (PR #3618). - Created datasource_base.go for data source analytics in TPF - Added SetClient() method pattern matching resources - Shared asUserAgentExtraFromProviderMeta() between resources and data sources
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 adds provider_meta support to all data sources (both TPF and SDKv2) to enable module usage tracking via User-Agent headers, following the same pattern previously implemented for resources.
Key changes:
- Created new
datasource_base.gofile for TPF data source analytics tracking - Extended
NewAnalyticsResourceSDKv2to support both resources and data sources viaisDataSourceparameter - Refactored User-Agent extra logic into shared
asUserAgentExtraFromProviderMetafunction
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| internal/provider/provider_sdk2.go | Wraps SDKv2 data sources with analytics support and updates resource wrapping to pass isDataSource=false |
| internal/provider/provider.go | Wraps TPF data sources with analytics support using new AnalyticsDataSourceFunc |
| internal/config/user_agent.go | Adds userAgentNameValueDataSource helper to format data source names with "data." prefix |
| internal/config/resource_base_sdkv2.go | Extracts analytics logic into shared updateContextWithProviderMetaSDKv2 function supporting both resources and data sources |
| internal/config/resource_base.go | Refactors to use shared asUserAgentExtraFromProviderMeta function and removes DSCommon (moved to datasource_base.go) |
| internal/config/datasource_base.go | New file implementing DSCommon with analytics wrapper pattern for TPF data sources |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // When embedded, the data source's own Schema method is used | ||
| } | ||
|
|
||
| func (d *DSCommon) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { |
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.
should we have some tests or will be (indirectly) tested with all acc 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.
Correct, tested indirectly.
AgustinBettati
left a comment
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
Description
Adds provider_meta support to all data sources (TPF and SDKv2) for module usage tracking via User-Agent headers. Follows the same pattern as resources (PR #3618).
Link to any related issue(s): CLOUDP-340210
Type of change:
Required Checklist:
Further comments