Repository: knative/client (go)

Issue:
Add support for providing sink spec in GVR format
<!-- If you need to report a security issue with Knative, send an email to knative-security@googlegroups.com. -->

### Feature request
The user can specify a sink in subscription create and update (`--sink`, `--sink-reply`, `--sink-dead-letter` flags), source create and update(`--sink` flag), and broker create and update (`--dl-sink` flag). Currently, only a few known types are supported as an argument to these flags ("broker", "ksvc", and "channel"). If the user provides any other prefix outside the supported ones, `kn` returns an `unsupported sink prefix` error.
<!-- Please describe the feature request and why you would like to have it -->

### Use case
To use sinks of custom types.
<!-- Please add a concrete use case to demonstrate how such a feature would add value for the user. If you don't have a use case for your feature, please remove this section (however providing a good use case increases the likelihood to be picked up) -->

### UI Example

<!-- If this is about a new command or command line options, please let us know how you would add it to the "kn" UI (in the code block below). If this is not applicable for your feature, delete this section. -->

```
kn source ping create my-ping --schedule "*/2 * * * *" --data '{ value: "hello" }' --sink <apiVersion>:<kind>:<name>:<namespace>
```

<!--
Optional Classifications, remove the '> ' to select:
> /kind good-first-issue
> /kind proposal
> /kind doc
> /kind cleanup
-->


Pull request description:
Add support for providing sink spec in GVR format
## Description

<!-- Please add a short summary about what the pull request is going to bring on the table -->

## Changes

<!-- Please add list of more detailed changes. These changes should be reflected also in the commit messages -->

* The user can specify the sink with custom resource types
* Follows the format: `prefix:name:namespace` where prefix is the group version resource

## Reference

<!-- Please add the corresponding issue number which this pull request is about to fix -->
Fixes #1704

**Release Note**

<!-- Enter your extended release note in the below block. If the PR requires
additional action from users switching to the new release, include the string
"action required". If no release note is required, write "NONE". -->

```release-note
Add support for providing sink spec in GVR format
```

<!--
Please add an entry to CHANGELOG.adoc file, too, as part of your Pull Request.

In the following cases, add a short description of PR to the unreleased section in CHANGELOG.adoc:

- 🎁 New feature
- 🐛 Bug fix
- ✨ Feature Update
- 🐣 Refactoring
- 🗑️ Remove feature or internal logic

See other entries in CHANGELOG.adoc as an example for how to add the entry, including a reference to the corresponding issue/PR

PLEASE DON'T ADD THAT LINE HERE IN THE PULL-REQUEST DESCRIPTION BUT DIRECTLY IN CHANGELOG.ADOC AND ADD CHANGELOG.ADOC AS PART OF YOUR PULL-REQUEST.
-->

<!--
To automatically lint go code in this pull request uncomment the line below. You get feedback as comments on your pull request then -->

<!--
/lint
-->


Patch:
diff --git a/go.mod b/go.mod
index def052b2..457b08cd 100644
--- a/go.mod
+++ b/go.mod
@@ -21,11 +21,11 @@ require (
 	k8s.io/cli-runtime v0.23.4
 	k8s.io/client-go v0.23.9
 	k8s.io/code-generator v0.23.9
-	knative.dev/eventing v0.33.1-0.20220728144837-15dd7ca8c811
+	knative.dev/eventing v0.33.1-0.20220809080920-c884e27795f7
 	knative.dev/hack v0.0.0-20220728013938-9dabf7cf62e3
 	knative.dev/networking v0.0.0-20220803115018-d2c739da1c1b
-	knative.dev/pkg v0.0.0-20220802185824-a01dfedb0486
-	knative.dev/serving v0.33.1-0.20220803152329-bfa381a72c6b
+	knative.dev/pkg v0.0.0-20220805012121-7b8b06028e4f
+	knative.dev/serving v0.33.1-0.20220808151524-fd833bc9c9f6
 	sigs.k8s.io/yaml v1.3.0
 )
 
diff --git a/go.sum b/go.sum
index 79805927..3983dec5 100644
--- a/go.sum
+++ b/go.sum
@@ -1318,16 +1318,16 @@ k8s.io/utils v0.0.0-20210802155522-efc7438f0176/go.mod h1:jPW/WVKK9YHAvNhRxK0md/
 k8s.io/utils v0.0.0-20211116205334-6203023598ed/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
 k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 h1:HNSDgDCrr/6Ly3WEGKZftiE7IY19Vz2GdbOCyI4qqhc=
 k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
-knative.dev/eventing v0.33.1-0.20220728144837-15dd7ca8c811 h1:JO83M4YKP44eApBDQeEU8+DGuLwJjHbi8+9ZRnUQx+s=
-knative.dev/eventing v0.33.1-0.20220728144837-15dd7ca8c811/go.mod h1:rxOHyuk8ssl+ymaSpeA1ZsRJcG6gSlgje2+di6LoFmg=
+knative.dev/eventing v0.33.1-0.20220809080920-c884e27795f7 h1:jg9UrgsupzJnIFZOjgAS9FMD09ej213zcznYUH6s/IQ=
+knative.dev/eventing v0.33.1-0.20220809080920-c884e27795f7/go.mod h1:Un3zodfDFZVyXc64I4IVQtcpW7AIBvEspf9LixGqO3E=
 knative.dev/hack v0.0.0-20220728013938-9dabf7cf62e3 h1:1JsQ8ylMK+9yQfuxXvGBux+NOzvNLQyoyTXlupBrfHE=
 knative.dev/hack v0.0.0-20220728013938-9dabf7cf62e3/go.mod h1:t/azP8I/Cygaw+87O7rkAPrNRjCelmtfSzWzu/9TM7I=
 knative.dev/networking v0.0.0-20220803115018-d2c739da1c1b h1:qxVG4TOwaPQi5ep5sWSK67xD0E85dGlLCOfrWtHINgs=
 knative.dev/networking v0.0.0-20220803115018-d2c739da1c1b/go.mod h1:wwhZW0N+qYb81ZsgDI/yxS1dwN+hoi++m01ft+HxG08=
-knative.dev/pkg v0.0.0-20220802185824-a01dfedb0486 h1:eWw7LtEIq2GjR9Z5Uw86BlVYyLh50ueJfcXV0SQiMWc=
-knative.dev/pkg v0.0.0-20220802185824-a01dfedb0486/go.mod h1:nBMKMJvyoaJdkpUrjwLVs/DwaP6d73R3UkXK6lblJyE=
-knative.dev/serving v0.33.1-0.20220803152329-bfa381a72c6b h1:4MTDVoeMQttGYPE7P8uNloctgo4xc+LFXEcKe7JifnE=
-knative.dev/serving v0.33.1-0.20220803152329-bfa381a72c6b/go.mod h1:7COCQVqcuxe7FN6Gds+NyT/Gs5bSl6OlNcHCKzZ1y2c=
+knative.dev/pkg v0.0.0-20220805012121-7b8b06028e4f h1:kW4K5SsjZ7qMzM8TCqHdDmpv0xKN4Jje4BXhDcByFUI=
+knative.dev/pkg v0.0.0-20220805012121-7b8b06028e4f/go.mod h1:nBMKMJvyoaJdkpUrjwLVs/DwaP6d73R3UkXK6lblJyE=
+knative.dev/serving v0.33.1-0.20220808151524-fd833bc9c9f6 h1:sly8jvp+SKeIuDDhipfRJ+7bKTiFcI2c0e7Q/YnoBHQ=
+knative.dev/serving v0.33.1-0.20220808151524-fd833bc9c9f6/go.mod h1:iA1F+M0tcAkwrPSgF5CSXs6L6VY5MAPDT/sKdmDGVQ4=
 rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
 rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
 rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
diff --git a/pkg/kn/commands/flags/sink.go b/pkg/kn/commands/flags/sink.go
index e0cabb6e..9cc8fea7 100644
--- a/pkg/kn/commands/flags/sink.go
+++ b/pkg/kn/commands/flags/sink.go
@@ -108,7 +108,21 @@ func (i *SinkFlags) ResolveSink(ctx context.Context, knclient clientdynamic.KnDy
 		if prefix == "svc" || prefix == "service" {
 			return nil, fmt.Errorf("unsupported sink prefix: '%s', please use prefix 'ksvc' for knative service", prefix)
 		}
-		return nil, fmt.Errorf("unsupported sink prefix: '%s', if referring to a knative service in another namespace, 'ksvc:name:namespace' combination must be provided explicitly", prefix)
+		idx := strings.LastIndex(prefix, "/")
+		var groupVersion string
+		var kind string
+		if idx != -1 && idx < len(prefix)-1 {
+			groupVersion, kind = prefix[:idx], prefix[idx+1:]
+		} else {
+			kind = prefix
+		}
+		parsedVersion, _ := schema.ParseGroupVersion(groupVersion)
+
+		typ = schema.GroupVersionResource{
+			Group:    parsedVersion.Group,
+			Version:  parsedVersion.Version,
+			Resource: kind,
+		}
 	}
 	if ns != "" {
 		namespace = ns
diff --git a/vendor/knative.dev/eventing/pkg/apis/eventing/v1/trigger_validation.go b/vendor/knative.dev/eventing/pkg/apis/eventing/v1/trigger_validation.go
index bcff34b9..64c3fb2d 100644
--- a/vendor/knative.dev/eventing/pkg/apis/eventing/v1/trigger_validation.go
+++ b/vendor/knative.dev/eventing/pkg/apis/eventing/v1/trigger_validation.go
@@ -168,22 +168,6 @@ func ValidateAttributesNames(attrs map[string]string) (errs *apis.FieldError) {
 	return errs
 }
 
-func ValidateSingleAttributeMap(expr map[string]string) (errs *apis.FieldError) {
-	if len(expr) == 0 {
-		return nil
-	}
-
-	if len(expr) != 1 {
-		return apis.ErrGeneric("Multiple items found, can have only one key-value", apis.CurrentField)
-	}
-	for attr := range expr {
-		if !validAttributeName.MatchString(attr) {
-			errs = errs.Also(apis.ErrInvalidKeyName(attr, apis.CurrentField, "Attribute name must start with a letter and can only contain lowercase alphanumeric").ViaKey(attr))
-		}
-	}
-	return errs
-}
-
 func ValidateSubscriptionAPIFiltersList(ctx context.Context, filters []SubscriptionsAPIFilter) (errs *apis.FieldError) {
 	if filters == nil || !feature.FromContext(ctx).IsEnabled(feature.NewTriggerFilters) {
 		return nil
@@ -221,11 +205,11 @@ func ValidateSubscriptionAPIFilter(ctx context.Context, filter *SubscriptionsAPI
 	errs = errs.Also(
 		ValidateOneOf(filter),
 	).Also(
-		ValidateSingleAttributeMap(filter.Exact).ViaField("exact"),
+		ValidateAttributesNames(filter.Exact).ViaField("exact"),
 	).Also(
-		ValidateSingleAttributeMap(filter.Prefix).ViaField("prefix"),
+		ValidateAttributesNames(filter.Prefix).ViaField("prefix"),
 	).Also(
-		ValidateSingleAttributeMap(filter.Suffix).ViaField("suffix"),
+		ValidateAttributesNames(filter.Suffix).ViaField("suffix"),
 	).Also(
 		ValidateSubscriptionAPIFiltersList(ctx, filter.All).ViaField("all"),
 	).Also(
diff --git a/vendor/knative.dev/eventing/pkg/apis/messaging/v1/subscription_types.go b/vendor/knative.dev/eventing/pkg/apis/messaging/v1/subscription_types.go
index 4bd637cb..ec80fea2 100644
--- a/vendor/knative.dev/eventing/pkg/apis/messaging/v1/subscription_types.go
+++ b/vendor/knative.dev/eventing/pkg/apis/messaging/v1/subscription_types.go
@@ -90,10 +90,9 @@ type SubscriptionSpec struct {
 	// etc.)
 	Channel duckv1.KReference `json:"channel"`
 
-	// Subscriber is reference to (optional) function for processing events.
+	// Subscriber is reference to function for processing events.
 	// Events from the Channel will be delivered here and replies are
 	// sent to a Destination as specified by the Reply.
-	// +optional
 	Subscriber *duckv1.Destination `json:"subscriber,omitempty"`
 
 	// Reply specifies (optionally) how to handle events returned from
diff --git a/vendor/modules.txt b/vendor/modules.txt
index 3a361061..86a06f81 100644
--- a/vendor/modules.txt
+++ b/vendor/modules.txt
@@ -902,8 +902,8 @@ k8s.io/utils/lru
 k8s.io/utils/net
 k8s.io/utils/pointer
 k8s.io/utils/trace
-# knative.dev/eventing v0.33.1-0.20220728144837-15dd7ca8c811
-## explicit; go 1.17
+# knative.dev/eventing v0.33.1-0.20220809080920-c884e27795f7
+## explicit; go 1.18
 knative.dev/eventing/pkg/apis/config
 knative.dev/eventing/pkg/apis/duck
 knative.dev/eventing/pkg/apis/duck/v1
@@ -948,7 +948,7 @@ knative.dev/networking/pkg/http/probe
 knative.dev/networking/pkg/http/proxy
 knative.dev/networking/pkg/http/stats
 knative.dev/networking/pkg/k8s
-# knative.dev/pkg v0.0.0-20220802185824-a01dfedb0486
+# knative.dev/pkg v0.0.0-20220805012121-7b8b06028e4f
 ## explicit; go 1.18
 knative.dev/pkg/apis
 knative.dev/pkg/apis/duck
@@ -998,7 +998,7 @@ knative.dev/pkg/tracing/config
 knative.dev/pkg/tracing/propagation
 knative.dev/pkg/tracing/propagation/tracecontextb3
 knative.dev/pkg/tracker
-# knative.dev/serving v0.33.1-0.20220803152329-bfa381a72c6b
+# knative.dev/serving v0.33.1-0.20220808151524-fd833bc9c9f6
 ## explicit; go 1.18
 knative.dev/serving/pkg/apis/autoscaling
 knative.dev/serving/pkg/apis/autoscaling/v1alpha1


Test patch:
diff --git a/pkg/kn/commands/flags/sink_test.go b/pkg/kn/commands/flags/sink_test.go
index 3f63529d..a194759a 100644
--- a/pkg/kn/commands/flags/sink_test.go
+++ b/pkg/kn/commands/flags/sink_test.go
@@ -117,7 +117,7 @@ func TestResolve(t *testing.T) {
 		{"http://target.example.com", &duckv1.Destination{
 			URI: targetExampleCom,
 		}, ""},
-		{"k8ssvc:foo", nil, "unsupported sink prefix: 'k8ssvc'"},
+		{"k8ssvc:foo", nil, "k8ssvc \"foo\" not found"},
 		{"svc:foo", nil, "please use prefix 'ksvc' for knative service"},
 		{"service:foo", nil, "please use prefix 'ksvc' for knative service"},
 	}