Move PostJSONWithTimeout to platform/http package and activity cleanup (#40561)
<!-- Add the related story/sub-task/bug number, like Resolves #123, or remove if NA --> **Related issue:** Resolves #38536 - Moved PostJSONWithTimeout to platform/http - Created platform/errors package with only types needed by ctxerr. This way, ctxerr did not need to import fleethttp. - Made activity bounded context use PostJSONWithTimeout directly - Removed some activity types from legacy code that were no longer needed # Checklist for submitter - [ ] Changes file added for user-visible changes in `changes/`, `orbit/changes/` or `ee/fleetd-chrome/changes`. - Changes file `38536-new-activity-bc` already present, and this is just cleanup from that work. ## Testing - [x] Added/updated automated tests - [x] QA'd all new/changed functionality manually <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Release Notes * **Refactor** * Reorganized error handling utilities for improved clarity and decoupling. * Consolidated HTTP utilities to centralize JSON posting functionality with timeout support. * Simplified activity service initialization by removing unused internal parameters. * Cleaned up test utilities and removed webhook-related test scaffolding. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -21,7 +21,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
platform_http "github.com/fleetdm/fleet/v4/server/platform/http"
|
||||
platform_errors "github.com/fleetdm/fleet/v4/server/platform/errors"
|
||||
"github.com/getsentry/sentry-go"
|
||||
"go.elastic.co/apm/v2"
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
@@ -202,7 +202,7 @@ func Wrapf(ctx context.Context, cause error, format string, args ...interface{})
|
||||
|
||||
// Cause returns the root error in err's chain.
|
||||
func Cause(err error) error {
|
||||
return platform_http.Cause(err)
|
||||
return platform_errors.Cause(err)
|
||||
}
|
||||
|
||||
// FleetCause is similar to Cause, but returns the root-most
|
||||
@@ -407,7 +407,7 @@ func isClientError(err error) bool {
|
||||
// Check for explicit client error interface. All 4xx error types
|
||||
// (not found, already exists, conflict, validation, permission,
|
||||
// bad request, foreign key, etc.) should implement this interface.
|
||||
var clientErr platform_http.ErrWithIsClientError
|
||||
var clientErr platform_errors.ErrWithIsClientError
|
||||
if errors.As(err, &clientErr) {
|
||||
return clientErr.IsClientError()
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
platform_errors "github.com/fleetdm/fleet/v4/server/platform/errors"
|
||||
platform_http "github.com/fleetdm/fleet/v4/server/platform/http"
|
||||
kithttp "github.com/go-kit/kit/transport/http"
|
||||
)
|
||||
@@ -233,7 +234,7 @@ func (l *LoggingContext) setLevelError() bool {
|
||||
}
|
||||
|
||||
if len(l.Errs) == 1 {
|
||||
var ew platform_http.ErrWithIsClientError
|
||||
var ew platform_errors.ErrWithIsClientError
|
||||
if errors.As(l.Errs[0], &ew) && ew.IsClientError() {
|
||||
return false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user