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

Use apis.HTTP() #3830

Merged
merged 3 commits into from
Aug 28, 2020
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 pkg/apis/flows/v1/parallel_lifecycle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions pkg/apis/flows/v1/sequence_lifecycle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/flows/v1beta1/parallel_lifecycle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions pkg/apis/flows/v1beta1/sequence_lifecycle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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
Expand Down
16 changes: 10 additions & 6 deletions pkg/apis/sources/v1alpha1/apiserver_conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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
Expand Down Expand Up @@ -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",
Expand All @@ -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{
Expand Down Expand Up @@ -263,7 +267,7 @@ func TestApiServerSourceConversionRoundTripDown(t *testing.T) {
Status: "True",
}},
},
SinkURI: sinkURI,
SinkURI: sinkUri,
},
},
},
Expand All @@ -289,7 +293,7 @@ func TestApiServerSourceConversionRoundTripDown(t *testing.T) {
Status: "True",
}},
},
SinkURI: sinkURI,
SinkURI: sinkUri,
},
},
},
Expand Down
16 changes: 10 additions & 6 deletions pkg/apis/sources/v1alpha1/sinkbinding_conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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{
Expand Down Expand Up @@ -236,7 +240,7 @@ func TestSinkBindingConversionRoundTripDown(t *testing.T) {
Status: "True",
}},
},
SinkURI: sinkURI,
SinkURI: sinkUri,
},
},
},
Expand All @@ -263,7 +267,7 @@ func TestSinkBindingConversionRoundTripDown(t *testing.T) {
Status: "True",
}},
},
SinkURI: sinkURI,
SinkURI: sinkUri,
},
},
},
Expand Down
16 changes: 10 additions & 6 deletions pkg/apis/sources/v1alpha2/apiserver_conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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
Expand Down Expand Up @@ -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",
Expand All @@ -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{
Expand Down Expand Up @@ -258,7 +262,7 @@ func TestApiServerSourceConversionRoundTripDown(t *testing.T) {
Status: "True",
}},
},
SinkURI: sinkURI,
SinkURI: sinkUri,
},
},
},
Expand Down Expand Up @@ -307,7 +311,7 @@ func TestApiServerSourceConversionRoundTripDown(t *testing.T) {
Status: "True",
}},
},
SinkURI: sinkURI,
SinkURI: sinkUri,
},
},
},
Expand Down
14 changes: 9 additions & 5 deletions pkg/apis/sources/v1alpha2/container_conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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
Expand Down Expand Up @@ -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",
Expand All @@ -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{
Expand Down Expand Up @@ -228,7 +232,7 @@ func TestContainerSourceConversionRoundTripDown(t *testing.T) {
Status: "True",
}},
},
SinkURI: sinkURI,
SinkURI: sinkUri,
},
},
},
Expand Down
18 changes: 11 additions & 7 deletions pkg/apis/sources/v1alpha2/ping_conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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
Expand Down Expand Up @@ -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",
Expand All @@ -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{
Expand Down Expand Up @@ -241,7 +245,7 @@ func TestPingSourceConversionRoundTripDown(t *testing.T) {
Status: "True",
}},
},
SinkURI: sinkURI,
SinkURI: sinkUri,
},
},
},
Expand Down Expand Up @@ -269,7 +273,7 @@ func TestPingSourceConversionRoundTripDown(t *testing.T) {
Status: "True",
}},
},
SinkURI: sinkURI,
SinkURI: sinkUri,
CloudEventAttributes: ceAttributes,
},
},
Expand Down Expand Up @@ -299,7 +303,7 @@ func TestPingSourceConversionRoundTripDown(t *testing.T) {
Status: "True",
}},
},
SinkURI: sinkURI,
SinkURI: sinkUri,
CloudEventAttributes: ceAttributes,
},
},
Expand Down
6 changes: 4 additions & 2 deletions pkg/apis/sources/v1beta1/apiserver_lifecycle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions pkg/reconciler/apiserversource/apiserversource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion pkg/reconciler/mtbroker/broker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading