Skip to content
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

[main] Upgrade to latest dependencies #7891

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ require (
knative.dev/hack v0.0.0-20240426013324-abdcdea830f0
knative.dev/hack/schema v0.0.0-20240426013324-abdcdea830f0
knative.dev/pkg v0.0.0-20240429080158-b69fa2713537
knative.dev/reconciler-test v0.0.0-20240501131019-eee0b8a44824
knative.dev/reconciler-test v0.0.0-20240503135940-d08dcf83a7db
sigs.k8s.io/yaml v1.4.0
)

Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -893,8 +893,8 @@ knative.dev/hack/schema v0.0.0-20240426013324-abdcdea830f0 h1:FWVyGpYNPdw1xrlUyr
knative.dev/hack/schema v0.0.0-20240426013324-abdcdea830f0/go.mod h1:3pWwBLnTZSM9psSgCAvhKOHIPTzqfEMlWRpDu6IYhK0=
knative.dev/pkg v0.0.0-20240429080158-b69fa2713537 h1:ZCAOdzhvd0XiXFc8FiEMeLhRtm2W3WRIoX4UnYaoRGo=
knative.dev/pkg v0.0.0-20240429080158-b69fa2713537/go.mod h1:w+HoJjceYoRP+xvxtOPlXRO/NIVe8Ca/CO3EAKFAbvo=
knative.dev/reconciler-test v0.0.0-20240501131019-eee0b8a44824 h1:z8WX0QN+59Z6Ma0aTMf9Cr3eFWFmY/FYo7++naJ1e0k=
knative.dev/reconciler-test v0.0.0-20240501131019-eee0b8a44824/go.mod h1:xrX67/nfPlCu0UAt9OHCpI1ZlAF0rqLA5hZrB/xu63s=
knative.dev/reconciler-test v0.0.0-20240503135940-d08dcf83a7db h1:nknSCTiHvTUc9LKffJR6WZ8mxdSI8TlLGd9lZS0il7c=
knative.dev/reconciler-test v0.0.0-20240503135940-d08dcf83a7db/go.mod h1:ctOcB7Yj+TAJ3f+jp+qoyAHnmT0GqzaTABZWSoE5Jrs=
pgregory.net/rapid v1.1.0 h1:CMa0sjHSru3puNx+J0MIAuiiEV4N0qj8/cMWGBBCsjw=
pgregory.net/rapid v1.1.0/go.mod h1:PY5XlDGj0+V1FCq0o192FdRhpKHGTRIWBgqjDBTrq04=
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,17 @@ limitations under the License.
package forwarder

import (
"bytes"
"context"
"fmt"
"io"
"io/ioutil"
"net/http"
"net/url"
"strings"
"time"

cloudevents "github.com/cloudevents/sdk-go/v2"
"github.com/cloudevents/sdk-go/v2/binding"
cloudeventsbindings "github.com/cloudevents/sdk-go/v2/binding"
"go.opencensus.io/trace"
"go.uber.org/zap"
Expand Down Expand Up @@ -127,10 +128,21 @@ func (o *Forwarder) ServeHTTP(writer http.ResponseWriter, request *http.Request)
requestCtx, span := trace.StartSpan(request.Context(), "eventshub-forwarder")
defer span.End()

body, err := io.ReadAll(request.Body)
if err != nil {
writer.WriteHeader(http.StatusInternalServerError)
logging.FromContext(o.ctx).Errorw("Failed to read request body", zap.Error(err))
return
}
_ = request.Body.Close()
request.Body = io.NopCloser(bytes.NewBuffer(body))

m := cloudeventshttp.NewMessageFromHttpRequest(request)
defer m.Finish(nil)

event, eventErr := cloudeventsbindings.ToEvent(context.TODO(), m)
request.Body = io.NopCloser(bytes.NewBuffer(body)) // reset body

receivedHeaders := make(http.Header)
for k, v := range request.Header {
if !strings.HasPrefix(k, "Ce-") {
Expand Down Expand Up @@ -174,11 +186,6 @@ func (o *Forwarder) ServeHTTP(writer http.ResponseWriter, request *http.Request)
}
req.URL = u

err = cehttp.WriteRequest(requestCtx, binding.ToMessage(event), req)
if err != nil {
logging.FromContext(o.ctx).Error("Cannot write the event to request: ", err)
}

eventString := "unknown"
if event != nil {
eventString = event.String()
Expand All @@ -202,7 +209,7 @@ func (o *Forwarder) ServeHTTP(writer http.ResponseWriter, request *http.Request)
}
}

writer.WriteHeader(http.StatusAccepted)
writer.WriteHeader(res.StatusCode)
}

func (o *Forwarder) sentInfo(event *cloudevents.Event, req *http.Request, err error) eventshub.EventInfo {
Expand Down
2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1397,7 +1397,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-20240501131019-eee0b8a44824
# knative.dev/reconciler-test v0.0.0-20240503135940-d08dcf83a7db
## explicit; go 1.21
knative.dev/reconciler-test/cmd/eventshub
knative.dev/reconciler-test/pkg/environment
Expand Down
Loading