From 20678a7053b1e00859098d5b96d54caef10dbdae Mon Sep 17 00:00:00 2001 From: Stavros Kontopoulos Date: Wed, 12 Aug 2020 18:40:59 +0300 Subject: [PATCH 1/3] use apis.HTTP --- pkg/apis/flows/v1/parallel_lifecycle_test.go | 2 +- pkg/apis/flows/v1/sequence_lifecycle_test.go | 4 ++-- .../flows/v1beta1/parallel_lifecycle_test.go | 2 +- .../flows/v1beta1/sequence_lifecycle_test.go | 4 ++-- .../v1alpha1/apiserver_conversion_test.go | 16 ++++++++++------ .../v1alpha1/sinkbinding_conversion_test.go | 16 ++++++++++------ .../v1alpha2/apiserver_conversion_test.go | 16 ++++++++++------ .../v1alpha2/apiserver_lifecycle_test.go | 6 ++++-- .../v1alpha2/container_conversion_test.go | 14 +++++++++----- .../sources/v1alpha2/ping_conversion_test.go | 18 +++++++++++------- .../sources/v1alpha2/ping_lifecycle_test.go | 9 ++++++--- .../v1beta1/apiserver_lifecycle_test.go | 6 ++++-- .../sources/v1beta1/ping_lifecycle_test.go | 9 ++++++--- .../apiserversource/apiserversource_test.go | 6 ++++-- .../dispatcher/inmemorychannel_test.go | 2 +- pkg/reconciler/mtbroker/broker_test.go | 2 +- pkg/reconciler/pingsource/pingsource_test.go | 4 ++-- .../resources/receive_adapter_test.go | 3 ++- pkg/reconciler/testing/v1beta1/trigger.go | 6 +++--- .../helpers/channel_spec_test_helper.go | 2 +- test/lib/resources/eventing.go | 4 ++-- 21 files changed, 92 insertions(+), 59 deletions(-) diff --git a/pkg/apis/flows/v1/parallel_lifecycle_test.go b/pkg/apis/flows/v1/parallel_lifecycle_test.go index d5fd532ec48..6dd74d2a61e 100644 --- a/pkg/apis/flows/v1/parallel_lifecycle_test.go +++ b/pkg/apis/flows/v1/parallel_lifecycle_test.go @@ -388,7 +388,7 @@ func TestParallelReady(t *testing.T) { } func TestParallelPropagateSetAddress(t *testing.T) { - URL, _ := apis.ParseURL("http://example.com") + URL := apis.HTTP("example.com") tests := []struct { name string address *duckv1.Addressable diff --git a/pkg/apis/flows/v1/sequence_lifecycle_test.go b/pkg/apis/flows/v1/sequence_lifecycle_test.go index 76e83ab93b7..abfca12ce6a 100644 --- a/pkg/apis/flows/v1/sequence_lifecycle_test.go +++ b/pkg/apis/flows/v1/sequence_lifecycle_test.go @@ -67,7 +67,7 @@ func getSubscription(name string, ready bool) *messagingv1.Subscription { } func getChannelable(ready bool) *eventingduckv1.Channelable { - URL, _ := apis.ParseURL("http://example.com") + URL := apis.HTTP("example.com") c := eventingduckv1.Channelable{ TypeMeta: metav1.TypeMeta{ APIVersion: "messaging.knative.dev/v1", @@ -357,7 +357,7 @@ func TestSequenceReady(t *testing.T) { } func TestSequencePropagateSetAddress(t *testing.T) { - URL, _ := apis.ParseURL("http://example.com") + URL := apis.HTTP("example.com") tests := []struct { name string address *duckv1.Addressable diff --git a/pkg/apis/flows/v1beta1/parallel_lifecycle_test.go b/pkg/apis/flows/v1beta1/parallel_lifecycle_test.go index 157057453d6..682085398e5 100644 --- a/pkg/apis/flows/v1beta1/parallel_lifecycle_test.go +++ b/pkg/apis/flows/v1beta1/parallel_lifecycle_test.go @@ -388,7 +388,7 @@ func TestParallelReady(t *testing.T) { } func TestParallelPropagateSetAddress(t *testing.T) { - URL, _ := apis.ParseURL("http://example.com") + URL := apis.HTTP("example.com") tests := []struct { name string address *duckv1.Addressable diff --git a/pkg/apis/flows/v1beta1/sequence_lifecycle_test.go b/pkg/apis/flows/v1beta1/sequence_lifecycle_test.go index 4cc8512315c..66f2fc0f1cc 100644 --- a/pkg/apis/flows/v1beta1/sequence_lifecycle_test.go +++ b/pkg/apis/flows/v1beta1/sequence_lifecycle_test.go @@ -69,7 +69,7 @@ func getSubscription(name string, ready bool) *messagingv1beta1.Subscription { } func getChannelable(ready bool) *eventingduckv1beta1.Channelable { - URL, _ := apis.ParseURL("http://example.com") + URL := apis.HTTP("example.com") c := eventingduckv1beta1.Channelable{ TypeMeta: metav1.TypeMeta{ APIVersion: "messaging.knative.dev/v1beta1", @@ -359,7 +359,7 @@ func TestSequenceReady(t *testing.T) { } func TestSequencePropagateSetAddress(t *testing.T) { - URL, _ := apis.ParseURL("http://example.com") + URL := apis.HTTP("example.com") tests := []struct { name string address *duckv1.Addressable diff --git a/pkg/apis/sources/v1alpha1/apiserver_conversion_test.go b/pkg/apis/sources/v1alpha1/apiserver_conversion_test.go index d43d1e8d345..67cb48b0243 100644 --- a/pkg/apis/sources/v1alpha1/apiserver_conversion_test.go +++ b/pkg/apis/sources/v1alpha1/apiserver_conversion_test.go @@ -62,7 +62,8 @@ func TestApiServerSourceConversionRoundTripUp(t *testing.T) { // Just one for now, just adding the for loop for ease of future changes. versions := []apis.Convertible{&v1alpha2.ApiServerSource{}, &v1beta1.ApiServerSource{}} - path, _ := apis.ParseURL("/path") + path := apis.HTTP("") + path.Path = "/path" sink := duckv1beta1.Destination{ Ref: &corev1.ObjectReference{ APIVersion: "Baf", @@ -76,7 +77,8 @@ func TestApiServerSourceConversionRoundTripUp(t *testing.T) { DeprecatedNamespace: "depNamespace", URI: path, } - sinkUri, _ := apis.ParseURL("http://example.com/path") + sinkUri := apis.HTTP("example.com") + sinkUri.Path = "path" tests := []struct { name string @@ -210,7 +212,8 @@ func TestApiServerSourceConversionRoundTripUp(t *testing.T) { // This tests round tripping from a higher version -> v1alpha1 and back to the higher version. func TestApiServerSourceConversionRoundTripDown(t *testing.T) { - path, _ := apis.ParseURL("/path") + path := apis.HTTP("") + path.Path = "/path" sink := duckv1.Destination{ Ref: &duckv1.KReference{ Kind: "Foo", @@ -220,7 +223,8 @@ func TestApiServerSourceConversionRoundTripDown(t *testing.T) { }, URI: path, } - sinkURI, _ := apis.ParseURL("http://example.com/path") + sinkUri := apis.HTTP("example.com") + sinkUri.Path = "path" ceOverrides := duckv1.CloudEventOverrides{ Extensions: map[string]string{ @@ -263,7 +267,7 @@ func TestApiServerSourceConversionRoundTripDown(t *testing.T) { Status: "True", }}, }, - SinkURI: sinkURI, + SinkURI: sinkUri, }, }, }, @@ -289,7 +293,7 @@ func TestApiServerSourceConversionRoundTripDown(t *testing.T) { Status: "True", }}, }, - SinkURI: sinkURI, + SinkURI: sinkUri, }, }, }, diff --git a/pkg/apis/sources/v1alpha1/sinkbinding_conversion_test.go b/pkg/apis/sources/v1alpha1/sinkbinding_conversion_test.go index 3bc72326cf2..19c9e11d6c9 100644 --- a/pkg/apis/sources/v1alpha1/sinkbinding_conversion_test.go +++ b/pkg/apis/sources/v1alpha1/sinkbinding_conversion_test.go @@ -48,7 +48,8 @@ func TestSinkBindingConversionBadType(t *testing.T) { func TestSinkBindingConversionRoundTripUp(t *testing.T) { versions := []apis.Convertible{&v1beta1.SinkBinding{}, &v1alpha2.SinkBinding{}} - path, _ := apis.ParseURL("/path") + path := apis.HTTP("") + path.Path = "/path" sink := duckv1.Destination{ Ref: &duckv1.KReference{ Kind: "Foo", @@ -58,7 +59,8 @@ func TestSinkBindingConversionRoundTripUp(t *testing.T) { }, URI: path, } - sinkUri, _ := apis.ParseURL("http://example.com/path") + sinkUri := apis.HTTP("example.com") + sinkUri.Path = "path" subject := tracker.Reference{ APIVersion: "API", @@ -176,7 +178,8 @@ func TestSinkBindingConversionRoundTripUp(t *testing.T) { // This tests round tripping from a higher version -> v1alpha1 and back to the higher version. func TestSinkBindingConversionRoundTripDown(t *testing.T) { - path, _ := apis.ParseURL("/path") + path := apis.HTTP("") + path.Path = "/path" sink := duckv1.Destination{ Ref: &duckv1.KReference{ Kind: "Foo", @@ -186,7 +189,8 @@ func TestSinkBindingConversionRoundTripDown(t *testing.T) { }, URI: path, } - sinkURI, _ := apis.ParseURL("http://example.com/path") + sinkUri := apis.HTTP("example.com") + sinkUri.Path = "path" ceOverrides := duckv1.CloudEventOverrides{ Extensions: map[string]string{ @@ -236,7 +240,7 @@ func TestSinkBindingConversionRoundTripDown(t *testing.T) { Status: "True", }}, }, - SinkURI: sinkURI, + SinkURI: sinkUri, }, }, }, @@ -263,7 +267,7 @@ func TestSinkBindingConversionRoundTripDown(t *testing.T) { Status: "True", }}, }, - SinkURI: sinkURI, + SinkURI: sinkUri, }, }, }, diff --git a/pkg/apis/sources/v1alpha2/apiserver_conversion_test.go b/pkg/apis/sources/v1alpha2/apiserver_conversion_test.go index c8137e0cd91..eaab3e74758 100644 --- a/pkg/apis/sources/v1alpha2/apiserver_conversion_test.go +++ b/pkg/apis/sources/v1alpha2/apiserver_conversion_test.go @@ -45,7 +45,8 @@ func TestApiServerSourceConversionRoundTripUp(t *testing.T) { // Just one for now, just adding the for loop for ease of future changes. versions := []apis.Convertible{&v1beta1.ApiServerSource{}} - path, _ := apis.ParseURL("/path") + path := apis.HTTP("") + path.Path = "/path" sink := duckv1.Destination{ Ref: &duckv1.KReference{ Kind: "Foo", @@ -55,7 +56,8 @@ func TestApiServerSourceConversionRoundTripUp(t *testing.T) { }, URI: path, } - sinkUri, _ := apis.ParseURL("http://example.com/path") + sinkUri := apis.HTTP("example.com") + sinkUri.Path = "path" tests := []struct { name string @@ -194,7 +196,8 @@ func TestApiServerSourceConversionRoundTripUp(t *testing.T) { // This tests round tripping from a higher version -> v1alpha1 and back to the higher version. func TestApiServerSourceConversionRoundTripDown(t *testing.T) { - path, _ := apis.ParseURL("/path") + path := apis.HTTP("") + path.Path = "/path" sink := duckv1.Destination{ Ref: &duckv1.KReference{ Kind: "Foo", @@ -204,7 +207,8 @@ func TestApiServerSourceConversionRoundTripDown(t *testing.T) { }, URI: path, } - sinkURI, _ := apis.ParseURL("http://example.com/path") + sinkUri := apis.HTTP("example.com") + sinkUri.Path = "path" ceOverrides := duckv1.CloudEventOverrides{ Extensions: map[string]string{ @@ -258,7 +262,7 @@ func TestApiServerSourceConversionRoundTripDown(t *testing.T) { Status: "True", }}, }, - SinkURI: sinkURI, + SinkURI: sinkUri, }, }, }, @@ -307,7 +311,7 @@ func TestApiServerSourceConversionRoundTripDown(t *testing.T) { Status: "True", }}, }, - SinkURI: sinkURI, + SinkURI: sinkUri, }, }, }, diff --git a/pkg/apis/sources/v1alpha2/apiserver_lifecycle_test.go b/pkg/apis/sources/v1alpha2/apiserver_lifecycle_test.go index 1beddbae88b..ecd1292c5c1 100644 --- a/pkg/apis/sources/v1alpha2/apiserver_lifecycle_test.go +++ b/pkg/apis/sources/v1alpha2/apiserver_lifecycle_test.go @@ -49,7 +49,8 @@ func TestApiServerSourceGetGroupVersionKind(t *testing.T) { } func TestApiServerSourceStatusIsReady(t *testing.T) { - sink, _ := apis.ParseURL("uri://example") + sink := apis.HTTP("example") + sink.Scheme = "uri" tests := []struct { name string @@ -198,7 +199,8 @@ func TestApiServerSourceStatusIsReady(t *testing.T) { } func TestApiServerSourceStatusGetCondition(t *testing.T) { - sink, _ := apis.ParseURL("uri://example") + sink := apis.HTTP("example") + sink.Scheme = "uri" tests := []struct { name string diff --git a/pkg/apis/sources/v1alpha2/container_conversion_test.go b/pkg/apis/sources/v1alpha2/container_conversion_test.go index 89a847918da..ade17363268 100644 --- a/pkg/apis/sources/v1alpha2/container_conversion_test.go +++ b/pkg/apis/sources/v1alpha2/container_conversion_test.go @@ -45,7 +45,8 @@ func TestContainerSourceConversionBadType(t *testing.T) { func TestContainerSourceConversionRoundTripUp(t *testing.T) { versions := []apis.Convertible{&v1beta1.ContainerSource{}} - path, _ := apis.ParseURL("/path") + path := apis.HTTP("") + path.Path = "/path" sink := duckv1.Destination{ Ref: &duckv1.KReference{ Kind: "Foo", @@ -55,7 +56,8 @@ func TestContainerSourceConversionRoundTripUp(t *testing.T) { }, URI: path, } - sinkUri, _ := apis.ParseURL("http://example.com/path") + sinkUri := apis.HTTP("example.com") + sinkUri.Path = "path" tests := []struct { name string @@ -176,7 +178,8 @@ func TestContainerSourceConversionRoundTripUp(t *testing.T) { // This tests round tripping from a higher version -> v1alpha2 and back to the higher version. func TestContainerSourceConversionRoundTripDown(t *testing.T) { - path, _ := apis.ParseURL("/path") + path := apis.HTTP("") + path.Path = "/path" sink := duckv1.Destination{ Ref: &duckv1.KReference{ Kind: "Foo", @@ -186,7 +189,8 @@ func TestContainerSourceConversionRoundTripDown(t *testing.T) { }, URI: path, } - sinkURI, _ := apis.ParseURL("http://example.com/path") + sinkUri := apis.HTTP("example.com") + sinkUri.Path = "path" ceOverrides := duckv1.CloudEventOverrides{ Extensions: map[string]string{ @@ -228,7 +232,7 @@ func TestContainerSourceConversionRoundTripDown(t *testing.T) { Status: "True", }}, }, - SinkURI: sinkURI, + SinkURI: sinkUri, }, }, }, diff --git a/pkg/apis/sources/v1alpha2/ping_conversion_test.go b/pkg/apis/sources/v1alpha2/ping_conversion_test.go index 61ebd75ad5b..37e7291c61f 100644 --- a/pkg/apis/sources/v1alpha2/ping_conversion_test.go +++ b/pkg/apis/sources/v1alpha2/ping_conversion_test.go @@ -44,7 +44,8 @@ func TestPingSourceConversionRoundTripUp(t *testing.T) { // Just one for now, just adding the for loop for ease of future changes. versions := []apis.Convertible{&v1beta1.PingSource{}} - path, _ := apis.ParseURL("/path") + path := apis.HTTP("") + path.Path = "/path" sink := duckv1.Destination{ Ref: &duckv1.KReference{ Kind: "Foo", @@ -54,7 +55,8 @@ func TestPingSourceConversionRoundTripUp(t *testing.T) { }, URI: path, } - sinkUri, _ := apis.ParseURL("http://example.com/path") + sinkUri := apis.HTTP("example.com") + sinkUri.Path = "path" tests := []struct { name string @@ -183,7 +185,8 @@ func TestPingSourceConversionRoundTripUp(t *testing.T) { func TestPingSourceConversionRoundTripDown(t *testing.T) { // Just one for now, just adding the for loop for ease of future changes. - path, _ := apis.ParseURL("/path") + path := apis.HTTP("") + path.Path = "/path" sink := duckv1.Destination{ Ref: &duckv1.KReference{ Kind: "Foo", @@ -193,7 +196,8 @@ func TestPingSourceConversionRoundTripDown(t *testing.T) { }, URI: path, } - sinkURI, _ := apis.ParseURL("http://example.com/path") + sinkUri := apis.HTTP("example.com") + sinkUri.Path = "path" ceOverrides := duckv1.CloudEventOverrides{ Extensions: map[string]string{ @@ -241,7 +245,7 @@ func TestPingSourceConversionRoundTripDown(t *testing.T) { Status: "True", }}, }, - SinkURI: sinkURI, + SinkURI: sinkUri, }, }, }, @@ -269,7 +273,7 @@ func TestPingSourceConversionRoundTripDown(t *testing.T) { Status: "True", }}, }, - SinkURI: sinkURI, + SinkURI: sinkUri, CloudEventAttributes: ceAttributes, }, }, @@ -299,7 +303,7 @@ func TestPingSourceConversionRoundTripDown(t *testing.T) { Status: "True", }}, }, - SinkURI: sinkURI, + SinkURI: sinkUri, CloudEventAttributes: ceAttributes, }, }, diff --git a/pkg/apis/sources/v1alpha2/ping_lifecycle_test.go b/pkg/apis/sources/v1alpha2/ping_lifecycle_test.go index fc2bdf1fd68..2d02f745bb7 100644 --- a/pkg/apis/sources/v1alpha2/ping_lifecycle_test.go +++ b/pkg/apis/sources/v1alpha2/ping_lifecycle_test.go @@ -53,7 +53,8 @@ func TestPingSource_PingSourceSource(t *testing.T) { } func TestPingSourceStatusIsReady(t *testing.T) { - exampleUri, _ := apis.ParseURL("uri://example") + exampleUri := apis.HTTP("example") + exampleUri.Scheme = "uri" tests := []struct { name string @@ -255,7 +256,8 @@ func TestPingSourceStatusIsReady(t *testing.T) { } func TestPingSourceStatusGetTopLevelCondition(t *testing.T) { - exampleUri, _ := apis.ParseURL("uri://example") + exampleUri := apis.HTTP("example") + exampleUri.Scheme = "uri" tests := []struct { name string @@ -457,7 +459,8 @@ func TestPingSourceStatusGetTopLevelCondition(t *testing.T) { } func TestPingSourceStatusGetCondition(t *testing.T) { - exampleUri, _ := apis.ParseURL("uri://example") + exampleUri := apis.HTTP("example") + exampleUri.Scheme = "uri" tests := []struct { name string s *PingSourceStatus diff --git a/pkg/apis/sources/v1beta1/apiserver_lifecycle_test.go b/pkg/apis/sources/v1beta1/apiserver_lifecycle_test.go index 49aabee5c56..757c69a36c2 100644 --- a/pkg/apis/sources/v1beta1/apiserver_lifecycle_test.go +++ b/pkg/apis/sources/v1beta1/apiserver_lifecycle_test.go @@ -49,7 +49,8 @@ func TestApiServerSourceGetGroupVersionKind(t *testing.T) { } func TestApiServerSourceStatusIsReady(t *testing.T) { - sink, _ := apis.ParseURL("uri://example") + sink := apis.HTTP("example") + sink.Scheme = "uri" tests := []struct { name string @@ -198,7 +199,8 @@ func TestApiServerSourceStatusIsReady(t *testing.T) { } func TestApiServerSourceStatusGetCondition(t *testing.T) { - sink, _ := apis.ParseURL("uri://example") + sink := apis.HTTP("example") + sink.Scheme = "uri" tests := []struct { name string diff --git a/pkg/apis/sources/v1beta1/ping_lifecycle_test.go b/pkg/apis/sources/v1beta1/ping_lifecycle_test.go index bbc83d67067..79fcf970252 100644 --- a/pkg/apis/sources/v1beta1/ping_lifecycle_test.go +++ b/pkg/apis/sources/v1beta1/ping_lifecycle_test.go @@ -52,7 +52,8 @@ func TestPingSource_PingSourceSource(t *testing.T) { } func TestPingSourceStatusIsReady(t *testing.T) { - exampleUri, _ := apis.ParseURL("uri://example") + exampleUri := apis.HTTP("example") + exampleUri.Scheme = "uri" tests := []struct { name string @@ -123,7 +124,8 @@ func TestPingSourceStatusIsReady(t *testing.T) { } func TestPingSourceStatusGetTopLevelCondition(t *testing.T) { - exampleUri, _ := apis.ParseURL("uri://example") + exampleUri := apis.HTTP("example") + exampleUri.Scheme = "uri" tests := []struct { name string @@ -196,7 +198,8 @@ func TestPingSourceStatusGetTopLevelCondition(t *testing.T) { } func TestPingSourceStatusGetCondition(t *testing.T) { - exampleUri, _ := apis.ParseURL("uri://example") + exampleUri := apis.HTTP("example") + exampleUri.Scheme = "uri" tests := []struct { name string s *PingSourceStatus diff --git a/pkg/reconciler/apiserversource/apiserversource_test.go b/pkg/reconciler/apiserversource/apiserversource_test.go index 53da51683e4..ad9775a4f3f 100644 --- a/pkg/reconciler/apiserversource/apiserversource_test.go +++ b/pkg/reconciler/apiserversource/apiserversource_test.go @@ -68,9 +68,9 @@ var ( }, } sinkDNS = "sink.mynamespace.svc." + utils.GetClusterDomainName() - sinkURI, _ = apis.ParseURL("http://" + sinkDNS) + sinkURI = apis.HTTP(sinkDNS) sinkURIReference = "/foo" - sinkTargetURI, _ = apis.ParseURL("http://" + sinkDNS + sinkURIReference) + sinkTargetURI = apis.HTTP(sinkDNS) ) const ( @@ -90,6 +90,8 @@ func init() { _ = appsv1.AddToScheme(scheme.Scheme) _ = corev1.AddToScheme(scheme.Scheme) _ = duckv1alpha1.AddToScheme(scheme.Scheme) + // Set path + sinkTargetURI.Path = sinkURIReference } func TestReconcile(t *testing.T) { diff --git a/pkg/reconciler/inmemorychannel/dispatcher/inmemorychannel_test.go b/pkg/reconciler/inmemorychannel/dispatcher/inmemorychannel_test.go index b96e293d56c..3295ea33f57 100644 --- a/pkg/reconciler/inmemorychannel/dispatcher/inmemorychannel_test.go +++ b/pkg/reconciler/inmemorychannel/dispatcher/inmemorychannel_test.go @@ -123,7 +123,7 @@ func TestAllCases(t *testing.T) { ReplyURI: apis.HTTP("sink2"), Delivery: &eventingduckv1.DeliverySpec{ DeadLetterSink: &duckv1.Destination{ - URI: apis.HTTP("http://www.example.com"), + URI: apis.HTTP("www.example.com"), }, Retry: pointer.Int32Ptr(10), BackoffPolicy: &backoffPolicy, diff --git a/pkg/reconciler/mtbroker/broker_test.go b/pkg/reconciler/mtbroker/broker_test.go index cc81b5a6790..9d6a6b190a8 100644 --- a/pkg/reconciler/mtbroker/broker_test.go +++ b/pkg/reconciler/mtbroker/broker_test.go @@ -742,7 +742,7 @@ func makeGenerationNotEqualPingSource() *sourcesv1alpha2.PingSource { } func makeReadyPingSource() *sourcesv1alpha2.PingSource { - u, _ := apis.ParseURL(sinkURI) + u := apis.HTTP(sinkURI) return rtv1alpha1.NewPingSourceV1Alpha2(pingSourceName, testNS, rtv1alpha1.WithPingSourceV1A2Spec(sourcesv1alpha2.PingSourceSpec{ Schedule: testSchedule, diff --git a/pkg/reconciler/pingsource/pingsource_test.go b/pkg/reconciler/pingsource/pingsource_test.go index 9a775588b9e..d289ac321a7 100644 --- a/pkg/reconciler/pingsource/pingsource_test.go +++ b/pkg/reconciler/pingsource/pingsource_test.go @@ -65,8 +65,8 @@ var ( sinkDestURI = duckv1.Destination{ URI: apis.HTTP(sinkDNS), } - sinkDNS = "sink.mynamespace.svc." + utils.GetClusterDomainName() - sinkURI, _ = apis.ParseURL("http://" + sinkDNS) + sinkDNS = "sink.mynamespace.svc." + utils.GetClusterDomainName() + sinkURI = apis.HTTP(sinkDNS) ) const ( diff --git a/pkg/reconciler/pingsource/resources/receive_adapter_test.go b/pkg/reconciler/pingsource/resources/receive_adapter_test.go index 538e7f8604f..bd48c6adb9b 100644 --- a/pkg/reconciler/pingsource/resources/receive_adapter_test.go +++ b/pkg/reconciler/pingsource/resources/receive_adapter_test.go @@ -43,7 +43,8 @@ func TestMakeReceiveAdapter(t *testing.T) { }, } - exampleUri, _ := apis.ParseURL("uri://example") + exampleUri := apis.HTTP("example") + exampleUri.Scheme = "uri" got := MakeReceiveAdapter(&Args{ Image: "test-image", diff --git a/pkg/reconciler/testing/v1beta1/trigger.go b/pkg/reconciler/testing/v1beta1/trigger.go index f4b00d31413..5f146e5615e 100644 --- a/pkg/reconciler/testing/v1beta1/trigger.go +++ b/pkg/reconciler/testing/v1beta1/trigger.go @@ -50,7 +50,7 @@ func NewTrigger(name, namespace, broker string, to ...TriggerOption) *v1beta1.Tr } func WithTriggerSubscriberURI(rawurl string) TriggerOption { - uri, _ := apis.ParseURL(rawurl) + uri := apis.HTTP(rawurl) return func(t *v1beta1.Trigger) { t.Spec.Subscriber = duckv1.Destination{URI: uri} } @@ -70,7 +70,7 @@ func WithTriggerSubscriberRef(gvk metav1.GroupVersionKind, name, namespace strin } func WithTriggerSubscriberRefAndURIReference(gvk metav1.GroupVersionKind, name, namespace string, rawuri string) TriggerOption { - uri, _ := apis.ParseURL(rawuri) + uri := apis.HTTP(rawuri) return func(t *v1beta1.Trigger) { t.Spec.Subscriber = duckv1.Destination{ Ref: &duckv1.KReference{ @@ -148,7 +148,7 @@ func WithTriggerSubscribed() TriggerOption { func WithTriggerStatusSubscriberURI(uri string) TriggerOption { return func(t *v1beta1.Trigger) { - u, _ := apis.ParseURL(uri) + u := apis.HTTP(uri) t.Status.SubscriberURI = u } } diff --git a/test/conformance/helpers/channel_spec_test_helper.go b/test/conformance/helpers/channel_spec_test_helper.go index e989a6c6ee6..fbe8123de94 100644 --- a/test/conformance/helpers/channel_spec_test_helper.go +++ b/test/conformance/helpers/channel_spec_test_helper.go @@ -66,7 +66,7 @@ func channelSpecAllowsSubscribersArray(st *testing.T, client *testlib.Client, ch client.CreateChannelOrFail(channelName, &channel) client.WaitForResourceReadyOrFail(channelName, &channel) - sampleUrl, _ := apis.ParseURL("http://example.com") + sampleUrl := apis.HTTP("example.com") gvr, _ := meta.UnsafeGuessKindToResource(channel.GroupVersionKind()) var ch interface{} diff --git a/test/lib/resources/eventing.go b/test/lib/resources/eventing.go index 167f0cace3e..75ced94c957 100644 --- a/test/lib/resources/eventing.go +++ b/test/lib/resources/eventing.go @@ -401,7 +401,7 @@ func WithSubscriberServiceRefForTriggerV1(name string) TriggerOptionV1 { // WithSubscriberURIForTriggerV1Beta1 returns an option that adds a Subscriber URI for the given v1beta1 Trigger. func WithSubscriberURIForTriggerV1Beta1(uri string) TriggerOptionV1Beta1 { - apisURI, _ := apis.ParseURL(uri) + apisURI := apis.HTTP(uri) return func(t *eventingv1beta1.Trigger) { t.Spec.Subscriber = duckv1.Destination{ URI: apisURI, @@ -411,7 +411,7 @@ func WithSubscriberURIForTriggerV1Beta1(uri string) TriggerOptionV1Beta1 { // WithSubscriberURIForTriggerV1 returns an option that adds a Subscriber URI for the given v1 Trigger. func WithSubscriberURIForTriggerV1(uri string) TriggerOptionV1 { - apisURI, _ := apis.ParseURL(uri) + apisURI := apis.HTTP(uri) return func(t *eventingv1.Trigger) { t.Spec.Subscriber = duckv1.Destination{ URI: apisURI, From 609bd6182c9b4ccdca0228ee1cbdb5f9d69f1f38 Mon Sep 17 00:00:00 2001 From: Stavros Kontopoulos Date: Tue, 25 Aug 2020 11:51:58 +0300 Subject: [PATCH 2/3] fixes --- pkg/reconciler/testing/v1beta1/trigger.go | 6 +++--- test/lib/resources/eventing.go | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/reconciler/testing/v1beta1/trigger.go b/pkg/reconciler/testing/v1beta1/trigger.go index 5f146e5615e..f4b00d31413 100644 --- a/pkg/reconciler/testing/v1beta1/trigger.go +++ b/pkg/reconciler/testing/v1beta1/trigger.go @@ -50,7 +50,7 @@ func NewTrigger(name, namespace, broker string, to ...TriggerOption) *v1beta1.Tr } func WithTriggerSubscriberURI(rawurl string) TriggerOption { - uri := apis.HTTP(rawurl) + uri, _ := apis.ParseURL(rawurl) return func(t *v1beta1.Trigger) { t.Spec.Subscriber = duckv1.Destination{URI: uri} } @@ -70,7 +70,7 @@ func WithTriggerSubscriberRef(gvk metav1.GroupVersionKind, name, namespace strin } func WithTriggerSubscriberRefAndURIReference(gvk metav1.GroupVersionKind, name, namespace string, rawuri string) TriggerOption { - uri := apis.HTTP(rawuri) + uri, _ := apis.ParseURL(rawuri) return func(t *v1beta1.Trigger) { t.Spec.Subscriber = duckv1.Destination{ Ref: &duckv1.KReference{ @@ -148,7 +148,7 @@ func WithTriggerSubscribed() TriggerOption { func WithTriggerStatusSubscriberURI(uri string) TriggerOption { return func(t *v1beta1.Trigger) { - u := apis.HTTP(uri) + u, _ := apis.ParseURL(uri) t.Status.SubscriberURI = u } } diff --git a/test/lib/resources/eventing.go b/test/lib/resources/eventing.go index 75ced94c957..167f0cace3e 100644 --- a/test/lib/resources/eventing.go +++ b/test/lib/resources/eventing.go @@ -401,7 +401,7 @@ func WithSubscriberServiceRefForTriggerV1(name string) TriggerOptionV1 { // WithSubscriberURIForTriggerV1Beta1 returns an option that adds a Subscriber URI for the given v1beta1 Trigger. func WithSubscriberURIForTriggerV1Beta1(uri string) TriggerOptionV1Beta1 { - apisURI := apis.HTTP(uri) + apisURI, _ := apis.ParseURL(uri) return func(t *eventingv1beta1.Trigger) { t.Spec.Subscriber = duckv1.Destination{ URI: apisURI, @@ -411,7 +411,7 @@ func WithSubscriberURIForTriggerV1Beta1(uri string) TriggerOptionV1Beta1 { // WithSubscriberURIForTriggerV1 returns an option that adds a Subscriber URI for the given v1 Trigger. func WithSubscriberURIForTriggerV1(uri string) TriggerOptionV1 { - apisURI := apis.HTTP(uri) + apisURI, _ := apis.ParseURL(uri) return func(t *eventingv1.Trigger) { t.Spec.Subscriber = duckv1.Destination{ URI: apisURI, From d022ca3fe00b37e8e78c41ebd64cb53e6d3c10bd Mon Sep 17 00:00:00 2001 From: Stavros Kontopoulos Date: Fri, 28 Aug 2020 11:34:07 +0300 Subject: [PATCH 3/3] updates --- pkg/apis/sources/v1alpha2/apiserver_lifecycle_test.go | 6 ++---- pkg/apis/sources/v1alpha2/ping_lifecycle_test.go | 9 +++------ pkg/apis/sources/v1beta1/ping_lifecycle_test.go | 9 +++------ pkg/reconciler/apiserversource/apiserversource_test.go | 8 +++++--- .../pingsource/resources/receive_adapter_test.go | 3 +-- 5 files changed, 14 insertions(+), 21 deletions(-) diff --git a/pkg/apis/sources/v1alpha2/apiserver_lifecycle_test.go b/pkg/apis/sources/v1alpha2/apiserver_lifecycle_test.go index ecd1292c5c1..1beddbae88b 100644 --- a/pkg/apis/sources/v1alpha2/apiserver_lifecycle_test.go +++ b/pkg/apis/sources/v1alpha2/apiserver_lifecycle_test.go @@ -49,8 +49,7 @@ func TestApiServerSourceGetGroupVersionKind(t *testing.T) { } func TestApiServerSourceStatusIsReady(t *testing.T) { - sink := apis.HTTP("example") - sink.Scheme = "uri" + sink, _ := apis.ParseURL("uri://example") tests := []struct { name string @@ -199,8 +198,7 @@ func TestApiServerSourceStatusIsReady(t *testing.T) { } func TestApiServerSourceStatusGetCondition(t *testing.T) { - sink := apis.HTTP("example") - sink.Scheme = "uri" + sink, _ := apis.ParseURL("uri://example") tests := []struct { name string diff --git a/pkg/apis/sources/v1alpha2/ping_lifecycle_test.go b/pkg/apis/sources/v1alpha2/ping_lifecycle_test.go index 2d02f745bb7..fc2bdf1fd68 100644 --- a/pkg/apis/sources/v1alpha2/ping_lifecycle_test.go +++ b/pkg/apis/sources/v1alpha2/ping_lifecycle_test.go @@ -53,8 +53,7 @@ func TestPingSource_PingSourceSource(t *testing.T) { } func TestPingSourceStatusIsReady(t *testing.T) { - exampleUri := apis.HTTP("example") - exampleUri.Scheme = "uri" + exampleUri, _ := apis.ParseURL("uri://example") tests := []struct { name string @@ -256,8 +255,7 @@ func TestPingSourceStatusIsReady(t *testing.T) { } func TestPingSourceStatusGetTopLevelCondition(t *testing.T) { - exampleUri := apis.HTTP("example") - exampleUri.Scheme = "uri" + exampleUri, _ := apis.ParseURL("uri://example") tests := []struct { name string @@ -459,8 +457,7 @@ func TestPingSourceStatusGetTopLevelCondition(t *testing.T) { } func TestPingSourceStatusGetCondition(t *testing.T) { - exampleUri := apis.HTTP("example") - exampleUri.Scheme = "uri" + exampleUri, _ := apis.ParseURL("uri://example") tests := []struct { name string s *PingSourceStatus diff --git a/pkg/apis/sources/v1beta1/ping_lifecycle_test.go b/pkg/apis/sources/v1beta1/ping_lifecycle_test.go index 79fcf970252..bbc83d67067 100644 --- a/pkg/apis/sources/v1beta1/ping_lifecycle_test.go +++ b/pkg/apis/sources/v1beta1/ping_lifecycle_test.go @@ -52,8 +52,7 @@ func TestPingSource_PingSourceSource(t *testing.T) { } func TestPingSourceStatusIsReady(t *testing.T) { - exampleUri := apis.HTTP("example") - exampleUri.Scheme = "uri" + exampleUri, _ := apis.ParseURL("uri://example") tests := []struct { name string @@ -124,8 +123,7 @@ func TestPingSourceStatusIsReady(t *testing.T) { } func TestPingSourceStatusGetTopLevelCondition(t *testing.T) { - exampleUri := apis.HTTP("example") - exampleUri.Scheme = "uri" + exampleUri, _ := apis.ParseURL("uri://example") tests := []struct { name string @@ -198,8 +196,7 @@ func TestPingSourceStatusGetTopLevelCondition(t *testing.T) { } func TestPingSourceStatusGetCondition(t *testing.T) { - exampleUri := apis.HTTP("example") - exampleUri.Scheme = "uri" + exampleUri, _ := apis.ParseURL("uri://example") tests := []struct { name string s *PingSourceStatus diff --git a/pkg/reconciler/apiserversource/apiserversource_test.go b/pkg/reconciler/apiserversource/apiserversource_test.go index ad9775a4f3f..197a89dbaad 100644 --- a/pkg/reconciler/apiserversource/apiserversource_test.go +++ b/pkg/reconciler/apiserversource/apiserversource_test.go @@ -70,7 +70,11 @@ var ( sinkDNS = "sink.mynamespace.svc." + utils.GetClusterDomainName() sinkURI = apis.HTTP(sinkDNS) sinkURIReference = "/foo" - sinkTargetURI = apis.HTTP(sinkDNS) + sinkTargetURI = func() *apis.URL { + u := apis.HTTP(sinkDNS) + u.Path = sinkURIReference + return u + }() ) const ( @@ -90,8 +94,6 @@ func init() { _ = appsv1.AddToScheme(scheme.Scheme) _ = corev1.AddToScheme(scheme.Scheme) _ = duckv1alpha1.AddToScheme(scheme.Scheme) - // Set path - sinkTargetURI.Path = sinkURIReference } func TestReconcile(t *testing.T) { diff --git a/pkg/reconciler/pingsource/resources/receive_adapter_test.go b/pkg/reconciler/pingsource/resources/receive_adapter_test.go index bd48c6adb9b..538e7f8604f 100644 --- a/pkg/reconciler/pingsource/resources/receive_adapter_test.go +++ b/pkg/reconciler/pingsource/resources/receive_adapter_test.go @@ -43,8 +43,7 @@ func TestMakeReceiveAdapter(t *testing.T) { }, } - exampleUri := apis.HTTP("example") - exampleUri.Scheme = "uri" + exampleUri, _ := apis.ParseURL("uri://example") got := MakeReceiveAdapter(&Args{ Image: "test-image",