mirror of https://github.com/knative/client.git
feat: Add channel sink prefix (#1092)
* Add channel sink prefix * Add unit and e2e tests * Add CHANGELOG * Fix e2e tests
This commit is contained in:
parent
a0ddad92fc
commit
26867f154d
|
|
@ -17,6 +17,10 @@
|
||||||
|===
|
|===
|
||||||
| | Description | PR
|
| | Description | PR
|
||||||
|
|
||||||
|
| 🎁
|
||||||
|
| Add channel sink prefix
|
||||||
|
| https://github.com/knative/client/pull/1092[#1092]
|
||||||
|
|
||||||
| 🐣
|
| 🐣
|
||||||
| Uniform multiple writeSink to DescribeSink
|
| Uniform multiple writeSink to DescribeSink
|
||||||
| https://github.com/knative/client/pull/1075[#1075]
|
| https://github.com/knative/client/pull/1075[#1075]
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ kn source apiserver create NAME --resource RESOURCE --sink SINK
|
||||||
--resource stringArray Specification for which events to listen, in the format Kind:APIVersion:LabelSelector, e.g. "Event:v1:key=value".
|
--resource stringArray Specification for which events to listen, in the format Kind:APIVersion:LabelSelector, e.g. "Event:v1:key=value".
|
||||||
"LabelSelector" is a list of comma separated key value pairs. "LabelSelector" can be omitted, e.g. "Event:v1".
|
"LabelSelector" is a list of comma separated key value pairs. "LabelSelector" can be omitted, e.g. "Event:v1".
|
||||||
--service-account string Name of the service account to use to run this source
|
--service-account string Name of the service account to use to run this source
|
||||||
-s, --sink string Addressable sink for events. You can specify a broker, Knative service or URI. Examples: '--sink broker:nest' for a broker 'nest', '--sink https://event.receiver.uri' for an URI with an 'http://' or 'https://' schema, '--sink ksvc:receiver' or simply '--sink receiver' for a Knative service 'receiver'. If a prefix is not provided, it is considered as a Knative service.
|
-s, --sink string Addressable sink for events. You can specify a broker, channel, Knative service or URI. Examples: '--sink broker:nest' for a broker 'nest', '--sink channel:pipe' for a channel 'pipe', '--sink https://event.receiver.uri' for an URI with an 'http://' or 'https://' schema, '--sink ksvc:receiver' or simply '--sink receiver' for a Knative service 'receiver'. If a prefix is not provided, it is considered as a Knative service.
|
||||||
```
|
```
|
||||||
|
|
||||||
### Options inherited from parent commands
|
### Options inherited from parent commands
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ kn source apiserver update NAME
|
||||||
--resource stringArray Specification for which events to listen, in the format Kind:APIVersion:LabelSelector, e.g. "Event:v1:key=value".
|
--resource stringArray Specification for which events to listen, in the format Kind:APIVersion:LabelSelector, e.g. "Event:v1:key=value".
|
||||||
"LabelSelector" is a list of comma separated key value pairs. "LabelSelector" can be omitted, e.g. "Event:v1".
|
"LabelSelector" is a list of comma separated key value pairs. "LabelSelector" can be omitted, e.g. "Event:v1".
|
||||||
--service-account string Name of the service account to use to run this source
|
--service-account string Name of the service account to use to run this source
|
||||||
-s, --sink string Addressable sink for events. You can specify a broker, Knative service or URI. Examples: '--sink broker:nest' for a broker 'nest', '--sink https://event.receiver.uri' for an URI with an 'http://' or 'https://' schema, '--sink ksvc:receiver' or simply '--sink receiver' for a Knative service 'receiver'. If a prefix is not provided, it is considered as a Knative service.
|
-s, --sink string Addressable sink for events. You can specify a broker, channel, Knative service or URI. Examples: '--sink broker:nest' for a broker 'nest', '--sink channel:pipe' for a channel 'pipe', '--sink https://event.receiver.uri' for an URI with an 'http://' or 'https://' schema, '--sink ksvc:receiver' or simply '--sink receiver' for a Knative service 'receiver'. If a prefix is not provided, it is considered as a Knative service.
|
||||||
```
|
```
|
||||||
|
|
||||||
### Options inherited from parent commands
|
### Options inherited from parent commands
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ kn source binding create NAME --subject SUBJECT --sink SINK
|
||||||
--ce-override stringArray Cloud Event overrides to apply before sending event to sink. Example: '--ce-override key=value' You may be provide this flag multiple times. To unset, append "-" to the key (e.g. --ce-override key-).
|
--ce-override stringArray Cloud Event overrides to apply before sending event to sink. Example: '--ce-override key=value' You may be provide this flag multiple times. To unset, append "-" to the key (e.g. --ce-override key-).
|
||||||
-h, --help help for create
|
-h, --help help for create
|
||||||
-n, --namespace string Specify the namespace to operate in.
|
-n, --namespace string Specify the namespace to operate in.
|
||||||
-s, --sink string Addressable sink for events. You can specify a broker, Knative service or URI. Examples: '--sink broker:nest' for a broker 'nest', '--sink https://event.receiver.uri' for an URI with an 'http://' or 'https://' schema, '--sink ksvc:receiver' or simply '--sink receiver' for a Knative service 'receiver'. If a prefix is not provided, it is considered as a Knative service.
|
-s, --sink string Addressable sink for events. You can specify a broker, channel, Knative service or URI. Examples: '--sink broker:nest' for a broker 'nest', '--sink channel:pipe' for a channel 'pipe', '--sink https://event.receiver.uri' for an URI with an 'http://' or 'https://' schema, '--sink ksvc:receiver' or simply '--sink receiver' for a Knative service 'receiver'. If a prefix is not provided, it is considered as a Knative service.
|
||||||
--subject string Subject which emits cloud events. This argument takes format kind:apiVersion:name for named resources or kind:apiVersion:labelKey1=value1,labelKey2=value2 for matching via a label selector
|
--subject string Subject which emits cloud events. This argument takes format kind:apiVersion:name for named resources or kind:apiVersion:labelKey1=value1,labelKey2=value2 for matching via a label selector
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ kn source binding update NAME
|
||||||
--ce-override stringArray Cloud Event overrides to apply before sending event to sink. Example: '--ce-override key=value' You may be provide this flag multiple times. To unset, append "-" to the key (e.g. --ce-override key-).
|
--ce-override stringArray Cloud Event overrides to apply before sending event to sink. Example: '--ce-override key=value' You may be provide this flag multiple times. To unset, append "-" to the key (e.g. --ce-override key-).
|
||||||
-h, --help help for update
|
-h, --help help for update
|
||||||
-n, --namespace string Specify the namespace to operate in.
|
-n, --namespace string Specify the namespace to operate in.
|
||||||
-s, --sink string Addressable sink for events. You can specify a broker, Knative service or URI. Examples: '--sink broker:nest' for a broker 'nest', '--sink https://event.receiver.uri' for an URI with an 'http://' or 'https://' schema, '--sink ksvc:receiver' or simply '--sink receiver' for a Knative service 'receiver'. If a prefix is not provided, it is considered as a Knative service.
|
-s, --sink string Addressable sink for events. You can specify a broker, channel, Knative service or URI. Examples: '--sink broker:nest' for a broker 'nest', '--sink channel:pipe' for a channel 'pipe', '--sink https://event.receiver.uri' for an URI with an 'http://' or 'https://' schema, '--sink ksvc:receiver' or simply '--sink receiver' for a Knative service 'receiver'. If a prefix is not provided, it is considered as a Knative service.
|
||||||
--subject string Subject which emits cloud events. This argument takes format kind:apiVersion:name for named resources or kind:apiVersion:labelKey1=value1,labelKey2=value2 for matching via a label selector
|
--subject string Subject which emits cloud events. This argument takes format kind:apiVersion:name for named resources or kind:apiVersion:labelKey1=value1,labelKey2=value2 for matching via a label selector
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ kn source ping create NAME --sink SINK
|
||||||
-h, --help help for create
|
-h, --help help for create
|
||||||
-n, --namespace string Specify the namespace to operate in.
|
-n, --namespace string Specify the namespace to operate in.
|
||||||
--schedule string Optional schedule specification in crontab format (e.g. '*/2 * * * *' for every two minutes. By default fire every minute.
|
--schedule string Optional schedule specification in crontab format (e.g. '*/2 * * * *' for every two minutes. By default fire every minute.
|
||||||
-s, --sink string Addressable sink for events. You can specify a broker, Knative service or URI. Examples: '--sink broker:nest' for a broker 'nest', '--sink https://event.receiver.uri' for an URI with an 'http://' or 'https://' schema, '--sink ksvc:receiver' or simply '--sink receiver' for a Knative service 'receiver'. If a prefix is not provided, it is considered as a Knative service.
|
-s, --sink string Addressable sink for events. You can specify a broker, channel, Knative service or URI. Examples: '--sink broker:nest' for a broker 'nest', '--sink channel:pipe' for a channel 'pipe', '--sink https://event.receiver.uri' for an URI with an 'http://' or 'https://' schema, '--sink ksvc:receiver' or simply '--sink receiver' for a Knative service 'receiver'. If a prefix is not provided, it is considered as a Knative service.
|
||||||
```
|
```
|
||||||
|
|
||||||
### Options inherited from parent commands
|
### Options inherited from parent commands
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ kn source ping update NAME
|
||||||
-h, --help help for update
|
-h, --help help for update
|
||||||
-n, --namespace string Specify the namespace to operate in.
|
-n, --namespace string Specify the namespace to operate in.
|
||||||
--schedule string Optional schedule specification in crontab format (e.g. '*/2 * * * *' for every two minutes. By default fire every minute.
|
--schedule string Optional schedule specification in crontab format (e.g. '*/2 * * * *' for every two minutes. By default fire every minute.
|
||||||
-s, --sink string Addressable sink for events. You can specify a broker, Knative service or URI. Examples: '--sink broker:nest' for a broker 'nest', '--sink https://event.receiver.uri' for an URI with an 'http://' or 'https://' schema, '--sink ksvc:receiver' or simply '--sink receiver' for a Knative service 'receiver'. If a prefix is not provided, it is considered as a Knative service.
|
-s, --sink string Addressable sink for events. You can specify a broker, channel, Knative service or URI. Examples: '--sink broker:nest' for a broker 'nest', '--sink channel:pipe' for a channel 'pipe', '--sink https://event.receiver.uri' for an URI with an 'http://' or 'https://' schema, '--sink ksvc:receiver' or simply '--sink receiver' for a Knative service 'receiver'. If a prefix is not provided, it is considered as a Knative service.
|
||||||
```
|
```
|
||||||
|
|
||||||
### Options inherited from parent commands
|
### Options inherited from parent commands
|
||||||
|
|
|
||||||
|
|
@ -27,9 +27,9 @@ kn subscription create NAME
|
||||||
--channel string Specify the channel to subscribe to. For the default channel, just use the name (e.g. 'mychannel'). A mapped channel type like 'imc' can be used as a prefix (e.g. 'imc:mychannel'). Finally you can specify the full coordinates to the referenced channel with Group:Version:Kind:Name (e.g. 'messaging.knative.dev:v1alpha1:KafkaChannel:mychannel').
|
--channel string Specify the channel to subscribe to. For the default channel, just use the name (e.g. 'mychannel'). A mapped channel type like 'imc' can be used as a prefix (e.g. 'imc:mychannel'). Finally you can specify the full coordinates to the referenced channel with Group:Version:Kind:Name (e.g. 'messaging.knative.dev:v1alpha1:KafkaChannel:mychannel').
|
||||||
-h, --help help for create
|
-h, --help help for create
|
||||||
-n, --namespace string Specify the namespace to operate in.
|
-n, --namespace string Specify the namespace to operate in.
|
||||||
-s, --sink string Addressable sink for events. You can specify a broker, Knative service or URI. Examples: '--sink broker:nest' for a broker 'nest', '--sink https://event.receiver.uri' for an URI with an 'http://' or 'https://' schema, '--sink ksvc:receiver' or simply '--sink receiver' for a Knative service 'receiver'. If a prefix is not provided, it is considered as a Knative service.
|
-s, --sink string Addressable sink for events. You can specify a broker, channel, Knative service or URI. Examples: '--sink broker:nest' for a broker 'nest', '--sink channel:pipe' for a channel 'pipe', '--sink https://event.receiver.uri' for an URI with an 'http://' or 'https://' schema, '--sink ksvc:receiver' or simply '--sink receiver' for a Knative service 'receiver'. If a prefix is not provided, it is considered as a Knative service.
|
||||||
--sink-dead-letter string Addressable sink for events. You can specify a broker, Knative service or URI. Examples: '--sink-dead-letter broker:nest' for a broker 'nest', '--sink-dead-letter https://event.receiver.uri' for an URI with an 'http://' or 'https://' schema, '--sink-dead-letter ksvc:receiver' or simply '--sink-dead-letter receiver' for a Knative service 'receiver'. If a prefix is not provided, it is considered as a Knative service.
|
--sink-dead-letter string Addressable sink for events. You can specify a broker, channel, Knative service or URI. Examples: '--sink-dead-letter broker:nest' for a broker 'nest', '--sink-dead-letter channel:pipe' for a channel 'pipe', '--sink-dead-letter https://event.receiver.uri' for an URI with an 'http://' or 'https://' schema, '--sink-dead-letter ksvc:receiver' or simply '--sink-dead-letter receiver' for a Knative service 'receiver'. If a prefix is not provided, it is considered as a Knative service.
|
||||||
--sink-reply string Addressable sink for events. You can specify a broker, Knative service or URI. Examples: '--sink-reply broker:nest' for a broker 'nest', '--sink-reply https://event.receiver.uri' for an URI with an 'http://' or 'https://' schema, '--sink-reply ksvc:receiver' or simply '--sink-reply receiver' for a Knative service 'receiver'. If a prefix is not provided, it is considered as a Knative service.
|
--sink-reply string Addressable sink for events. You can specify a broker, channel, Knative service or URI. Examples: '--sink-reply broker:nest' for a broker 'nest', '--sink-reply channel:pipe' for a channel 'pipe', '--sink-reply https://event.receiver.uri' for an URI with an 'http://' or 'https://' schema, '--sink-reply ksvc:receiver' or simply '--sink-reply receiver' for a Knative service 'receiver'. If a prefix is not provided, it is considered as a Knative service.
|
||||||
```
|
```
|
||||||
|
|
||||||
### Options inherited from parent commands
|
### Options inherited from parent commands
|
||||||
|
|
|
||||||
|
|
@ -26,9 +26,9 @@ kn subscription update NAME
|
||||||
```
|
```
|
||||||
-h, --help help for update
|
-h, --help help for update
|
||||||
-n, --namespace string Specify the namespace to operate in.
|
-n, --namespace string Specify the namespace to operate in.
|
||||||
-s, --sink string Addressable sink for events. You can specify a broker, Knative service or URI. Examples: '--sink broker:nest' for a broker 'nest', '--sink https://event.receiver.uri' for an URI with an 'http://' or 'https://' schema, '--sink ksvc:receiver' or simply '--sink receiver' for a Knative service 'receiver'. If a prefix is not provided, it is considered as a Knative service.
|
-s, --sink string Addressable sink for events. You can specify a broker, channel, Knative service or URI. Examples: '--sink broker:nest' for a broker 'nest', '--sink channel:pipe' for a channel 'pipe', '--sink https://event.receiver.uri' for an URI with an 'http://' or 'https://' schema, '--sink ksvc:receiver' or simply '--sink receiver' for a Knative service 'receiver'. If a prefix is not provided, it is considered as a Knative service.
|
||||||
--sink-dead-letter string Addressable sink for events. You can specify a broker, Knative service or URI. Examples: '--sink-dead-letter broker:nest' for a broker 'nest', '--sink-dead-letter https://event.receiver.uri' for an URI with an 'http://' or 'https://' schema, '--sink-dead-letter ksvc:receiver' or simply '--sink-dead-letter receiver' for a Knative service 'receiver'. If a prefix is not provided, it is considered as a Knative service.
|
--sink-dead-letter string Addressable sink for events. You can specify a broker, channel, Knative service or URI. Examples: '--sink-dead-letter broker:nest' for a broker 'nest', '--sink-dead-letter channel:pipe' for a channel 'pipe', '--sink-dead-letter https://event.receiver.uri' for an URI with an 'http://' or 'https://' schema, '--sink-dead-letter ksvc:receiver' or simply '--sink-dead-letter receiver' for a Knative service 'receiver'. If a prefix is not provided, it is considered as a Knative service.
|
||||||
--sink-reply string Addressable sink for events. You can specify a broker, Knative service or URI. Examples: '--sink-reply broker:nest' for a broker 'nest', '--sink-reply https://event.receiver.uri' for an URI with an 'http://' or 'https://' schema, '--sink-reply ksvc:receiver' or simply '--sink-reply receiver' for a Knative service 'receiver'. If a prefix is not provided, it is considered as a Knative service.
|
--sink-reply string Addressable sink for events. You can specify a broker, channel, Knative service or URI. Examples: '--sink-reply broker:nest' for a broker 'nest', '--sink-reply channel:pipe' for a channel 'pipe', '--sink-reply https://event.receiver.uri' for an URI with an 'http://' or 'https://' schema, '--sink-reply ksvc:receiver' or simply '--sink-reply receiver' for a Knative service 'receiver'. If a prefix is not provided, it is considered as a Knative service.
|
||||||
```
|
```
|
||||||
|
|
||||||
### Options inherited from parent commands
|
### Options inherited from parent commands
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ kn trigger create NAME --sink SINK
|
||||||
-h, --help help for create
|
-h, --help help for create
|
||||||
--inject-broker Create new broker with name default through common annotation
|
--inject-broker Create new broker with name default through common annotation
|
||||||
-n, --namespace string Specify the namespace to operate in.
|
-n, --namespace string Specify the namespace to operate in.
|
||||||
-s, --sink string Addressable sink for events. You can specify a broker, Knative service or URI. Examples: '--sink broker:nest' for a broker 'nest', '--sink https://event.receiver.uri' for an URI with an 'http://' or 'https://' schema, '--sink ksvc:receiver' or simply '--sink receiver' for a Knative service 'receiver'. If a prefix is not provided, it is considered as a Knative service.
|
-s, --sink string Addressable sink for events. You can specify a broker, channel, Knative service or URI. Examples: '--sink broker:nest' for a broker 'nest', '--sink channel:pipe' for a channel 'pipe', '--sink https://event.receiver.uri' for an URI with an 'http://' or 'https://' schema, '--sink ksvc:receiver' or simply '--sink receiver' for a Knative service 'receiver'. If a prefix is not provided, it is considered as a Knative service.
|
||||||
```
|
```
|
||||||
|
|
||||||
### Options inherited from parent commands
|
### Options inherited from parent commands
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ kn trigger update NAME
|
||||||
-h, --help help for update
|
-h, --help help for update
|
||||||
--inject-broker Create new broker with name default through common annotation
|
--inject-broker Create new broker with name default through common annotation
|
||||||
-n, --namespace string Specify the namespace to operate in.
|
-n, --namespace string Specify the namespace to operate in.
|
||||||
-s, --sink string Addressable sink for events. You can specify a broker, Knative service or URI. Examples: '--sink broker:nest' for a broker 'nest', '--sink https://event.receiver.uri' for an URI with an 'http://' or 'https://' schema, '--sink ksvc:receiver' or simply '--sink receiver' for a Knative service 'receiver'. If a prefix is not provided, it is considered as a Knative service.
|
-s, --sink string Addressable sink for events. You can specify a broker, channel, Knative service or URI. Examples: '--sink broker:nest' for a broker 'nest', '--sink channel:pipe' for a channel 'pipe', '--sink https://event.receiver.uri' for an URI with an 'http://' or 'https://' schema, '--sink ksvc:receiver' or simply '--sink receiver' for a Knative service 'receiver'. If a prefix is not provided, it is considered as a Knative service.
|
||||||
```
|
```
|
||||||
|
|
||||||
### Options inherited from parent commands
|
### Options inherited from parent commands
|
||||||
|
|
|
||||||
|
|
@ -43,8 +43,9 @@ func (i *SinkFlags) AddWithFlagName(cmd *cobra.Command, fname, short string) {
|
||||||
cmd.Flags().StringVarP(&i.sink, fname, short, "", "")
|
cmd.Flags().StringVarP(&i.sink, fname, short, "", "")
|
||||||
}
|
}
|
||||||
cmd.Flag(fname).Usage = "Addressable sink for events. " +
|
cmd.Flag(fname).Usage = "Addressable sink for events. " +
|
||||||
"You can specify a broker, Knative service or URI. " +
|
"You can specify a broker, channel, Knative service or URI. " +
|
||||||
"Examples: '" + flag + " broker:nest' for a broker 'nest', " +
|
"Examples: '" + flag + " broker:nest' for a broker 'nest', " +
|
||||||
|
"'" + flag + " channel:pipe' for a channel 'pipe', " +
|
||||||
"'" + flag + " https://event.receiver.uri' for an URI with an 'http://' or 'https://' schema, " +
|
"'" + flag + " https://event.receiver.uri' for an URI with an 'http://' or 'https://' schema, " +
|
||||||
"'" + flag + " ksvc:receiver' or simply '" + flag + " receiver' for a Knative service 'receiver'. " +
|
"'" + flag + " ksvc:receiver' or simply '" + flag + " receiver' for a Knative service 'receiver'. " +
|
||||||
"If a prefix is not provided, it is considered as a Knative service."
|
"If a prefix is not provided, it is considered as a Knative service."
|
||||||
|
|
@ -77,6 +78,11 @@ var sinkMappings = map[string]schema.GroupVersionResource{
|
||||||
Group: "serving.knative.dev",
|
Group: "serving.knative.dev",
|
||||||
Version: "v1",
|
Version: "v1",
|
||||||
},
|
},
|
||||||
|
"channel": {
|
||||||
|
Resource: "channels",
|
||||||
|
Group: "messaging.knative.dev",
|
||||||
|
Version: "v1beta1",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
// ResolveSink returns the Destination referred to by the flags in the acceptor.
|
// ResolveSink returns the Destination referred to by the flags in the acceptor.
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ import (
|
||||||
"gotest.tools/assert"
|
"gotest.tools/assert"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
eventingv1beta1 "knative.dev/eventing/pkg/apis/eventing/v1beta1"
|
eventingv1beta1 "knative.dev/eventing/pkg/apis/eventing/v1beta1"
|
||||||
|
messagingv1beta1 "knative.dev/eventing/pkg/apis/messaging/v1beta1"
|
||||||
"knative.dev/pkg/apis"
|
"knative.dev/pkg/apis"
|
||||||
duckv1 "knative.dev/pkg/apis/duck/v1"
|
duckv1 "knative.dev/pkg/apis/duck/v1"
|
||||||
servingv1 "knative.dev/serving/pkg/apis/serving/v1"
|
servingv1 "knative.dev/serving/pkg/apis/serving/v1"
|
||||||
|
|
@ -70,6 +71,8 @@ func TestSinkFlagAdd(t *testing.T) {
|
||||||
|
|
||||||
func TestResolve(t *testing.T) {
|
func TestResolve(t *testing.T) {
|
||||||
targetExampleCom, err := apis.ParseURL("http://target.example.com")
|
targetExampleCom, err := apis.ParseURL("http://target.example.com")
|
||||||
|
assert.NilError(t, err)
|
||||||
|
|
||||||
mysvc := &servingv1.Service{
|
mysvc := &servingv1.Service{
|
||||||
TypeMeta: metav1.TypeMeta{Kind: "Service", APIVersion: "serving.knative.dev/v1"},
|
TypeMeta: metav1.TypeMeta{Kind: "Service", APIVersion: "serving.knative.dev/v1"},
|
||||||
ObjectMeta: metav1.ObjectMeta{Name: "mysvc", Namespace: "default"},
|
ObjectMeta: metav1.ObjectMeta{Name: "mysvc", Namespace: "default"},
|
||||||
|
|
@ -78,8 +81,11 @@ func TestResolve(t *testing.T) {
|
||||||
TypeMeta: metav1.TypeMeta{Kind: "Broker", APIVersion: "eventing.knative.dev/v1beta1"},
|
TypeMeta: metav1.TypeMeta{Kind: "Broker", APIVersion: "eventing.knative.dev/v1beta1"},
|
||||||
ObjectMeta: metav1.ObjectMeta{Name: "default", Namespace: "default"},
|
ObjectMeta: metav1.ObjectMeta{Name: "default", Namespace: "default"},
|
||||||
}
|
}
|
||||||
|
pipeChannel := &messagingv1beta1.Channel{
|
||||||
|
TypeMeta: metav1.TypeMeta{Kind: "Channel", APIVersion: "messaging.knative.dev/v1beta1"},
|
||||||
|
ObjectMeta: metav1.ObjectMeta{Name: "pipe", Namespace: "default"},
|
||||||
|
}
|
||||||
|
|
||||||
assert.NilError(t, err)
|
|
||||||
cases := []resolveCase{
|
cases := []resolveCase{
|
||||||
{"ksvc:mysvc", &duckv1.Destination{
|
{"ksvc:mysvc", &duckv1.Destination{
|
||||||
Ref: &duckv1.KReference{Kind: "Service",
|
Ref: &duckv1.KReference{Kind: "Service",
|
||||||
|
|
@ -97,6 +103,16 @@ func TestResolve(t *testing.T) {
|
||||||
APIVersion: "eventing.knative.dev/v1beta1",
|
APIVersion: "eventing.knative.dev/v1beta1",
|
||||||
Namespace: "default",
|
Namespace: "default",
|
||||||
Name: "default"}}, ""},
|
Name: "default"}}, ""},
|
||||||
|
{"channel:pipe",
|
||||||
|
&duckv1.Destination{
|
||||||
|
Ref: &duckv1.KReference{Kind: "Channel",
|
||||||
|
APIVersion: "messaging.knative.dev/v1beta1",
|
||||||
|
Namespace: "default",
|
||||||
|
Name: "pipe",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
""},
|
||||||
|
|
||||||
{"http://target.example.com", &duckv1.Destination{
|
{"http://target.example.com", &duckv1.Destination{
|
||||||
URI: targetExampleCom,
|
URI: targetExampleCom,
|
||||||
}, ""},
|
}, ""},
|
||||||
|
|
@ -104,7 +120,7 @@ func TestResolve(t *testing.T) {
|
||||||
{"svc:foo", nil, "please use prefix 'ksvc' for knative service"},
|
{"svc:foo", nil, "please use prefix 'ksvc' for knative service"},
|
||||||
{"service:foo", nil, "please use prefix 'ksvc' for knative service"},
|
{"service:foo", nil, "please use prefix 'ksvc' for knative service"},
|
||||||
}
|
}
|
||||||
dynamicClient := dynamicfake.CreateFakeKnDynamicClient("default", mysvc, defaultBroker)
|
dynamicClient := dynamicfake.CreateFakeKnDynamicClient("default", mysvc, defaultBroker, pipeChannel)
|
||||||
for _, c := range cases {
|
for _, c := range cases {
|
||||||
i := &SinkFlags{c.sink}
|
i := &SinkFlags{c.sink}
|
||||||
result, err := i.ResolveSink(dynamicClient, "default")
|
result, err := i.ResolveSink(dynamicClient, "default")
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,15 @@ func TestSink(t *testing.T) {
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
assert.Equal(t, out, "default")
|
assert.Equal(t, out, "default")
|
||||||
|
|
||||||
|
// create a channel
|
||||||
|
test.ChannelCreate(r, "pipe")
|
||||||
|
|
||||||
|
t.Log("Update Ping source with a sink to the channel")
|
||||||
|
pingSourceUpdateSink(r, "testpingsource0", "channel:pipe")
|
||||||
|
out, err = test.GetResourceFieldsWithJSONPath(t, it, "pingsource", "testpingsource0", jpSinkRefNameInSpec)
|
||||||
|
assert.NilError(t, err)
|
||||||
|
assert.Equal(t, out, "pipe")
|
||||||
|
|
||||||
t.Log("delete Ping sources")
|
t.Log("delete Ping sources")
|
||||||
pingSourceDelete(r, "testpingsource0")
|
pingSourceDelete(r, "testpingsource0")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue