From 9597cc68a7984901366c8bf5a8eeaff1e69b5af8 Mon Sep 17 00:00:00 2001 From: "Grot (@grafanabot)" <43478413+grafanabot@users.noreply.github.com> Date: Mon, 11 Apr 2022 07:08:36 -0600 Subject: [PATCH] chore: remove golang.org/x/net/context in favor of stdlib (#47532) (#47558) This PR removes golang.org context imports under pkg/services/* and replaces them with the stdlib context. Closes #44178 (cherry picked from commit bda3dd24e44f5f5805259b562feb9ecd9cefac73) Co-authored-by: Kristin Laemmert --- pkg/services/notifications/webhook.go | 6 ++---- pkg/services/provisioning/notifiers/alert_notifications.go | 3 ++- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/pkg/services/notifications/webhook.go b/pkg/services/notifications/webhook.go index 2ea0ea19048..9c790c3c549 100644 --- a/pkg/services/notifications/webhook.go +++ b/pkg/services/notifications/webhook.go @@ -11,8 +11,6 @@ import ( "net/http" "time" - "golang.org/x/net/context/ctxhttp" - "github.com/grafana/grafana/pkg/util" ) @@ -52,7 +50,7 @@ func (ns *NotificationService) sendWebRequestSync(ctx context.Context, webhook * return fmt.Errorf("webhook only supports HTTP methods PUT or POST") } - request, err := http.NewRequest(webhook.HttpMethod, webhook.Url, bytes.NewReader([]byte(webhook.Body))) + request, err := http.NewRequestWithContext(ctx, webhook.HttpMethod, webhook.Url, bytes.NewReader([]byte(webhook.Body))) if err != nil { return err } @@ -72,7 +70,7 @@ func (ns *NotificationService) sendWebRequestSync(ctx context.Context, webhook * request.Header.Set(k, v) } - resp, err := ctxhttp.Do(ctx, netClient, request) + resp, err := netClient.Do(request) if err != nil { return err } diff --git a/pkg/services/provisioning/notifiers/alert_notifications.go b/pkg/services/provisioning/notifiers/alert_notifications.go index aac68649cda..de1621a7177 100644 --- a/pkg/services/provisioning/notifiers/alert_notifications.go +++ b/pkg/services/provisioning/notifiers/alert_notifications.go @@ -1,11 +1,12 @@ package notifiers import ( + "context" + "github.com/grafana/grafana/pkg/infra/log" "github.com/grafana/grafana/pkg/models" "github.com/grafana/grafana/pkg/services/encryption" "github.com/grafana/grafana/pkg/services/notifications" - "golang.org/x/net/context" ) type Manager interface {