mirror of https://github.com/knative/client.git
Add support for providing sink spec in GVR format (#1717)
This commit is contained in:
parent
ebc672993a
commit
bf20fe2185
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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"},
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue