TPT-4423: Drop resty as a dependency#938
TPT-4423: Drop resty as a dependency#938ezilber-akamai wants to merge 9 commits intolinode:proj/linodego_v2from
Conversation
…ade additional changes to monitor client
cab2905 to
1cd0216
Compare
1cd0216 to
1ae5e50
Compare
a3f8375 to
026d0b6
Compare
There was a problem hiding this comment.
Pull request overview
Removes the resty dependency by migrating the LinodeGo client stack (request execution, retries, pagination, logging, and related tests) to net/http, and updates fixtures/tests accordingly.
Changes:
- Replaces Resty-based request/retry/pagination/logging helpers with
net/httpequivalents. - Updates unit/integration tests and fixtures to match new request shapes (e.g., explicit
page=1). - Drops
restyfrom root/k8s/test modules and removes now-obsoleteretries_http*code.
Reviewed changes
Copilot reviewed 28 out of 31 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
client.go |
Reworks core client to use net/http, adds retry plumbing, request/response logging via embedded templates. |
client_http.go |
Removes old httpClient wrapper type. |
client_monitor.go |
Migrates Monitor client from Resty to net/http + new request helper. |
errors.go |
Replaces Resty error handling with http.Response-based parsing/formatting. |
errors_test.go |
Updates error tests for new http.Response error path. |
retries.go |
Ports retry conditionals and Retry-After handling to net/http. |
retries_test.go |
Updates retry tests to build http.Response objects directly. |
retries_http.go |
Removes unused/obsolete HTTP retry implementation. |
retries_http_test.go |
Removes tests for the deleted retries_http.go. |
pagination.go |
Changes list options application to an *http.Request mutator. |
request_helpers.go |
Migrates generic request helpers and pagination execution to client.doRequest. |
request_helpers_test.go |
Adjusts request helper tests to new request behavior. |
logger.go |
Introduces internal Logger interface and removes “RESTY” prefixes. |
request_log_template.tmpl |
Adds request log template used by embedded logging. |
response_log_template.tmpl |
Adds response log template used by embedded logging. |
images.go |
Replaces Resty upload-to-URL logic with raw net/http PUT. |
test/unit/images_test.go |
Adds default-transport httpmock activation for upload-to-URL PUT mock. |
monitor_api_services.go |
Migrates monitor metrics request to net/http request params. |
monitor_alert_definitions.go |
Migrates alert definition create flow to net/http + per-request headers. |
test/integration/maintenance_test.go |
Switches integration test to ListMaintenancePolicies API call. |
test/integration/fixtures/TestMaintenancePolicies_List.yaml |
Updates recorded interaction (adds ?page=1, header/body deltas). |
test/integration/cache_test.go |
Updates request inspection to use http.Request.URL.Query(). |
internal/testutil/mock.go |
Keeps test logger output consistent without “RESTY” prefixes. |
client_test.go |
Updates client tests for new fields and doRequest signature/behavior. |
config_test.go |
Updates config tests to check hostURL/header instead of Resty fields. |
go.mod / go.sum |
Drops github.com/go-resty/resty/v2 (and related sum entries). |
k8s/go.mod / k8s/go.sum |
Drops github.com/go-resty/resty/v2 from k8s module. |
test/go.mod / test/go.sum |
Drops github.com/go-resty/resty/v2 from test module. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
169d9f1 to
0cebc58
Compare
There was a problem hiding this comment.
Pull request overview
This PR removes the resty dependency from linodego by porting request execution, retries, error handling, and debug logging to net/http, and updates unit/integration tests and fixtures accordingly.
Changes:
- Replaced Resty-based request/retry/logging pipeline with a
net/httpimplementation (including templated debug request/response logging). - Updated pagination/request helpers and monitor-client code paths to use the new HTTP request layer.
- Removed
restyfrom module dependencies and updated tests/fixtures to match new request behavior (e.g., page=1 query param).
Reviewed changes
Copilot reviewed 28 out of 31 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| client.go | Core client rewrite to net/http, including retries and debug logging templates (go:embed). |
| client_http.go | Removes the old httpClient wrapper type. |
| client_monitor.go | Monitor client ported from Resty to net/http, including custom root CA handling and request execution. |
| retries.go | Retry conditionals/Retry-After logic ported to operate on *http.Response. |
| retries_http.go | Removes the separate HTTP retry implementation. |
| errors.go | Error coupling now operates on *http.Response instead of Resty response types. |
| images.go | Upload-to-URL now uses net/http (including content-length handling) instead of Resty. |
| pagination.go | List option application moved to an *http.Request mutator. |
| request_helpers.go | Request helper methods ported to call Client.doRequest. |
| logger.go | Introduces a custom logger interface/impl and adds log-injection sanitization. |
| request_log_template.tmpl | New embedded request log template for debug logging. |
| response_log_template.tmpl | New embedded response log template for debug logging. |
| internal/testutil/mock.go | Adjusts test logger formatting to match new logger prefixes. |
| request_helpers_test.go | Formatting-only updates for httpmock responder registration. |
| retries_test.go | Tests updated to use *http.Response and exported retry helpers; removes Resty usage. |
| retries_http_test.go | Removes old HTTP retry tests. |
| errors_test.go | Updates tests to build *http.Response-based error cases and use new coupling paths. |
| client_test.go | Updates tests for new fields (hostURL/header/debug) and doRequest calling patterns. |
| config_test.go | Updates tests to assert hostURL/header instead of Resty client fields. |
| monitor_api_services.go | Uses MonitorClient doRequest with net/http. |
| monitor_alert_definitions.go | Uses Client.doRequest and per-request headers for idempotency key. |
| test/unit/images_test.go | Adds httpmock activation for default transport to cover upload PUT to external URL. |
| test/integration/cache_test.go | Updates request inspection to use request.URL.Query() / request.URL.String(). |
| test/integration/maintenance_test.go | Migrates from direct request/JSON parsing to ListMaintenancePolicies. |
| test/integration/fixtures/TestMaintenancePolicies_List.yaml | Fixture updated for new pagination query behavior and recorded headers. |
| go.mod / go.sum | Removes github.com/go-resty/resty/v2 (and related sums). |
| k8s/go.mod / k8s/go.sum | Removes github.com/go-resty/resty/v2 (and related sums) in k8s module. |
| test/go.mod / test/go.sum | Removes github.com/go-resty/resty/v2 (and related sums) in test module. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
📝 Description
Ported the old resty removal code from outdated linodego_v2 branch to the new up-to-date one.
✔️ How to Test
make test-unitmake test-int