Skip to content

Commit

Permalink
upgrade to latest dependencies
Browse files Browse the repository at this point in the history
bumping google.golang.org/api 4b79cc4...b49e3b9:
  > b49e3b9 chore(main): release 0.182.0 (# 2591)
  > b6f615b chore(all): update all (# 2607)
  > c4c51ce feat(all): auto-regenerate discovery clients (# 2609)
  > 0e58f74 feat(all): auto-regenerate discovery clients (# 2608)
  > ceaeabf feat(all): auto-regenerate discovery clients (# 2606)
  > f474c8f feat(all): auto-regenerate discovery clients (# 2604)
  > ece7727 feat(all): auto-regenerate discovery clients (# 2603)
  > a86c4b6 feat(all): auto-regenerate discovery clients (# 2602)
  > 2e7cc39 feat(all): auto-regenerate discovery clients (# 2600)
  > 677f53d feat(all): auto-regenerate discovery clients (# 2599)
  > 7d46b4d feat(all): auto-regenerate discovery clients (# 2597)
  > 07e7104 feat(all): auto-regenerate discovery clients (# 2595)
  > 21295a5 feat(all): auto-regenerate discovery clients (# 2594)
  > e95bd57 feat(all): auto-regenerate discovery clients (# 2590)
bumping knative.dev/reconciler-test 1351b60...c3147c1:
  > c3147c1 upgrade to latest dependencies (# 734)
  > 1f340aa Fix `nil` pointer error in forwarder from file (# 733)
  > 2723f53 Allow forwarder to forward events from files (# 732)
  > fe1acf2 feat: eventshub sender can send to resources in other namespaces (# 731)
  > c8f73e2 upgrade to latest dependencies (# 729)
  > 5c0e9f6 Update community files (# 728)
bumping knative.dev/eventing 74253dd...3ee2400:
  > 3ee2400 fix: sequence updates subscription where possible, instead of recreating it (# 7948)
  > 96e0f09 Bump rekt to main (# 7958)
  > e3604b8 [main] Upgrade to latest dependencies (# 7957)
  > 08b0813 [main] Upgrade to latest dependencies (# 7956)
  > c53b44d [main] Format Go code (# 7953)
  > a58c135 Prototype a MQTT Source  (# 7919)
  > 39d2723 [main] Upgrade to latest dependencies (# 7950)
  > b9cba87 Add EventType v1beta3 conversion (# 7938)
  > 2a11bb8 [main] Update community files (# 7949)
  > 746dc52 fix: no more panic in the execute request method (# 7947)
  > abdbf14 Remove rekt test from GH actions e2e test run (# 7941)
  > a3a2ac0 Enable `eventtype-auto-create` feature flag for e2e tests (# 7940)
bumping knative.dev/pkg 99e1685...fce44ea:
  > fce44ea Maybe fix controller ha (# 3046)
  > 1709961 Bump google.golang.org/api from 0.181.0 to 0.182.0 (# 3048)
  > 229e527 fix: downstream tests assume release branch was cut (# 3047)
  > 7d52a43 drop special logic when handling kubelet probe header for istio mTLS (# 2997)
  > ff4756a Update community files (# 3044)
  > 5eeb7ec Skip lease with empty holder (# 3042)
bumping google.golang.org/genproto/googleapis/api b8a5c65...0867130:
  > 0867130 chore(all): auto-regenerate .pb.go files (# 1125)
  > 024948a chore(all): update all (# 1126)
  > 6275950 chore(all): auto-regenerate .pb.go files (# 1124)
bumping google.golang.org/genproto/googleapis/rpc 0867130...d264139:
  > d264139 chore(all): update all (# 1128)
  > dc85e6b chore(all): auto-regenerate .pb.go files (# 1129)
  > fc5f0ca chore: min Go version to 1.20 (# 1127)
bumping knative.dev/hack 68e3bfb...3b6d644:
  > 3b6d644 Update community files (# 383)

Signed-off-by: Knative Automation <automation@knative.team>
  • Loading branch information
knative-automation committed Jun 4, 2024
1 parent c7c016c commit 14ae9b3
Show file tree
Hide file tree
Showing 10 changed files with 220 additions and 42 deletions.
14 changes: 7 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ require (
k8s.io/client-go v0.29.2
k8s.io/code-generator v0.29.2
k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00
knative.dev/eventing v0.41.1-0.20240523103154-74253dd1c57a
knative.dev/hack v0.0.0-20240507013718-68e3bfb39d11
knative.dev/pkg v0.0.0-20240521083825-99e1685a7997
knative.dev/reconciler-test v0.0.0-20240523103149-1351b601972d
knative.dev/eventing v0.41.1-0.20240603163018-3ee2400189c1
knative.dev/hack v0.0.0-20240529131459-3b6d6441e7ea
knative.dev/pkg v0.0.0-20240603145758-fce44ead15bd
knative.dev/reconciler-test v0.0.0-20240603143331-c3147c12b459
sigs.k8s.io/controller-runtime v0.15.2
)

Expand Down Expand Up @@ -113,9 +113,9 @@ require (
golang.org/x/tools v0.21.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
gonum.org/v1/gonum v0.11.0 // indirect
google.golang.org/api v0.181.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240506185236-b8a5c65736ae // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240513163218-0867130af1f8 // indirect
google.golang.org/api v0.182.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240513163218-0867130af1f8 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240521202816-d264139d666e // indirect
google.golang.org/grpc v1.64.0 // indirect
google.golang.org/protobuf v1.34.1 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
Expand Down
28 changes: 14 additions & 14 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -723,8 +723,8 @@ google.golang.org/api v0.25.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0M
google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE=
google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM=
google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc=
google.golang.org/api v0.181.0 h1:rPdjwnWgiPPOJx3IcSAQ2III5aX5tCer6wMpa/xmZi4=
google.golang.org/api v0.181.0/go.mod h1:MnQ+M0CFsfUwA5beZ+g/vCBCPXvtmZwRz2qzZk8ih1k=
google.golang.org/api v0.182.0 h1:if5fPvudRQ78GeRx3RayIoiuV7modtErPIZC/T2bIvE=
google.golang.org/api v0.182.0/go.mod h1:cGhjy4caqA5yXRzEhkHI8Y9mfyC2VLTlER2l08xaqtM=
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
Expand Down Expand Up @@ -762,10 +762,10 @@ google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7Fc
google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
google.golang.org/genproto/googleapis/api v0.0.0-20240506185236-b8a5c65736ae h1:AH34z6WAGVNkllnKs5raNq3yRq93VnjBG6rpfub/jYk=
google.golang.org/genproto/googleapis/api v0.0.0-20240506185236-b8a5c65736ae/go.mod h1:FfiGhwUm6CJviekPrc0oJ+7h29e+DmWU6UtjX0ZvI7Y=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240513163218-0867130af1f8 h1:mxSlqyb8ZAHsYDCfiXN1EDdNTdvjUJSLY+OnAUtYNYA=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240513163218-0867130af1f8/go.mod h1:I7Y+G38R2bu5j1aLzfFmQfTcU/WnFuqDwLZAbvKTKpM=
google.golang.org/genproto/googleapis/api v0.0.0-20240513163218-0867130af1f8 h1:W5Xj/70xIA4x60O/IFyXivR5MGqblAb8R3w26pnD6No=
google.golang.org/genproto/googleapis/api v0.0.0-20240513163218-0867130af1f8/go.mod h1:vPrPUTsDCYxXWjP7clS81mZ6/803D8K4iM9Ma27VKas=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240521202816-d264139d666e h1:Elxv5MwEkCI9f5SkoL6afed6NTdxaGoAo39eANBwHL8=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240521202816-d264139d666e/go.mod h1:EfXuqaE1J41VCDicxHzUDm+8rk+7ZdXzHV0IhO/I6s0=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
google.golang.org/grpc v1.20.0/go.mod h1:chYK+tFQF0nDUGJgXMSgLCQk3phJEuONr2DCgLDdAQM=
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
Expand Down Expand Up @@ -849,14 +849,14 @@ k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 h1:aVUu9fTY98ivBPKR9Y5w/A
k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00/go.mod h1:AsvuZPBlUDVuCdzJ87iajxtXuR9oktsTctW/R9wwouA=
k8s.io/utils v0.0.0-20240102154912-e7106e64919e h1:eQ/4ljkx21sObifjzXwlPKpdGLrCfRziVtos3ofG/sQ=
k8s.io/utils v0.0.0-20240102154912-e7106e64919e/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
knative.dev/eventing v0.41.1-0.20240523103154-74253dd1c57a h1:FTDl2yRQgnp/ZmBmU66igmMspkoN7Lf2WxDijIWyOqs=
knative.dev/eventing v0.41.1-0.20240523103154-74253dd1c57a/go.mod h1:IUBpMsDIfyV5836R9PN0/VyADgoDa9ykgz7gpvTseLw=
knative.dev/hack v0.0.0-20240507013718-68e3bfb39d11 h1:CYoD72R8/R35REjeY2nnWfBak+Q3f+NxXwEfwcID1eU=
knative.dev/hack v0.0.0-20240507013718-68e3bfb39d11/go.mod h1:yk2OjGDsbEnQjfxdm0/HJKS2WqTLEFg/N6nUs6Rqx3Q=
knative.dev/pkg v0.0.0-20240521083825-99e1685a7997 h1:MN/u8ivos957WdihUjKfFw1Qv9HZ3+pe4TOwdYQiB2Q=
knative.dev/pkg v0.0.0-20240521083825-99e1685a7997/go.mod h1:GHFUP1wtD/bR/c02QADqaAK3odDJh1ddBMvXhq/goy8=
knative.dev/reconciler-test v0.0.0-20240523103149-1351b601972d h1:MhO1bvabteY0VjkS2MR0S6+VHCT+DByTIGTLodRBV48=
knative.dev/reconciler-test v0.0.0-20240523103149-1351b601972d/go.mod h1:IhLACQFqZDDTj34bY3Nte9tWWqc8KyahohdRGyeayRM=
knative.dev/eventing v0.41.1-0.20240603163018-3ee2400189c1 h1:udSFPuiXYxyRErU4hs7EJ2G6MmR+OW1uKbniILcIkJQ=
knative.dev/eventing v0.41.1-0.20240603163018-3ee2400189c1/go.mod h1:FO0xttJnXLgKrAGdkEvEqL7hBpmnUKGu2wMqKUC4p78=
knative.dev/hack v0.0.0-20240529131459-3b6d6441e7ea h1:iWW6SNMrVd2hI5Y+ltKIEzXVedoQLL86b23dS5fkvXs=
knative.dev/hack v0.0.0-20240529131459-3b6d6441e7ea/go.mod h1:yk2OjGDsbEnQjfxdm0/HJKS2WqTLEFg/N6nUs6Rqx3Q=
knative.dev/pkg v0.0.0-20240603145758-fce44ead15bd h1:SxwfJkmXwxl2PT5xZjtKKHO7URgHuigOoyzelaIGb2g=
knative.dev/pkg v0.0.0-20240603145758-fce44ead15bd/go.mod h1:E5OxJHFsQiW7pL0lVJ02XEVm2QUc0ZVdSUHiarUJHrU=
knative.dev/reconciler-test v0.0.0-20240603143331-c3147c12b459 h1:9MngfrMPaonqOxfJ23V45sWxJXBGdZhoGXN2NQJzbFI=
knative.dev/reconciler-test v0.0.0-20240603143331-c3147c12b459/go.mod h1:vn4ts7F9M2LrU07Sz0OQW3Ci92rv/JQ/4BW3crU7Xb4=
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

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,86 @@ package v1beta2

import (
"context"
"fmt"

"knative.dev/pkg/apis"
duckv1 "knative.dev/pkg/apis/duck/v1"

eventing "knative.dev/eventing/pkg/apis/eventing/v1"
"knative.dev/eventing/pkg/apis/eventing/v1beta3"
)

// ConvertTo implements apis.Convertible
// ConvertTo converts the receiver into `to`.
func (source *EventType) ConvertTo(ctx context.Context, to apis.Convertible) error {
return fmt.Errorf("v1beta2 is the highest known version, got: %T", to)
switch sink := to.(type) {
case *v1beta3.EventType:

source.ObjectMeta.DeepCopyInto(&sink.ObjectMeta)
source.Status.Status.DeepCopyInto(&sink.Status.Status)

sink.Spec.Reference = source.Spec.Reference.DeepCopy()
sink.Spec.Description = source.Spec.Description

if source.Spec.Reference == nil && source.Spec.Broker != "" {
source.Spec.Reference = &duckv1.KReference{
Kind: "Broker",
Name: source.Spec.Broker,
APIVersion: eventing.SchemeGroupVersion.String(),
}
}

sink.Spec.Attributes = []v1beta3.EventAttributeDefinition{}
if source.Spec.Type != "" {
sink.Spec.Attributes = append(sink.Spec.Attributes, v1beta3.EventAttributeDefinition{
Name: "type",
Required: true,
Value: source.Spec.Type,
})
}
if source.Spec.Schema != nil {
sink.Spec.Attributes = append(sink.Spec.Attributes, v1beta3.EventAttributeDefinition{
Name: "schemadata",
Required: false,
Value: source.Spec.Schema.String(),
})
}
if source.Spec.Source != nil {
sink.Spec.Attributes = append(sink.Spec.Attributes, v1beta3.EventAttributeDefinition{
Name: "source",
Required: true,
Value: source.Spec.Source.String(),
})
}
return nil
default:
return apis.ConvertToViaProxy(ctx, source, &v1beta3.EventType{}, to)
}

}

// ConvertFrom implements apis.Convertible
func (sink *EventType) ConvertFrom(ctx context.Context, from apis.Convertible) error {
return fmt.Errorf("v1beta2 is the highest known version, got: %T", from)
switch source := from.(type) {
case *v1beta3.EventType:

source.ObjectMeta.DeepCopyInto(&sink.ObjectMeta)
source.Status.Status.DeepCopyInto(&sink.Status.Status)

sink.Spec.Reference = source.Spec.Reference.DeepCopy()
sink.Spec.Description = source.Spec.Description

for _, at := range source.Spec.Attributes {
switch at.Name {
case "source":
sink.Spec.Source, _ = apis.ParseURL(at.Value)
case "type":
sink.Spec.Type = at.Value
case "schemadata":
sink.Spec.Schema, _ = apis.ParseURL(at.Value)
}
}

return nil
default:
return apis.ConvertFromViaProxy(ctx, from, &v1beta3.EventType{}, sink)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -289,11 +289,18 @@ func (d *Dispatcher) send(ctx context.Context, message binding.Message, destinat
}

func (d *Dispatcher) executeRequest(ctx context.Context, target duckv1.Addressable, message cloudevents.Message, additionalHeaders http.Header, retryConfig *RetryConfig, oidcServiceAccount *types.NamespacedName, transformers ...binding.Transformer) (context.Context, cloudevents.Message, *DispatchInfo, error) {
var scheme string
if target.URL != nil {
scheme = target.URL.Scheme
} else {
// assume that the scheme is http by default
scheme = "http"
}
dispatchInfo := DispatchInfo{
Duration: NoDuration,
ResponseCode: NoResponse,
ResponseHeader: make(http.Header),
Scheme: target.URL.Scheme,
Scheme: scheme,
}

ctx, span := trace.StartSpan(ctx, "knative.dev", trace.WithSpanKind(trace.SpanKindClient))
Expand Down
5 changes: 3 additions & 2 deletions vendor/knative.dev/pkg/network/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,12 @@ const (
// KubeletProbeHeaderName is the header name to augment the probes, because
// Istio with mTLS rewrites probes, but their probes pass a different
// user-agent.
//
// Deprecated: use knative.dev/networking/pkg/http/header.UserAgentKey
KubeletProbeHeaderName = "K-Kubelet-Probe"
)

// IsKubeletProbe returns true if the request is a Kubernetes probe.
func IsKubeletProbe(r *http.Request) bool {
return strings.HasPrefix(r.Header.Get(UserAgentKey), KubeProbeUAPrefix) ||
r.Header.Get(KubeletProbeHeaderName) != ""
return strings.HasPrefix(r.Header.Get(UserAgentKey), KubeProbeUAPrefix)
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ package forwarder
import (
"bytes"
"context"
"encoding/json"
"fmt"
"io"
"io/ioutil"
"net/http"
"net/url"
"os"
"strings"
"time"

Expand Down Expand Up @@ -51,6 +53,9 @@ type Forwarder struct {
// Sink
Sink string

// FromFiles allows forwarding JSON-formatted events that are present on specified files (comma separated list of file paths)
FromFiles string

// EventLogs is the list of EventLogger implementors to vent observed events.
EventLogs *eventshub.EventLogs

Expand All @@ -69,6 +74,9 @@ type envConfig struct {

// Sink url for the message destination
Sink string `envconfig:"SINK" required:"true"`

// FromFiles allows forwarding JSON-formatted events that are present on specified files (comma separated list of file paths)
FromFiles string `envconfig:"FROM_FILES" required:"false"`
}

func NewFromEnv(ctx context.Context, eventLogs *eventshub.EventLogs, handlerFuncs []eventshub.HandlerFunc, clientOpts []eventshub.ClientOption) *Forwarder {
Expand All @@ -83,6 +91,7 @@ func NewFromEnv(ctx context.Context, eventLogs *eventshub.EventLogs, handlerFunc
Name: env.Name,
Namespace: env.Namespace,
Sink: env.Sink,
FromFiles: env.FromFiles,
EventLogs: eventLogs,
ctx: ctx,
handlerFuncs: handlerFuncs,
Expand All @@ -106,6 +115,11 @@ func (o *Forwarder) Start(ctx context.Context) error {
handler = dec(handler)
}

if o.FromFiles != "" {
o.forwardFromFiles()
return nil
}

server := &http.Server{Addr: ":8080", Handler: handler}

var err error
Expand Down Expand Up @@ -277,3 +291,66 @@ func (o *Forwarder) responseInfo(res *http.Response, event *cloudevents.Event) e
}
return responseInfo
}

func (o *Forwarder) forwardFromFile(f string) {
b, err := os.ReadFile(f)
if err != nil {
logging.FromContext(o.ctx).Fatalw("Failed to read the file",
zap.String("file", f),
zap.Error(err))
}

event := &cloudevents.Event{}
if err := json.Unmarshal(b, event); err != nil {
logging.FromContext(o.ctx).Fatalw("Failed to unmarshal the event",
zap.String("file", f),
zap.Error(err))
}

eventInfo := eventshub.EventInfo{
Event: event,
Observer: o.Name,
Origin: f,
Time: time.Now(),
Kind: eventshub.EventSent,
}

// Log the event that is being forwarded
if err := o.EventLogs.Vent(eventInfo); err != nil {
logging.FromContext(o.ctx).Fatalw("Failed to vent the event",
zap.String("file", f),
zap.Error(err))
}

req, err := http.NewRequest("POST", o.Sink, nil)
if err != nil {
logging.FromContext(o.ctx).Fatalw("Failed to create the client request",
zap.String("file", f),
zap.Error(err))
}
if err := cehttp.WriteRequest(context.Background(), cloudevents.ToMessage(event), req); err != nil {
logging.FromContext(o.ctx).Fatalw("Failed to write the client request",
zap.String("file", f),
zap.Error(err))
}

res, err := o.httpClient.Do(req)
if err != nil {
logging.FromContext(o.ctx).Fatalw("Failed to forward the event",
zap.String("file", f),
zap.Error(err))
}

// Vent the response info
if err := o.EventLogs.Vent(o.responseInfo(res, event)); err != nil {
logging.FromContext(o.ctx).Errorw("Failed to log response for forwarded event",
zap.String("file", f),
zap.Error(err))
}
}

func (o *Forwarder) forwardFromFiles() {
for _, f := range strings.Split(o.FromFiles, ",") {
o.forwardFromFile(f)
}
}
23 changes: 21 additions & 2 deletions vendor/knative.dev/reconciler-test/pkg/eventshub/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,16 @@ func StartSenderTLS(sinkSvc string, caCerts *string) EventsHubOption {
// This can be used together with InputEvent, AddTracing, EnableIncrementalId, InputEncoding and InputHeader options
func StartSenderToResource(gvr schema.GroupVersionResource, name string) EventsHubOption {
return func(ctx context.Context, envs map[string]string) error {
u, err := k8s.Address(ctx, gvr, name)
env := environment.FromContext(ctx)
return StartSenderToNamespacedResource(gvr, name, env.Namespace())(ctx, envs)
}
}

// StartSenderToNamespacedResource starts the sender in the eventshub pointing to the provided resource
// This can be used together with InputEvent, AddTracing, EnableIncrementalId, InputEncoding and InputHeader options
func StartSenderToNamespacedResource(gvr schema.GroupVersionResource, name, namespace string) EventsHubOption {
return func(ctx context.Context, envs map[string]string) error {
u, err := k8s.NamespacedAddress(ctx, gvr, name, namespace)
if err != nil {
return err
}
Expand All @@ -102,7 +111,17 @@ func StartSenderToResource(gvr schema.GroupVersionResource, name string) EventsH
// This can be used together with InputEvent, AddTracing, EnableIncrementalId, InputEncoding and InputHeader options
func StartSenderToResourceTLS(gvr schema.GroupVersionResource, name string, caCerts *string) EventsHubOption {
return func(ctx context.Context, m map[string]string) error {
u, err := k8s.Address(ctx, gvr, name)
env := environment.FromContext(ctx)
return StartSenderToNamespacedResourceTLS(gvr, name, env.Namespace(), caCerts)(ctx, m)
}
}

// StartSenderToNamespacedResourceTLS starts the sender in the eventshub pointing to the provided namespaced resource.
// `caCerts` parameter is optional, if nil, it will fall back to use the addressable CA certs.
// This can be used together with InputEvent, AddTracing, EnableIncrementalId, InputEncoding and InputHeader options
func StartSenderToNamespacedResourceTLS(gvr schema.GroupVersionResource, name, namespace string, caCerts *string) EventsHubOption {
return func(ctx context.Context, m map[string]string) error {
u, err := k8s.NamespacedAddress(ctx, gvr, name, namespace)
if err != nil {
return err
}
Expand Down
9 changes: 7 additions & 2 deletions vendor/knative.dev/reconciler-test/pkg/k8s/steps.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,21 @@ func IsAddressable(gvr schema.GroupVersionResource, name string, timing ...time.
// resource is found but not Addressable, Address will return (nil, nil).
func Address(ctx context.Context, gvr schema.GroupVersionResource, name string) (*duckv1.Addressable, error) {
env := environment.FromContext(ctx)
return NamespacedAddress(ctx, gvr, name, env.Namespace())
}

// NamespacedAddress attempts to resolve an Addressable address in a specific namespace into a URL. If the
// resource is found but not Addressable, Address will return (nil, nil).
func NamespacedAddress(ctx context.Context, gvr schema.GroupVersionResource, name, namespace string) (*duckv1.Addressable, error) {
// Special case Service.
if gvr.Group == "" && gvr.Version == "v1" && gvr.Resource == "services" {
u := "http://" + network.GetServiceHostname(name, env.Namespace())
u := "http://" + network.GetServiceHostname(name, namespace)
url, err := apis.ParseURL(u)
return &duckv1.Addressable{URL: url}, err
}

like := &duckv1.AddressableType{}
us, err := dynamicclient.Get(ctx).Resource(gvr).Namespace(env.Namespace()).Get(ctx, name, metav1.GetOptions{})
us, err := dynamicclient.Get(ctx).Resource(gvr).Namespace(namespace).Get(ctx, name, metav1.GetOptions{})
if err != nil {
return nil, err
}
Expand Down
Loading

0 comments on commit 14ae9b3

Please sign in to comment.