Skip to content

Commit

Permalink
upgrade to latest dependencies
Browse files Browse the repository at this point in the history
bumping knative.dev/reconciler-test 6e00c29...a7237b0:
  > a7237b0 Use the Request in Forwarder directly (# 575)

Signed-off-by: Knative Automation <[email protected]>
  • Loading branch information
knative-automation committed Aug 11, 2023
1 parent abba035 commit 1648811
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 17 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ require (
knative.dev/hack v0.0.0-20230809013436-ab12e24b8c13
knative.dev/hack/schema v0.0.0-20230809013436-ab12e24b8c13
knative.dev/pkg v0.0.0-20230809013237-cceb144872f7
knative.dev/reconciler-test v0.0.0-20230809113634-6e00c293c065
knative.dev/reconciler-test v0.0.0-20230810072538-a7237b013cbb
sigs.k8s.io/yaml v1.3.0
)

Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -901,8 +901,8 @@ knative.dev/hack/schema v0.0.0-20230809013436-ab12e24b8c13 h1:ECgvl8NGeFM1RhIWcY
knative.dev/hack/schema v0.0.0-20230809013436-ab12e24b8c13/go.mod h1:GeIb+PLd5mllawcpHEGF5J5fYTQrvgEO5liao8lUKUs=
knative.dev/pkg v0.0.0-20230809013237-cceb144872f7 h1:QbvbP7Mq1iLLVxKYqj/BEp9rnwCeRuWvLG8IGao+KIo=
knative.dev/pkg v0.0.0-20230809013237-cceb144872f7/go.mod h1:1TUywzFGQcoDUg/hrP4PRPh1Xaw7s5B9n0Kb0hrytJs=
knative.dev/reconciler-test v0.0.0-20230809113634-6e00c293c065 h1:RAaHGHVl0lfhGD+tbwVw7UMqK1U+RBT9nLqmjQCsLhQ=
knative.dev/reconciler-test v0.0.0-20230809113634-6e00c293c065/go.mod h1:i+/PWK/n3HPgjXMoj5U7CA6WRW/C3c3EfHCQ0FmrhNM=
knative.dev/reconciler-test v0.0.0-20230810072538-a7237b013cbb h1:XKIYY3OOzlzuN1hX3jc3UoJyIXe33bghVHyyhIpkr2A=
knative.dev/reconciler-test v0.0.0-20230810072538-a7237b013cbb/go.mod h1:i+/PWK/n3HPgjXMoj5U7CA6WRW/C3c3EfHCQ0FmrhNM=
pgregory.net/rapid v1.0.0 h1:iQaM2w5PZ6xvt6x7hbd7tiDS+nk7YPp5uCaEba+T/F4=
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"fmt"
"io/ioutil"
"net/http"
"net/url"
"strings"
"time"

Expand All @@ -29,7 +30,6 @@ import (
"go.opencensus.io/trace"
"go.uber.org/zap"

"github.com/cloudevents/sdk-go/v2/binding"
cehttp "github.com/cloudevents/sdk-go/v2/protocol/http"
cloudeventshttp "github.com/cloudevents/sdk-go/v2/protocol/http"
"github.com/kelseyhightower/envconfig"
Expand Down Expand Up @@ -131,14 +131,10 @@ func (o *Forwarder) ServeHTTP(writer http.ResponseWriter, request *http.Request)

event, eventErr := cloudeventsbindings.ToEvent(context.TODO(), m)
receivedHeaders := make(http.Header)
headersToBeSent := make(http.Header)
for k, v := range request.Header {
if !strings.HasPrefix(k, "Ce-") {
receivedHeaders[k] = v
}
if strings.HasPrefix(k, "Kn-") {
headersToBeSent[k] = v
}
}
// Host header is removed from the request.Header map by net/http
if request.Host != "" {
Expand All @@ -165,17 +161,15 @@ func (o *Forwarder) ServeHTTP(writer http.ResponseWriter, request *http.Request)
logging.FromContext(o.ctx).Fatalw("Error while venting the received event", zap.Error(err))
}

req, err := http.NewRequestWithContext(requestCtx, http.MethodPost, o.Sink, nil)
if err != nil {
logging.FromContext(o.ctx).Error("Cannot create the request: ", err)
}

req.Header = headersToBeSent
req := request.Clone(requestCtx)
// It is an error to set this field in an HTTP client request.
req.RequestURI = ""

err = cehttp.WriteRequest(requestCtx, binding.ToMessage(event), req)
u, err := url.Parse(o.Sink)
if err != nil {
logging.FromContext(o.ctx).Error("Cannot write the event: ", err)
logging.FromContext(o.ctx).Fatalw("Unable to parse sink URL", zap.Error(err))
}
req.URL = u

eventString := "unknown"
if event != nil {
Expand Down
2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1323,7 +1323,7 @@ knative.dev/pkg/webhook/resourcesemantics
knative.dev/pkg/webhook/resourcesemantics/conversion
knative.dev/pkg/webhook/resourcesemantics/defaulting
knative.dev/pkg/webhook/resourcesemantics/validation
# knative.dev/reconciler-test v0.0.0-20230809113634-6e00c293c065
# knative.dev/reconciler-test v0.0.0-20230810072538-a7237b013cbb
## explicit; go 1.18
knative.dev/reconciler-test/cmd/eventshub
knative.dev/reconciler-test/pkg/environment
Expand Down

0 comments on commit 1648811

Please sign in to comment.