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/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/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/reconciler/apiserversource/apiserversource_test.go b/pkg/reconciler/apiserversource/apiserversource_test.go index 53da51683e4..197a89dbaad 100644 --- a/pkg/reconciler/apiserversource/apiserversource_test.go +++ b/pkg/reconciler/apiserversource/apiserversource_test.go @@ -68,9 +68,13 @@ 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 = func() *apis.URL { + u := apis.HTTP(sinkDNS) + u.Path = sinkURIReference + return u + }() ) const ( 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/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{}