diff --git a/docs/cmd/kn.md b/docs/cmd/kn.md index b52df1ab73..0298879a18 100644 --- a/docs/cmd/kn.md +++ b/docs/cmd/kn.md @@ -28,5 +28,6 @@ Manage your Knative building blocks: * [kn route](kn_route.md) - Route command group * [kn service](kn_service.md) - Service command group * [kn source](kn_source.md) - Event source command group +* [kn trigger](kn_trigger.md) - Trigger command group * [kn version](kn_version.md) - Prints the client version diff --git a/docs/cmd/kn_trigger.md b/docs/cmd/kn_trigger.md new file mode 100644 index 0000000000..d0a2896e87 --- /dev/null +++ b/docs/cmd/kn_trigger.md @@ -0,0 +1,33 @@ +## kn trigger + +Trigger command group + +### Synopsis + +Trigger command group + +``` +kn trigger [flags] +``` + +### Options + +``` + -h, --help help for trigger +``` + +### Options inherited from parent commands + +``` + --config string kn config file (default is $HOME/.kn/config.yaml) + --kubeconfig string kubectl config file (default is $HOME/.kube/config) + --log-http log http traffic +``` + +### SEE ALSO + +* [kn](kn.md) - Knative client +* [kn trigger create](kn_trigger_create.md) - Create a trigger +* [kn trigger delete](kn_trigger_delete.md) - Delete a trigger. +* [kn trigger describe](kn_trigger_describe.md) - Describe a trigger. + diff --git a/docs/cmd/kn_trigger_create.md b/docs/cmd/kn_trigger_create.md new file mode 100644 index 0000000000..62990fd47c --- /dev/null +++ b/docs/cmd/kn_trigger_create.md @@ -0,0 +1,42 @@ +## kn trigger create + +Create a trigger + +### Synopsis + +Create a trigger + +``` +kn trigger create NAME --broker BROKER --filter KEY=VALUE --sink SINK [flags] +``` + +### Examples + +``` + + # Create a trigger 'mytrigger' to declare a subscription to events with attribute 'type=dev.knative.foo' from default broker. The subscriber is service 'mysvc' + kn trigger create mytrigger --broker default --filter type=dev.knative.foo --sink svc:mysvc +``` + +### Options + +``` + --broker string Name of the Broker which the trigger associates with. (default "default") + --filter []string Key-value pair for exact CloudEvent attribute matching against incoming events, e.g type=dev.knative.foo + -h, --help help for create + -n, --namespace string Specify the namespace to operate in. + -s, --sink string Addressable sink for events +``` + +### Options inherited from parent commands + +``` + --config string kn config file (default is $HOME/.kn/config.yaml) + --kubeconfig string kubectl config file (default is $HOME/.kube/config) + --log-http log http traffic +``` + +### SEE ALSO + +* [kn trigger](kn_trigger.md) - Trigger command group + diff --git a/docs/cmd/kn_trigger_delete.md b/docs/cmd/kn_trigger_delete.md new file mode 100644 index 0000000000..652fd4ab4c --- /dev/null +++ b/docs/cmd/kn_trigger_delete.md @@ -0,0 +1,39 @@ +## kn trigger delete + +Delete a trigger. + +### Synopsis + +Delete a trigger. + +``` +kn trigger delete NAME [flags] +``` + +### Examples + +``` + + # Delete a trigger 'mytrigger' in default namespace + kn trigger delete mytrigger +``` + +### Options + +``` + -h, --help help for delete + -n, --namespace string Specify the namespace to operate in. +``` + +### Options inherited from parent commands + +``` + --config string kn config file (default is $HOME/.kn/config.yaml) + --kubeconfig string kubectl config file (default is $HOME/.kube/config) + --log-http log http traffic +``` + +### SEE ALSO + +* [kn trigger](kn_trigger.md) - Trigger command group + diff --git a/docs/cmd/kn_trigger_describe.md b/docs/cmd/kn_trigger_describe.md new file mode 100644 index 0000000000..e483b277cb --- /dev/null +++ b/docs/cmd/kn_trigger_describe.md @@ -0,0 +1,40 @@ +## kn trigger describe + +Describe a trigger. + +### Synopsis + +Describe a trigger. + +``` +kn trigger describe NAME [flags] +``` + +### Examples + +``` + + # Describe a trigger with name 'my-trigger' + kn trigger describe my-trigger +``` + +### Options + +``` + -h, --help help for describe + -n, --namespace string Specify the namespace to operate in. + -v, --verbose More output. +``` + +### Options inherited from parent commands + +``` + --config string kn config file (default is $HOME/.kn/config.yaml) + --kubeconfig string kubectl config file (default is $HOME/.kube/config) + --log-http log http traffic +``` + +### SEE ALSO + +* [kn trigger](kn_trigger.md) - Trigger command group + diff --git a/pkg/eventing/v1alpha1/client.go b/pkg/eventing/v1alpha1/client.go new file mode 100644 index 0000000000..9431672e37 --- /dev/null +++ b/pkg/eventing/v1alpha1/client.go @@ -0,0 +1,84 @@ +// Copyright © 2019 The Knative Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package v1alpha1 + +import ( + apis_v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + kn_errors "knative.dev/client/pkg/errors" + "knative.dev/eventing/pkg/apis/eventing/v1alpha1" + client_v1alpha1 "knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1alpha1" +) + +// KnEventingClient to Eventing Sources. All methods are relative to the +// namespace specified during construction +type KnEventingClient interface { + // Namespace in which this client is operating for + Namespace() string + // CreateTrigger is used to create an instance of trigger + CreateTrigger(trigger *v1alpha1.Trigger) (*v1alpha1.Trigger, error) + // DeleteTrigger is used to delete an instance of trigger + DeleteTrigger(name string) error + // GetTrigger is used to get an instance of trigger + GetTrigger(name string) (*v1alpha1.Trigger, error) +} + +// KnEventingClient is a combination of Sources client interface and namespace +// Temporarily help to add sources dependencies +// May be changed when adding real sources features +type knEventingClient struct { + client client_v1alpha1.EventingV1alpha1Interface + namespace string +} + +// NewKnEventingClient is to invoke Eventing Sources Client API to create object +func NewKnEventingClient(client client_v1alpha1.EventingV1alpha1Interface, namespace string) KnEventingClient { + return &knEventingClient{ + client: client, + namespace: namespace, + } +} + +//CreateTrigger is used to create an instance of trigger +func (c *knEventingClient) CreateTrigger(trigger *v1alpha1.Trigger) (*v1alpha1.Trigger, error) { + trigger, err := c.client.Triggers(c.namespace).Create(trigger) + if err != nil { + return nil, kn_errors.GetError(err) + } + return trigger, nil +} + +//DeleteTrigger is used to delete an instance of trigger +func (c *knEventingClient) DeleteTrigger(name string) error { + err := c.client.Triggers(c.namespace).Delete(name, &apis_v1.DeleteOptions{}) + if err != nil { + return kn_errors.GetError(err) + } + return nil +} + +//GetTrigger is used to get an instance of trigger +func (c *knEventingClient) GetTrigger(name string) (*v1alpha1.Trigger, error) { + trigger, err := c.client.Triggers(c.namespace).Get(name, apis_v1.GetOptions{}) + if err != nil { + return nil, kn_errors.GetError(err) + } + return trigger, nil +} + +// Return the client's namespace +func (c *knEventingClient) Namespace() string { + return c.namespace +} diff --git a/pkg/eventing/v1alpha1/client_mock.go b/pkg/eventing/v1alpha1/client_mock.go new file mode 100644 index 0000000000..c5ed01e3ff --- /dev/null +++ b/pkg/eventing/v1alpha1/client_mock.go @@ -0,0 +1,97 @@ +// Copyright © 2019 The Knative Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package v1alpha1 + +import ( + "testing" + + "knative.dev/client/pkg/util/mock" + "knative.dev/eventing/pkg/apis/eventing/v1alpha1" +) + +// MockKnEventingClient is a combine of test object and recorder +type MockKnEventingClient struct { + t *testing.T + recorder *EventingRecorder + namespace string +} + +// NewMockKnEventingClient returns a new mock instance which you need to record for +func NewMockKnEventingClient(t *testing.T, ns ...string) *MockKnEventingClient { + namespace := "default" + if len(ns) > 0 { + namespace = ns[0] + } + return &MockKnEventingClient{ + t: t, + recorder: &EventingRecorder{mock.NewRecorder(t, namespace)}, + } +} + +// Ensure that the interface is implemented +var _ KnEventingClient = &MockKnEventingClient{} + +// EventingRecorder is recorder for eventing objects +type EventingRecorder struct { + r *mock.Recorder +} + +// Recorder returns the recorder for registering API calls +func (c *MockKnEventingClient) Recorder() *EventingRecorder { + return c.recorder +} + +// Namespace of this client +func (c *MockKnEventingClient) Namespace() string { + return c.recorder.r.Namespace() +} + +// CreateTrigger records a call for CreateCronJobSource with the expected error +func (sr *EventingRecorder) CreateTrigger(trigger interface{}, err error) { + sr.r.Add("CreateTrigger", []interface{}{trigger}, []interface{}{trigger, err}) +} + +// CreateTrigger performs a previously recorded action, failing if non has been registered +func (c *MockKnEventingClient) CreateTrigger(trigger *v1alpha1.Trigger) (*v1alpha1.Trigger, error) { + call := c.recorder.r.VerifyCall("CreateTrigger", trigger) + return call.Result[0].(*v1alpha1.Trigger), mock.ErrorOrNil(call.Result[1]) +} + +// GetTrigger records a call for GetTrigger with the expected object or error. Either trigger or err should be nil +func (sr *EventingRecorder) GetTrigger(name interface{}, trigger *v1alpha1.Trigger, err error) { + sr.r.Add("GetTrigger", []interface{}{name}, []interface{}{trigger, err}) +} + +// GetTrigger performs a previously recorded action, failing if non has been registered +func (c *MockKnEventingClient) GetTrigger(name string) (*v1alpha1.Trigger, error) { + call := c.recorder.r.VerifyCall("GetTrigger", name) + return call.Result[0].(*v1alpha1.Trigger), mock.ErrorOrNil(call.Result[1]) +} + +// DeleteTrigger records a call for DeleteTrigger with the expected error (nil if none) +func (sr *EventingRecorder) DeleteTrigger(name interface{}, err error) { + sr.r.Add("DeleteTrigger", []interface{}{name}, []interface{}{err}) +} + +// DeleteTrigger performs a previously recorded action, failing if non has been registered +func (c *MockKnEventingClient) DeleteTrigger(name string) error { + call := c.recorder.r.VerifyCall("DeleteTrigger", name) + return mock.ErrorOrNil(call.Result[0]) +} + +// Validate validates whether every recorded action has been called +func (sr *EventingRecorder) Validate() { + sr.r.CheckThatAllRecordedMethodsHaveBeenCalled() +} diff --git a/pkg/eventing/v1alpha1/client_mock_test.go b/pkg/eventing/v1alpha1/client_mock_test.go new file mode 100644 index 0000000000..bfff269d6e --- /dev/null +++ b/pkg/eventing/v1alpha1/client_mock_test.go @@ -0,0 +1,41 @@ +// Copyright © 2019 The Knative Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package v1alpha1 + +import ( + "testing" + + "knative.dev/eventing/pkg/apis/eventing/v1alpha1" +) + +func TestMockKnClient(t *testing.T) { + + client := NewMockKnEventingClient(t) + + recorder := client.Recorder() + + // Record all services + recorder.GetTrigger("hello", nil, nil) + recorder.CreateTrigger(&v1alpha1.Trigger{}, nil) + recorder.DeleteTrigger("hello", nil) + + // Call all service + client.GetTrigger("hello") + client.CreateTrigger(&v1alpha1.Trigger{}) + client.DeleteTrigger("hello") + + // Validate + recorder.Validate() +} diff --git a/pkg/eventing/v1alpha1/client_test.go b/pkg/eventing/v1alpha1/client_test.go new file mode 100644 index 0000000000..00c94cc174 --- /dev/null +++ b/pkg/eventing/v1alpha1/client_test.go @@ -0,0 +1,128 @@ +// Copyright © 2019 The Knative Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package v1alpha1 + +import ( + "fmt" + "testing" + + "gotest.tools/assert" + "k8s.io/apimachinery/pkg/runtime" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + client_testing "k8s.io/client-go/testing" + "knative.dev/eventing/pkg/apis/eventing/v1alpha1" + "knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1alpha1/fake" +) + +var testNamespace = "test-ns" + +func setup() (fakeSvr fake.FakeEventingV1alpha1, client KnEventingClient) { + fakeE := fake.FakeEventingV1alpha1{Fake: &client_testing.Fake{}} + cli := NewKnEventingClient(&fakeE, testNamespace) + return fakeE, cli +} + +func TestDeleteTrigger(t *testing.T) { + var name = "new-trigger" + server, client := setup() + + server.AddReactor("delete", "triggers", + func(a client_testing.Action) (bool, runtime.Object, error) { + name := a.(client_testing.DeleteAction).GetName() + if name == "errorTrigger" { + return true, nil, fmt.Errorf("error while deleting trigger %s", name) + } + return true, nil, nil + }) + + err := client.DeleteTrigger(name) + assert.NilError(t, err) + + err = client.DeleteTrigger("errorTrigger") + assert.ErrorContains(t, err, "errorTrigger") +} + +func TestCreateTrigger(t *testing.T) { + var name = "new-trigger" + server, client := setup() + + objNew := newTrigger(name) + + server.AddReactor("create", "triggers", + func(a client_testing.Action) (bool, runtime.Object, error) { + assert.Equal(t, testNamespace, a.GetNamespace()) + name := a.(client_testing.CreateAction).GetObject().(metav1.Object).GetName() + if name == objNew.Name { + objNew.Generation = 2 + return true, objNew, nil + } + return true, nil, fmt.Errorf("error while creating trigger %s", name) + }) + + t.Run("create trigger without error", func(t *testing.T) { + ins, err := client.CreateTrigger(objNew) + assert.NilError(t, err) + assert.Equal(t, ins.Name, name) + assert.Equal(t, ins.Namespace, testNamespace) + }) + + t.Run("create trigger with an error returns an error object", func(t *testing.T) { + _, err := client.CreateTrigger(newTrigger("unknown")) + assert.ErrorContains(t, err, "unknown") + }) +} + +func TestGetTrigger(t *testing.T) { + var name = "mytrigger" + server, client := setup() + + server.AddReactor("get", "triggers", + func(a client_testing.Action) (bool, runtime.Object, error) { + name := a.(client_testing.GetAction).GetName() + if name == "errorTrigger" { + return true, nil, fmt.Errorf("error while getting trigger %s", name) + } + return true, newTrigger(name), nil + }) + + trigger, err := client.GetTrigger(name) + assert.NilError(t, err) + assert.Equal(t, trigger.Name, name) + assert.Equal(t, trigger.Spec.Broker, "default") + + _, err = client.GetTrigger("errorTrigger") + assert.ErrorContains(t, err, "errorTrigger") +} + +func newTrigger(name string) *v1alpha1.Trigger { + obj := &v1alpha1.Trigger{ + ObjectMeta: metav1.ObjectMeta{ + Name: name, + Namespace: testNamespace, + }, + Spec: v1alpha1.TriggerSpec{ + Broker: "default", + Filter: &v1alpha1.TriggerFilter{ + Attributes: &v1alpha1.TriggerFilterAttributes{ + "type": "foo", + }, + }, + }, + } + obj.Name = name + obj.Namespace = testNamespace + return obj +} diff --git a/pkg/kn/commands/testing_helper.go b/pkg/kn/commands/testing_helper.go index 3ecae773fe..528e3a0072 100644 --- a/pkg/kn/commands/testing_helper.go +++ b/pkg/kn/commands/testing_helper.go @@ -33,6 +33,8 @@ import ( dynamic_fake "k8s.io/client-go/dynamic/fake" dynamic_kn "knative.dev/client/pkg/dynamic" sources_client "knative.dev/client/pkg/eventing/sources/v1alpha1" + eventing_client "knative.dev/client/pkg/eventing/v1alpha1" + eventing_fake "knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1alpha1/fake" sources_fake "knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1/fake" ) @@ -78,6 +80,25 @@ func CreateSourcesTestKnCommand(cmd *cobra.Command, knParams *KnParams) (*cobra. return knCommand, fakeEventing, buf } +// CreateEventingTestKnCommand helper for creating test commands +func CreateEventingTestKnCommand(cmd *cobra.Command, knParams *KnParams) (*cobra.Command, *eventing_fake.FakeEventingV1alpha1, *bytes.Buffer) { + buf := new(bytes.Buffer) + // create fake serving client because the sink of source depends on serving client + fakeServing := &fake.FakeServingV1alpha1{&client_testing.Fake{}} + knParams.NewServingClient = func(namespace string) (v1alpha1.KnServingClient, error) { + return v1alpha1.NewKnServingClient(fakeServing, FakeNamespace), nil + } + // create fake sources client + fakeEventing := &eventing_fake.FakeEventingV1alpha1{&client_testing.Fake{}} + knParams.Output = buf + knParams.NewEventingClient = func(namespace string) (eventing_client.KnEventingClient, error) { + return eventing_client.NewKnEventingClient(fakeEventing, FakeNamespace), nil + } + knParams.fixedCurrentNamespace = FakeNamespace + knCommand := NewKnTestCommand(cmd, knParams) + return knCommand, fakeEventing, buf +} + // CreateDynamicTestKnCommand helper for creating test commands using dynamic client func CreateDynamicTestKnCommand(cmd *cobra.Command, knParams *KnParams, objects ...runtime.Object) (*cobra.Command, *dynamic_fake.FakeDynamicClient, *bytes.Buffer) { buf := new(bytes.Buffer) diff --git a/pkg/kn/commands/trigger/create.go b/pkg/kn/commands/trigger/create.go new file mode 100644 index 0000000000..1bf38c6590 --- /dev/null +++ b/pkg/kn/commands/trigger/create.go @@ -0,0 +1,115 @@ +// Copyright © 2019 The Knative Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package trigger + +import ( + "errors" + "fmt" + + "github.com/spf13/cobra" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "knative.dev/client/pkg/kn/commands" + "knative.dev/client/pkg/kn/commands/flags" + "knative.dev/eventing/pkg/apis/eventing/v1alpha1" + duckv1 "knative.dev/pkg/apis/duck/v1" +) + +// NewTriggerCreateCommand to create trigger create command +func NewTriggerCreateCommand(p *commands.KnParams) *cobra.Command { + var triggerUpdateFlags TriggerUpdateFlags + var sinkFlags flags.SinkFlags + + cmd := &cobra.Command{ + Use: "create NAME --broker BROKER --filter KEY=VALUE --sink SINK", + Short: "Create a trigger", + Example: ` + # Create a trigger 'mytrigger' to declare a subscription to events with attribute 'type=dev.knative.foo' from default broker. The subscriber is service 'mysvc' + kn trigger create mytrigger --broker default --filter type=dev.knative.foo --sink svc:mysvc`, + + RunE: func(cmd *cobra.Command, args []string) (err error) { + if len(args) != 1 { + return errors.New("'trigger create' requires the name of the trigger as single argument") + } + name := args[0] + + namespace, err := p.GetNamespace(cmd) + if err != nil { + return err + } + + eventingClient, err := p.NewEventingClient(namespace) + if err != nil { + return err + } + + servingClient, err := p.NewServingClient(namespace) + if err != nil { + return err + } + + objectRef, err := sinkFlags.ResolveSink(servingClient) + if err != nil { + return fmt.Errorf( + "cannot create trigger '%s' in namespace '%s' "+ + "because %s", name, namespace, err) + } + + trigger := constructTrigger(name, namespace, triggerUpdateFlags) + trigger.Spec.Subscriber = &duckv1.Destination{ + Ref: objectRef.Ref, + URI: objectRef.URI, + } + + _, err = eventingClient.CreateTrigger(trigger) + if err != nil { + return fmt.Errorf( + "cannot create trigger '%s' in namespace '%s' "+ + "because %s", name, namespace, err) + } + fmt.Fprintf(cmd.OutOrStdout(), "Trigger '%s' successfully created in namespace '%s'.\n", args[0], namespace) + return nil + }, + } + commands.AddNamespaceFlags(cmd.Flags(), false) + triggerUpdateFlags.Add(cmd) + sinkFlags.Add(cmd) + cmd.MarkFlagRequired("schedule") + + return cmd +} + +// constructTrigger is to create an instance of v1alpha1.Trigger +func constructTrigger(name string, namespace string, flags TriggerUpdateFlags) *v1alpha1.Trigger { + trigger := v1alpha1.Trigger{ + ObjectMeta: metav1.ObjectMeta{ + Name: name, + Namespace: namespace, + }, + Spec: v1alpha1.TriggerSpec{ + Broker: flags.Broker, + }, + } + + filters := flags.GetFilters() + if filters != nil { + triggerFilterAttributes := v1alpha1.TriggerFilterAttributes(filters) + trigger.Spec.Filter = &v1alpha1.TriggerFilter{ + Attributes: &triggerFilterAttributes, + } + } + + return &trigger +} diff --git a/pkg/kn/commands/trigger/create_test.go b/pkg/kn/commands/trigger/create_test.go new file mode 100644 index 0000000000..659a2688ae --- /dev/null +++ b/pkg/kn/commands/trigger/create_test.go @@ -0,0 +1,117 @@ +// Copyright © 2019 The Knative Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package trigger + +import ( + "errors" + "fmt" + "testing" + + "gotest.tools/assert" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + eventing_client "knative.dev/client/pkg/eventing/v1alpha1" + knserving_client "knative.dev/client/pkg/serving/v1alpha1" + "knative.dev/client/pkg/util" + "knative.dev/eventing/pkg/apis/eventing/v1alpha1" + duckv1 "knative.dev/pkg/apis/duck/v1" + serving_v1alpha1 "knative.dev/serving/pkg/apis/serving/v1alpha1" +) + +var ( + triggerName = "foo" +) + +func TestTriggerCreate(t *testing.T) { + eventingClient := eventing_client.NewMockKnEventingClient(t) + servingClient := knserving_client.NewMockKnServiceClient(t) + + servingRecorder := servingClient.Recorder() + servingRecorder.GetService("mysvc", &serving_v1alpha1.Service{ + TypeMeta: metav1.TypeMeta{Kind: "Service"}, + ObjectMeta: metav1.ObjectMeta{Name: "mysvc"}, + }, nil) + + eventingRecorder := eventingClient.Recorder() + eventingRecorder.CreateTrigger(createTrigger(triggerName, map[string]string{"type": "dev.knative.foo"}, "mybroker", "mysvc"), nil) + + out, err := executeTriggerCommand(eventingClient, servingClient, "create", triggerName, "--broker", "mybroker", + "--filter", "type=dev.knative.foo", "--sink", "svc:mysvc") + assert.NilError(t, err, "Trigger should be created") + util.ContainsAll(out, "Trigger", triggerName, "created", "namespace", "default") + + eventingRecorder.Validate() + servingRecorder.Validate() +} + +func TestNoSinkError(t *testing.T) { + eventingClient := eventing_client.NewMockKnEventingClient(t) + servingClient := knserving_client.NewMockKnServiceClient(t) + + errorMsg := fmt.Sprintf("cannot create trigger '%s' in namespace 'default' because no Service mysvc found", triggerName) + servingRecorder := servingClient.Recorder() + servingRecorder.GetService("mysvc", nil, errors.New("no Service mysvc found")) + + out, err := executeTriggerCommand(eventingClient, servingClient, "create", triggerName, "--broker", "mybroker", + "--filter", "type=dev.knative.foo", "--sink", "svc:mysvc") + assert.Error(t, err, errorMsg) + assert.Assert(t, util.ContainsAll(out, errorMsg, "Usage")) + servingRecorder.Validate() +} + +func TestTriggerCreateMultipleFilter(t *testing.T) { + eventingClient := eventing_client.NewMockKnEventingClient(t) + servingClient := knserving_client.NewMockKnServiceClient(t) + + servingRecorder := servingClient.Recorder() + servingRecorder.GetService("mysvc", &serving_v1alpha1.Service{ + TypeMeta: metav1.TypeMeta{Kind: "Service"}, + ObjectMeta: metav1.ObjectMeta{Name: "mysvc"}, + }, nil) + + eventingRecorder := eventingClient.Recorder() + eventingRecorder.CreateTrigger(createTrigger(triggerName, map[string]string{"type": "dev.knative.foo", "source": "event.host"}, "mybroker", "mysvc"), nil) + + out, err := executeTriggerCommand(eventingClient, servingClient, "create", triggerName, "--broker", "mybroker", + "--filter", "type=dev.knative.foo", "--filter", "source=event.host", "--sink", "svc:mysvc") + assert.NilError(t, err, "Trigger should be created") + util.ContainsAll(out, "Trigger", triggerName, "created", "namespace", "default") + + eventingRecorder.Validate() + servingRecorder.Validate() +} + +func createTrigger(name string, filters map[string]string, broker string, svcname string) *v1alpha1.Trigger { + triggerFilterAttributes := v1alpha1.TriggerFilterAttributes(filters) + wanted := &v1alpha1.Trigger{ + ObjectMeta: metav1.ObjectMeta{ + Name: name, + Namespace: "default", + }, + Spec: v1alpha1.TriggerSpec{ + Broker: broker, + Filter: &v1alpha1.TriggerFilter{ + Attributes: &triggerFilterAttributes, + }, + Subscriber: &duckv1.Destination{ + Ref: &corev1.ObjectReference{ + Name: svcname, + Kind: "Service", + }, + }, + }, + } + return wanted +} diff --git a/pkg/kn/commands/trigger/delete.go b/pkg/kn/commands/trigger/delete.go new file mode 100644 index 0000000000..1d4656892e --- /dev/null +++ b/pkg/kn/commands/trigger/delete.go @@ -0,0 +1,59 @@ +// Copyright © 2019 The Knative Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package trigger + +import ( + "errors" + "fmt" + + "github.com/spf13/cobra" + "knative.dev/client/pkg/kn/commands" +) + +// NewTriggerDeleteCommand represent 'revision delete' command +func NewTriggerDeleteCommand(p *commands.KnParams) *cobra.Command { + TriggerDeleteCommand := &cobra.Command{ + Use: "delete NAME", + Short: "Delete a trigger.", + Example: ` + # Delete a trigger 'mytrigger' in default namespace + kn trigger delete mytrigger`, + RunE: func(cmd *cobra.Command, args []string) error { + if len(args) != 1 { + return errors.New("'trigger delete' requires the name of the trigger as single argument") + } + name := args[0] + + namespace, err := p.GetNamespace(cmd) + if err != nil { + return err + } + + eventingClient, err := p.NewEventingClient(namespace) + if err != nil { + return err + } + + err = eventingClient.DeleteTrigger(name) + if err != nil { + return err + } + fmt.Fprintf(cmd.OutOrStdout(), "Trigger '%s' deleted in namespace '%s'.\n", args[0], namespace) + return nil + }, + } + commands.AddNamespaceFlags(TriggerDeleteCommand.Flags(), false) + return TriggerDeleteCommand +} diff --git a/pkg/kn/commands/trigger/delete_test.go b/pkg/kn/commands/trigger/delete_test.go new file mode 100644 index 0000000000..778a189f56 --- /dev/null +++ b/pkg/kn/commands/trigger/delete_test.go @@ -0,0 +1,53 @@ +// Copyright © 2019 The Knative Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package trigger + +import ( + "errors" + "fmt" + "testing" + + "gotest.tools/assert" + eventing_client "knative.dev/client/pkg/eventing/v1alpha1" + "knative.dev/client/pkg/util" +) + +func TestTriggerDelete(t *testing.T) { + triggerName := "trigger-12345" + + eventingClient := eventing_client.NewMockKnEventingClient(t) + eventingRecorder := eventingClient.Recorder() + eventingRecorder.DeleteTrigger(triggerName, nil) + + out, err := executeTriggerCommand(eventingClient, nil, "delete", triggerName) + assert.NilError(t, err) + util.ContainsAll(out, "deleted", "testns", triggerName) + + eventingRecorder.Validate() +} + +func TestTriggerDeleteWithError(t *testing.T) { + triggerName := "trigger-12345" + + eventingClient := eventing_client.NewMockKnEventingClient(t) + eventingRecorder := eventingClient.Recorder() + eventingRecorder.DeleteTrigger(triggerName, errors.New(fmt.Sprintf("trigger %s not found", triggerName))) + + out, err := executeTriggerCommand(eventingClient, nil, "delete", triggerName) + assert.ErrorContains(t, err, triggerName) + util.ContainsAll(out, "trigger", triggerName, "not found") + + eventingRecorder.Validate() +} diff --git a/pkg/kn/commands/trigger/describe.go b/pkg/kn/commands/trigger/describe.go new file mode 100644 index 0000000000..a838e256ad --- /dev/null +++ b/pkg/kn/commands/trigger/describe.go @@ -0,0 +1,119 @@ +// Copyright © 2019 The Knative Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package trigger + +import ( + "errors" + "fmt" + + "github.com/spf13/cobra" + + "knative.dev/client/pkg/kn/commands" + "knative.dev/client/pkg/printers" + "knative.dev/eventing/pkg/apis/eventing/v1alpha1" + duckv1 "knative.dev/pkg/apis/duck/v1" +) + +// NewTriggerDescribeCommand returns a new command for describe a trigger +func NewTriggerDescribeCommand(p *commands.KnParams) *cobra.Command { + + triggerDescribe := &cobra.Command{ + Use: "describe NAME", + Short: "Describe a trigger.", + Example: ` + # Describe a trigger with name 'my-trigger' + kn trigger describe my-trigger`, + RunE: func(cmd *cobra.Command, args []string) error { + if len(args) != 1 { + return errors.New("'trigger describe' requires the name of the trigger as single argument") + } + name := args[0] + + // get namespace + namespace, err := p.GetNamespace(cmd) + if err != nil { + return err + } + + // get client + eventingClient, err := p.NewEventingClient(namespace) + if err != nil { + return err + } + + trigger, err := eventingClient.GetTrigger(name) + if err != nil { + return err + } + + out := cmd.OutOrStdout() + dw := printers.NewPrefixWriter(out) + + printDetails, err := cmd.Flags().GetBool("verbose") + if err != nil { + return err + } + + writeTrigger(dw, trigger, printDetails) + dw.WriteLine() + if err := dw.Flush(); err != nil { + return err + } + + // Revisions summary info + writeSink(dw, trigger.Spec.Subscriber) + dw.WriteLine() + if err := dw.Flush(); err != nil { + return err + } + + // Condition info + commands.WriteConditions(dw, trigger.Status.Conditions, printDetails) + if err := dw.Flush(); err != nil { + return err + } + + return nil + }, + } + flags := triggerDescribe.Flags() + commands.AddNamespaceFlags(flags, false) + flags.BoolP("verbose", "v", false, "More output.") + + return triggerDescribe +} + +func writeSink(dw printers.PrefixWriter, sink *duckv1.Destination) { + subWriter := dw.WriteAttribute("Sink", "") + subWriter.WriteAttribute("Name", sink.Ref.Name) + subWriter.WriteAttribute("Namespace", sink.Ref.Namespace) + ref := sink.Ref + if ref != nil { + subWriter.WriteAttribute("Resource", fmt.Sprintf("%s (%s)", sink.Ref.Kind, sink.Ref.APIVersion)) + } + uri := sink.URI + if uri != nil { + subWriter.WriteAttribute("URI", uri.String()) + } +} + +func writeTrigger(dw printers.PrefixWriter, trigger *v1alpha1.Trigger, printDetails bool) { + commands.WriteMetadata(dw, &trigger.ObjectMeta, printDetails) + dw.WriteAttribute("Broker", trigger.Spec.Broker) + subWriter := dw.WriteAttribute("Filter", "") + for key, value := range *trigger.Spec.Filter.Attributes { + subWriter.WriteAttribute(key, value) + } +} diff --git a/pkg/kn/commands/trigger/describe_test.go b/pkg/kn/commands/trigger/describe_test.go new file mode 100644 index 0000000000..cab7813b5c --- /dev/null +++ b/pkg/kn/commands/trigger/describe_test.go @@ -0,0 +1,89 @@ +// Copyright © 2019 The Knative Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package trigger + +import ( + "errors" + "testing" + + "gotest.tools/assert" + "gotest.tools/assert/cmp" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + client_v1alpha1 "knative.dev/client/pkg/eventing/v1alpha1" + "knative.dev/client/pkg/util" + v1alpha1 "knative.dev/eventing/pkg/apis/eventing/v1alpha1" + duckv1 "knative.dev/pkg/apis/duck/v1" +) + +func TestSimpleDescribe(t *testing.T) { + client := client_v1alpha1.NewMockKnEventingClient(t, "mynamespace") + + recorder := client.Recorder() + recorder.GetTrigger("testtrigger", getTrigger(), nil) + + out, err := executeTriggerCommand(client, nil, "describe", "testtrigger") + assert.NilError(t, err) + + assert.Assert(t, cmp.Regexp("Name:\\s+testtrigger", out)) + assert.Assert(t, cmp.Regexp("Namespace:\\s+default", out)) + + assert.Assert(t, util.ContainsAll(out, "Broker:", "mybroker")) + assert.Assert(t, util.ContainsAll(out, "Filter:", "type", "foo.type.knative", "source", "src.eventing.knative")) + assert.Assert(t, util.ContainsAll(out, "Sink:", "Service", "myservicenamespace", "mysvc")) + + // Validate that all recorded API methods have been called + recorder.Validate() +} + +func TestDescribeError(t *testing.T) { + client := client_v1alpha1.NewMockKnEventingClient(t, "mynamespace") + + recorder := client.Recorder() + recorder.GetTrigger("testtrigger", nil, errors.New("triggers.eventing.knative.dev 'testtrigger' not found")) + + _, err := executeTriggerCommand(client, nil, "describe", "testtrigger") + assert.ErrorContains(t, err, "testtrigger", "not found") + + recorder.Validate() +} + +func getTrigger() *v1alpha1.Trigger { + return &v1alpha1.Trigger{ + TypeMeta: v1.TypeMeta{}, + ObjectMeta: metav1.ObjectMeta{ + Name: "testtrigger", + Namespace: "default", + }, + Spec: v1alpha1.TriggerSpec{ + Broker: "mybroker", + Filter: &v1alpha1.TriggerFilter{ + Attributes: &v1alpha1.TriggerFilterAttributes{ + "type": "foo.type.knative", + "source": "src.eventing.knative", + }, + }, + Subscriber: &duckv1.Destination{ + Ref: &corev1.ObjectReference{ + Kind: "Service", + Namespace: "myservicenamespace", + Name: "mysvc", + }, + }, + }, + Status: v1alpha1.TriggerStatus{}, + } +} diff --git a/pkg/kn/commands/trigger/flag.go b/pkg/kn/commands/trigger/flag.go new file mode 100644 index 0000000000..be3b601223 --- /dev/null +++ b/pkg/kn/commands/trigger/flag.go @@ -0,0 +1,67 @@ +// Copyright © 2019 The Knative Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package trigger + +import ( + "fmt" + "strings" + + "github.com/spf13/cobra" +) + +type filterArray []string + +func (filters *filterArray) String() string { + str := "" + for _, filter := range *filters { + str = str + filter + " " + } + return str +} + +func (filters *filterArray) Set(value string) error { + *filters = append(*filters, value) + return nil +} + +func (filters *filterArray) Type() string { + return "[]string" +} + +// TriggerUpdateFlags are flags for create and update a trigger +type TriggerUpdateFlags struct { + Broker string + Filters filterArray +} + +// GetFilter to return a map type of filters +func (f *TriggerUpdateFlags) GetFilters() map[string]string { + filters := map[string]string{} + for _, item := range f.Filters { + parts := strings.Split(item, "=") + if len(parts) == 2 { + filters[parts[0]] = parts[1] + } else { + fmt.Printf("Ignore invalid filter %s", f) + } + } + return filters +} + +//Add is to set parameters +func (f *TriggerUpdateFlags) Add(cmd *cobra.Command) { + cmd.Flags().StringVar(&f.Broker, "broker", "default", "Name of the Broker which the trigger associates with.") + cmd.Flags().Var(&f.Filters, "filter", "Key-value pair for exact CloudEvent attribute matching against incoming events, e.g type=dev.knative.foo") +} diff --git a/pkg/kn/commands/trigger/flag_test.go b/pkg/kn/commands/trigger/flag_test.go new file mode 100644 index 0000000000..e82ff6fe27 --- /dev/null +++ b/pkg/kn/commands/trigger/flag_test.go @@ -0,0 +1,35 @@ +// Copyright © 2019 The Knative Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package trigger + +import ( + "testing" + + "gotest.tools/assert" +) + +func TestGetFilter(t *testing.T) { + t.Run("get multiple filters", func(t *testing.T) { + createFlag := TriggerUpdateFlags{ + Filters: filterArray{"type=abc.edf.ghi", "attr=value"}, + } + created := createFlag.GetFilters() + wanted := map[string]string{ + "type": "abc.edf.ghi", + "attr": "value", + } + assert.DeepEqual(t, wanted, created) + }) +} diff --git a/pkg/kn/commands/trigger/trigger.go b/pkg/kn/commands/trigger/trigger.go new file mode 100644 index 0000000000..22bba08649 --- /dev/null +++ b/pkg/kn/commands/trigger/trigger.go @@ -0,0 +1,33 @@ +// Copyright © 2019 The Knative Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package trigger + +import ( + "github.com/spf13/cobra" + + "knative.dev/client/pkg/kn/commands" +) + +// NewTriggerCommand to create trigger command group +func NewTriggerCommand(p *commands.KnParams) *cobra.Command { + triggerCmd := &cobra.Command{ + Use: "trigger", + Short: "Trigger command group", + } + triggerCmd.AddCommand(NewTriggerCreateCommand(p)) + triggerCmd.AddCommand(NewTriggerDeleteCommand(p)) + triggerCmd.AddCommand(NewTriggerDescribeCommand(p)) + return triggerCmd +} diff --git a/pkg/kn/commands/trigger/trigger_test.go b/pkg/kn/commands/trigger/trigger_test.go new file mode 100644 index 0000000000..6640ca0a62 --- /dev/null +++ b/pkg/kn/commands/trigger/trigger_test.go @@ -0,0 +1,72 @@ +// Copyright © 2019 The Knative Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package trigger + +import ( + "bytes" + + "k8s.io/client-go/tools/clientcmd" + + eventc_v1alpha1 "knative.dev/client/pkg/eventing/v1alpha1" + "knative.dev/client/pkg/kn/commands" + serving_client_v1alpha1 "knative.dev/client/pkg/serving/v1alpha1" +) + +// Helper methods +var blankConfig clientcmd.ClientConfig + +func init() { + var err error + blankConfig, err = clientcmd.NewClientConfigFromBytes([]byte(`kind: Config +version: v1 +users: +- name: u +clusters: +- name: c + cluster: + server: example.com +contexts: +- name: x + context: + user: u + cluster: c +current-context: x +`)) + if err != nil { + panic(err) + } +} + +func executeTriggerCommand(triggerClient eventc_v1alpha1.KnEventingClient, servingClient serving_client_v1alpha1.KnServingClient, args ...string) (string, error) { + knParams := &commands.KnParams{} + knParams.ClientConfig = blankConfig + + output := new(bytes.Buffer) + knParams.Output = output + knParams.NewServingClient = func(namespace string) (serving_client_v1alpha1.KnServingClient, error) { + return servingClient, nil + } + knParams.NewEventingClient = func(namespace string) (eventc_v1alpha1.KnEventingClient, error) { + return triggerClient, nil + } + + cmd := NewTriggerCommand(knParams) + cmd.SetArgs(args) + cmd.SetOutput(output) + + err := cmd.Execute() + + return output.String(), err +} diff --git a/pkg/kn/commands/types.go b/pkg/kn/commands/types.go index 748d80d026..1729ad6a30 100644 --- a/pkg/kn/commands/types.go +++ b/pkg/kn/commands/types.go @@ -24,11 +24,13 @@ import ( "k8s.io/client-go/rest" "k8s.io/client-go/tools/clientcmd" "knative.dev/client/pkg/util" + eventing "knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1alpha1" eventing_sources "knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1" serving_v1alpha1_client "knative.dev/serving/pkg/client/clientset/versioned/typed/serving/v1alpha1" dynamic_kn "knative.dev/client/pkg/dynamic" sources_kn_v1alpha1 "knative.dev/client/pkg/eventing/sources/v1alpha1" + eventing_kn_v1alpha1 "knative.dev/client/pkg/eventing/v1alpha1" serving_kn_v1alpha1 "knative.dev/client/pkg/serving/v1alpha1" ) @@ -46,12 +48,13 @@ type Config struct { // KnParams for creating commands. Useful for inserting mocks for testing. type KnParams struct { - Output io.Writer - KubeCfgPath string - ClientConfig clientcmd.ClientConfig - NewServingClient func(namespace string) (serving_kn_v1alpha1.KnServingClient, error) - NewSourcesClient func(namespace string) (sources_kn_v1alpha1.KnSourcesClient, error) - NewDynamicClient func(namespace string) (dynamic_kn.KnDynamicClient, error) + Output io.Writer + KubeCfgPath string + ClientConfig clientcmd.ClientConfig + NewServingClient func(namespace string) (serving_kn_v1alpha1.KnServingClient, error) + NewSourcesClient func(namespace string) (sources_kn_v1alpha1.KnSourcesClient, error) + NewEventingClient func(namespace string) (eventing_kn_v1alpha1.KnEventingClient, error) + NewDynamicClient func(namespace string) (dynamic_kn.KnDynamicClient, error) // General global options LogHTTP bool @@ -69,6 +72,10 @@ func (params *KnParams) Initialize() { params.NewSourcesClient = params.newSourcesClient } + if params.NewEventingClient == nil { + params.NewEventingClient = params.newEventingClient + } + if params.NewDynamicClient == nil { params.NewDynamicClient = params.newDynamicClient } @@ -94,6 +101,16 @@ func (params *KnParams) newSourcesClient(namespace string) (sources_kn_v1alpha1. return sources_kn_v1alpha1.NewKnSourcesClient(client, namespace), nil } +func (params *KnParams) newEventingClient(namespace string) (eventing_kn_v1alpha1.KnEventingClient, error) { + restConfig, err := params.RestConfig() + if err != nil { + return nil, err + } + + client, _ := eventing.NewForConfig(restConfig) + return eventing_kn_v1alpha1.NewKnEventingClient(client, namespace), nil +} + func (params *KnParams) newDynamicClient(namespace string) (dynamic_kn.KnDynamicClient, error) { restConfig, err := params.RestConfig() if err != nil { diff --git a/pkg/kn/core/root.go b/pkg/kn/core/root.go index 6f1d040e44..cec1ec3b90 100644 --- a/pkg/kn/core/root.go +++ b/pkg/kn/core/root.go @@ -36,6 +36,7 @@ import ( "knative.dev/client/pkg/kn/commands/route" "knative.dev/client/pkg/kn/commands/service" "knative.dev/client/pkg/kn/commands/source" + "knative.dev/client/pkg/kn/commands/trigger" "knative.dev/client/pkg/kn/commands/version" "knative.dev/client/pkg/kn/flags" ) @@ -144,6 +145,7 @@ func NewKnCommand(params ...commands.KnParams) *cobra.Command { rootCmd.AddCommand(completion.NewCompletionCommand(p)) rootCmd.AddCommand(version.NewVersionCommand(p)) rootCmd.AddCommand(source.NewSourceCommand(p)) + rootCmd.AddCommand(trigger.NewTriggerCommand(p)) // Deal with empty and unknown sub command groups EmptyAndUnknownSubCommands(rootCmd) diff --git a/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1alpha1/broker.go b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1alpha1/broker.go new file mode 100644 index 0000000000..292f384f87 --- /dev/null +++ b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1alpha1/broker.go @@ -0,0 +1,191 @@ +/* +Copyright 2019 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "time" + + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" + v1alpha1 "knative.dev/eventing/pkg/apis/eventing/v1alpha1" + scheme "knative.dev/eventing/pkg/client/clientset/versioned/scheme" +) + +// BrokersGetter has a method to return a BrokerInterface. +// A group's client should implement this interface. +type BrokersGetter interface { + Brokers(namespace string) BrokerInterface +} + +// BrokerInterface has methods to work with Broker resources. +type BrokerInterface interface { + Create(*v1alpha1.Broker) (*v1alpha1.Broker, error) + Update(*v1alpha1.Broker) (*v1alpha1.Broker, error) + UpdateStatus(*v1alpha1.Broker) (*v1alpha1.Broker, error) + Delete(name string, options *v1.DeleteOptions) error + DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error + Get(name string, options v1.GetOptions) (*v1alpha1.Broker, error) + List(opts v1.ListOptions) (*v1alpha1.BrokerList, error) + Watch(opts v1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.Broker, err error) + BrokerExpansion +} + +// brokers implements BrokerInterface +type brokers struct { + client rest.Interface + ns string +} + +// newBrokers returns a Brokers +func newBrokers(c *EventingV1alpha1Client, namespace string) *brokers { + return &brokers{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the broker, and returns the corresponding broker object, and an error if there is any. +func (c *brokers) Get(name string, options v1.GetOptions) (result *v1alpha1.Broker, err error) { + result = &v1alpha1.Broker{} + err = c.client.Get(). + Namespace(c.ns). + Resource("brokers"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of Brokers that match those selectors. +func (c *brokers) List(opts v1.ListOptions) (result *v1alpha1.BrokerList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.BrokerList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("brokers"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested brokers. +func (c *brokers) Watch(opts v1.ListOptions) (watch.Interface, error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("brokers"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch() +} + +// Create takes the representation of a broker and creates it. Returns the server's representation of the broker, and an error, if there is any. +func (c *brokers) Create(broker *v1alpha1.Broker) (result *v1alpha1.Broker, err error) { + result = &v1alpha1.Broker{} + err = c.client.Post(). + Namespace(c.ns). + Resource("brokers"). + Body(broker). + Do(). + Into(result) + return +} + +// Update takes the representation of a broker and updates it. Returns the server's representation of the broker, and an error, if there is any. +func (c *brokers) Update(broker *v1alpha1.Broker) (result *v1alpha1.Broker, err error) { + result = &v1alpha1.Broker{} + err = c.client.Put(). + Namespace(c.ns). + Resource("brokers"). + Name(broker.Name). + Body(broker). + Do(). + Into(result) + return +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). + +func (c *brokers) UpdateStatus(broker *v1alpha1.Broker) (result *v1alpha1.Broker, err error) { + result = &v1alpha1.Broker{} + err = c.client.Put(). + Namespace(c.ns). + Resource("brokers"). + Name(broker.Name). + SubResource("status"). + Body(broker). + Do(). + Into(result) + return +} + +// Delete takes name of the broker and deletes it. Returns an error if one occurs. +func (c *brokers) Delete(name string, options *v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("brokers"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *brokers) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + var timeout time.Duration + if listOptions.TimeoutSeconds != nil { + timeout = time.Duration(*listOptions.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Namespace(c.ns). + Resource("brokers"). + VersionedParams(&listOptions, scheme.ParameterCodec). + Timeout(timeout). + Body(options). + Do(). + Error() +} + +// Patch applies the patch and returns the patched broker. +func (c *brokers) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.Broker, err error) { + result = &v1alpha1.Broker{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("brokers"). + SubResource(subresources...). + Name(name). + Body(data). + Do(). + Into(result) + return +} diff --git a/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1alpha1/doc.go b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1alpha1/doc.go new file mode 100644 index 0000000000..a1c6bb9fe8 --- /dev/null +++ b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1alpha1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2019 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package v1alpha1 diff --git a/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1alpha1/eventing_client.go b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1alpha1/eventing_client.go new file mode 100644 index 0000000000..4c52ead987 --- /dev/null +++ b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1alpha1/eventing_client.go @@ -0,0 +1,99 @@ +/* +Copyright 2019 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + rest "k8s.io/client-go/rest" + v1alpha1 "knative.dev/eventing/pkg/apis/eventing/v1alpha1" + "knative.dev/eventing/pkg/client/clientset/versioned/scheme" +) + +type EventingV1alpha1Interface interface { + RESTClient() rest.Interface + BrokersGetter + EventTypesGetter + TriggersGetter +} + +// EventingV1alpha1Client is used to interact with features provided by the eventing.knative.dev group. +type EventingV1alpha1Client struct { + restClient rest.Interface +} + +func (c *EventingV1alpha1Client) Brokers(namespace string) BrokerInterface { + return newBrokers(c, namespace) +} + +func (c *EventingV1alpha1Client) EventTypes(namespace string) EventTypeInterface { + return newEventTypes(c, namespace) +} + +func (c *EventingV1alpha1Client) Triggers(namespace string) TriggerInterface { + return newTriggers(c, namespace) +} + +// NewForConfig creates a new EventingV1alpha1Client for the given config. +func NewForConfig(c *rest.Config) (*EventingV1alpha1Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientFor(&config) + if err != nil { + return nil, err + } + return &EventingV1alpha1Client{client}, nil +} + +// NewForConfigOrDie creates a new EventingV1alpha1Client for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *EventingV1alpha1Client { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new EventingV1alpha1Client for the given RESTClient. +func New(c rest.Interface) *EventingV1alpha1Client { + return &EventingV1alpha1Client{c} +} + +func setConfigDefaults(config *rest.Config) error { + gv := v1alpha1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = scheme.Codecs.WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } + + return nil +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *EventingV1alpha1Client) RESTClient() rest.Interface { + if c == nil { + return nil + } + return c.restClient +} diff --git a/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1alpha1/eventtype.go b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1alpha1/eventtype.go new file mode 100644 index 0000000000..391474f299 --- /dev/null +++ b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1alpha1/eventtype.go @@ -0,0 +1,191 @@ +/* +Copyright 2019 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "time" + + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" + v1alpha1 "knative.dev/eventing/pkg/apis/eventing/v1alpha1" + scheme "knative.dev/eventing/pkg/client/clientset/versioned/scheme" +) + +// EventTypesGetter has a method to return a EventTypeInterface. +// A group's client should implement this interface. +type EventTypesGetter interface { + EventTypes(namespace string) EventTypeInterface +} + +// EventTypeInterface has methods to work with EventType resources. +type EventTypeInterface interface { + Create(*v1alpha1.EventType) (*v1alpha1.EventType, error) + Update(*v1alpha1.EventType) (*v1alpha1.EventType, error) + UpdateStatus(*v1alpha1.EventType) (*v1alpha1.EventType, error) + Delete(name string, options *v1.DeleteOptions) error + DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error + Get(name string, options v1.GetOptions) (*v1alpha1.EventType, error) + List(opts v1.ListOptions) (*v1alpha1.EventTypeList, error) + Watch(opts v1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.EventType, err error) + EventTypeExpansion +} + +// eventTypes implements EventTypeInterface +type eventTypes struct { + client rest.Interface + ns string +} + +// newEventTypes returns a EventTypes +func newEventTypes(c *EventingV1alpha1Client, namespace string) *eventTypes { + return &eventTypes{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the eventType, and returns the corresponding eventType object, and an error if there is any. +func (c *eventTypes) Get(name string, options v1.GetOptions) (result *v1alpha1.EventType, err error) { + result = &v1alpha1.EventType{} + err = c.client.Get(). + Namespace(c.ns). + Resource("eventtypes"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of EventTypes that match those selectors. +func (c *eventTypes) List(opts v1.ListOptions) (result *v1alpha1.EventTypeList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.EventTypeList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("eventtypes"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested eventTypes. +func (c *eventTypes) Watch(opts v1.ListOptions) (watch.Interface, error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("eventtypes"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch() +} + +// Create takes the representation of a eventType and creates it. Returns the server's representation of the eventType, and an error, if there is any. +func (c *eventTypes) Create(eventType *v1alpha1.EventType) (result *v1alpha1.EventType, err error) { + result = &v1alpha1.EventType{} + err = c.client.Post(). + Namespace(c.ns). + Resource("eventtypes"). + Body(eventType). + Do(). + Into(result) + return +} + +// Update takes the representation of a eventType and updates it. Returns the server's representation of the eventType, and an error, if there is any. +func (c *eventTypes) Update(eventType *v1alpha1.EventType) (result *v1alpha1.EventType, err error) { + result = &v1alpha1.EventType{} + err = c.client.Put(). + Namespace(c.ns). + Resource("eventtypes"). + Name(eventType.Name). + Body(eventType). + Do(). + Into(result) + return +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). + +func (c *eventTypes) UpdateStatus(eventType *v1alpha1.EventType) (result *v1alpha1.EventType, err error) { + result = &v1alpha1.EventType{} + err = c.client.Put(). + Namespace(c.ns). + Resource("eventtypes"). + Name(eventType.Name). + SubResource("status"). + Body(eventType). + Do(). + Into(result) + return +} + +// Delete takes name of the eventType and deletes it. Returns an error if one occurs. +func (c *eventTypes) Delete(name string, options *v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("eventtypes"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *eventTypes) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + var timeout time.Duration + if listOptions.TimeoutSeconds != nil { + timeout = time.Duration(*listOptions.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Namespace(c.ns). + Resource("eventtypes"). + VersionedParams(&listOptions, scheme.ParameterCodec). + Timeout(timeout). + Body(options). + Do(). + Error() +} + +// Patch applies the patch and returns the patched eventType. +func (c *eventTypes) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.EventType, err error) { + result = &v1alpha1.EventType{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("eventtypes"). + SubResource(subresources...). + Name(name). + Body(data). + Do(). + Into(result) + return +} diff --git a/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1alpha1/fake/doc.go b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1alpha1/fake/doc.go new file mode 100644 index 0000000000..a00e5d7b21 --- /dev/null +++ b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1alpha1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2019 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +// Package fake has the automatically generated clients. +package fake diff --git a/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1alpha1/fake/fake_broker.go b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1alpha1/fake/fake_broker.go new file mode 100644 index 0000000000..2da6854673 --- /dev/null +++ b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1alpha1/fake/fake_broker.go @@ -0,0 +1,140 @@ +/* +Copyright 2019 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + schema "k8s.io/apimachinery/pkg/runtime/schema" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" + v1alpha1 "knative.dev/eventing/pkg/apis/eventing/v1alpha1" +) + +// FakeBrokers implements BrokerInterface +type FakeBrokers struct { + Fake *FakeEventingV1alpha1 + ns string +} + +var brokersResource = schema.GroupVersionResource{Group: "eventing.knative.dev", Version: "v1alpha1", Resource: "brokers"} + +var brokersKind = schema.GroupVersionKind{Group: "eventing.knative.dev", Version: "v1alpha1", Kind: "Broker"} + +// Get takes name of the broker, and returns the corresponding broker object, and an error if there is any. +func (c *FakeBrokers) Get(name string, options v1.GetOptions) (result *v1alpha1.Broker, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(brokersResource, c.ns, name), &v1alpha1.Broker{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Broker), err +} + +// List takes label and field selectors, and returns the list of Brokers that match those selectors. +func (c *FakeBrokers) List(opts v1.ListOptions) (result *v1alpha1.BrokerList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(brokersResource, brokersKind, c.ns, opts), &v1alpha1.BrokerList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.BrokerList{ListMeta: obj.(*v1alpha1.BrokerList).ListMeta} + for _, item := range obj.(*v1alpha1.BrokerList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested brokers. +func (c *FakeBrokers) Watch(opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(brokersResource, c.ns, opts)) + +} + +// Create takes the representation of a broker and creates it. Returns the server's representation of the broker, and an error, if there is any. +func (c *FakeBrokers) Create(broker *v1alpha1.Broker) (result *v1alpha1.Broker, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(brokersResource, c.ns, broker), &v1alpha1.Broker{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Broker), err +} + +// Update takes the representation of a broker and updates it. Returns the server's representation of the broker, and an error, if there is any. +func (c *FakeBrokers) Update(broker *v1alpha1.Broker) (result *v1alpha1.Broker, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(brokersResource, c.ns, broker), &v1alpha1.Broker{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Broker), err +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *FakeBrokers) UpdateStatus(broker *v1alpha1.Broker) (*v1alpha1.Broker, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(brokersResource, "status", c.ns, broker), &v1alpha1.Broker{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Broker), err +} + +// Delete takes name of the broker and deletes it. Returns an error if one occurs. +func (c *FakeBrokers) Delete(name string, options *v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(brokersResource, c.ns, name), &v1alpha1.Broker{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeBrokers) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(brokersResource, c.ns, listOptions) + + _, err := c.Fake.Invokes(action, &v1alpha1.BrokerList{}) + return err +} + +// Patch applies the patch and returns the patched broker. +func (c *FakeBrokers) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.Broker, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(brokersResource, c.ns, name, pt, data, subresources...), &v1alpha1.Broker{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Broker), err +} diff --git a/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1alpha1/fake/fake_eventing_client.go b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1alpha1/fake/fake_eventing_client.go new file mode 100644 index 0000000000..4e11aec55e --- /dev/null +++ b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1alpha1/fake/fake_eventing_client.go @@ -0,0 +1,48 @@ +/* +Copyright 2019 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + rest "k8s.io/client-go/rest" + testing "k8s.io/client-go/testing" + v1alpha1 "knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1alpha1" +) + +type FakeEventingV1alpha1 struct { + *testing.Fake +} + +func (c *FakeEventingV1alpha1) Brokers(namespace string) v1alpha1.BrokerInterface { + return &FakeBrokers{c, namespace} +} + +func (c *FakeEventingV1alpha1) EventTypes(namespace string) v1alpha1.EventTypeInterface { + return &FakeEventTypes{c, namespace} +} + +func (c *FakeEventingV1alpha1) Triggers(namespace string) v1alpha1.TriggerInterface { + return &FakeTriggers{c, namespace} +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FakeEventingV1alpha1) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret +} diff --git a/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1alpha1/fake/fake_eventtype.go b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1alpha1/fake/fake_eventtype.go new file mode 100644 index 0000000000..81c4fd618d --- /dev/null +++ b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1alpha1/fake/fake_eventtype.go @@ -0,0 +1,140 @@ +/* +Copyright 2019 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + schema "k8s.io/apimachinery/pkg/runtime/schema" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" + v1alpha1 "knative.dev/eventing/pkg/apis/eventing/v1alpha1" +) + +// FakeEventTypes implements EventTypeInterface +type FakeEventTypes struct { + Fake *FakeEventingV1alpha1 + ns string +} + +var eventtypesResource = schema.GroupVersionResource{Group: "eventing.knative.dev", Version: "v1alpha1", Resource: "eventtypes"} + +var eventtypesKind = schema.GroupVersionKind{Group: "eventing.knative.dev", Version: "v1alpha1", Kind: "EventType"} + +// Get takes name of the eventType, and returns the corresponding eventType object, and an error if there is any. +func (c *FakeEventTypes) Get(name string, options v1.GetOptions) (result *v1alpha1.EventType, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(eventtypesResource, c.ns, name), &v1alpha1.EventType{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.EventType), err +} + +// List takes label and field selectors, and returns the list of EventTypes that match those selectors. +func (c *FakeEventTypes) List(opts v1.ListOptions) (result *v1alpha1.EventTypeList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(eventtypesResource, eventtypesKind, c.ns, opts), &v1alpha1.EventTypeList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.EventTypeList{ListMeta: obj.(*v1alpha1.EventTypeList).ListMeta} + for _, item := range obj.(*v1alpha1.EventTypeList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested eventTypes. +func (c *FakeEventTypes) Watch(opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(eventtypesResource, c.ns, opts)) + +} + +// Create takes the representation of a eventType and creates it. Returns the server's representation of the eventType, and an error, if there is any. +func (c *FakeEventTypes) Create(eventType *v1alpha1.EventType) (result *v1alpha1.EventType, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(eventtypesResource, c.ns, eventType), &v1alpha1.EventType{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.EventType), err +} + +// Update takes the representation of a eventType and updates it. Returns the server's representation of the eventType, and an error, if there is any. +func (c *FakeEventTypes) Update(eventType *v1alpha1.EventType) (result *v1alpha1.EventType, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(eventtypesResource, c.ns, eventType), &v1alpha1.EventType{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.EventType), err +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *FakeEventTypes) UpdateStatus(eventType *v1alpha1.EventType) (*v1alpha1.EventType, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(eventtypesResource, "status", c.ns, eventType), &v1alpha1.EventType{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.EventType), err +} + +// Delete takes name of the eventType and deletes it. Returns an error if one occurs. +func (c *FakeEventTypes) Delete(name string, options *v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(eventtypesResource, c.ns, name), &v1alpha1.EventType{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeEventTypes) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(eventtypesResource, c.ns, listOptions) + + _, err := c.Fake.Invokes(action, &v1alpha1.EventTypeList{}) + return err +} + +// Patch applies the patch and returns the patched eventType. +func (c *FakeEventTypes) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.EventType, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(eventtypesResource, c.ns, name, pt, data, subresources...), &v1alpha1.EventType{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.EventType), err +} diff --git a/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1alpha1/fake/fake_trigger.go b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1alpha1/fake/fake_trigger.go new file mode 100644 index 0000000000..19682083b2 --- /dev/null +++ b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1alpha1/fake/fake_trigger.go @@ -0,0 +1,140 @@ +/* +Copyright 2019 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + schema "k8s.io/apimachinery/pkg/runtime/schema" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" + v1alpha1 "knative.dev/eventing/pkg/apis/eventing/v1alpha1" +) + +// FakeTriggers implements TriggerInterface +type FakeTriggers struct { + Fake *FakeEventingV1alpha1 + ns string +} + +var triggersResource = schema.GroupVersionResource{Group: "eventing.knative.dev", Version: "v1alpha1", Resource: "triggers"} + +var triggersKind = schema.GroupVersionKind{Group: "eventing.knative.dev", Version: "v1alpha1", Kind: "Trigger"} + +// Get takes name of the trigger, and returns the corresponding trigger object, and an error if there is any. +func (c *FakeTriggers) Get(name string, options v1.GetOptions) (result *v1alpha1.Trigger, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(triggersResource, c.ns, name), &v1alpha1.Trigger{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Trigger), err +} + +// List takes label and field selectors, and returns the list of Triggers that match those selectors. +func (c *FakeTriggers) List(opts v1.ListOptions) (result *v1alpha1.TriggerList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(triggersResource, triggersKind, c.ns, opts), &v1alpha1.TriggerList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha1.TriggerList{ListMeta: obj.(*v1alpha1.TriggerList).ListMeta} + for _, item := range obj.(*v1alpha1.TriggerList).Items { + if label.Matches(labels.Set(item.Labels)) { + list.Items = append(list.Items, item) + } + } + return list, err +} + +// Watch returns a watch.Interface that watches the requested triggers. +func (c *FakeTriggers) Watch(opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(triggersResource, c.ns, opts)) + +} + +// Create takes the representation of a trigger and creates it. Returns the server's representation of the trigger, and an error, if there is any. +func (c *FakeTriggers) Create(trigger *v1alpha1.Trigger) (result *v1alpha1.Trigger, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(triggersResource, c.ns, trigger), &v1alpha1.Trigger{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Trigger), err +} + +// Update takes the representation of a trigger and updates it. Returns the server's representation of the trigger, and an error, if there is any. +func (c *FakeTriggers) Update(trigger *v1alpha1.Trigger) (result *v1alpha1.Trigger, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(triggersResource, c.ns, trigger), &v1alpha1.Trigger{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Trigger), err +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). +func (c *FakeTriggers) UpdateStatus(trigger *v1alpha1.Trigger) (*v1alpha1.Trigger, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(triggersResource, "status", c.ns, trigger), &v1alpha1.Trigger{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Trigger), err +} + +// Delete takes name of the trigger and deletes it. Returns an error if one occurs. +func (c *FakeTriggers) Delete(name string, options *v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(triggersResource, c.ns, name), &v1alpha1.Trigger{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeTriggers) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(triggersResource, c.ns, listOptions) + + _, err := c.Fake.Invokes(action, &v1alpha1.TriggerList{}) + return err +} + +// Patch applies the patch and returns the patched trigger. +func (c *FakeTriggers) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.Trigger, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(triggersResource, c.ns, name, pt, data, subresources...), &v1alpha1.Trigger{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha1.Trigger), err +} diff --git a/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1alpha1/generated_expansion.go b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1alpha1/generated_expansion.go new file mode 100644 index 0000000000..f31f68a6b2 --- /dev/null +++ b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1alpha1/generated_expansion.go @@ -0,0 +1,25 @@ +/* +Copyright 2019 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +type BrokerExpansion interface{} + +type EventTypeExpansion interface{} + +type TriggerExpansion interface{} diff --git a/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1alpha1/trigger.go b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1alpha1/trigger.go new file mode 100644 index 0000000000..65b68f11b1 --- /dev/null +++ b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1alpha1/trigger.go @@ -0,0 +1,191 @@ +/* +Copyright 2019 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + "time" + + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + rest "k8s.io/client-go/rest" + v1alpha1 "knative.dev/eventing/pkg/apis/eventing/v1alpha1" + scheme "knative.dev/eventing/pkg/client/clientset/versioned/scheme" +) + +// TriggersGetter has a method to return a TriggerInterface. +// A group's client should implement this interface. +type TriggersGetter interface { + Triggers(namespace string) TriggerInterface +} + +// TriggerInterface has methods to work with Trigger resources. +type TriggerInterface interface { + Create(*v1alpha1.Trigger) (*v1alpha1.Trigger, error) + Update(*v1alpha1.Trigger) (*v1alpha1.Trigger, error) + UpdateStatus(*v1alpha1.Trigger) (*v1alpha1.Trigger, error) + Delete(name string, options *v1.DeleteOptions) error + DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error + Get(name string, options v1.GetOptions) (*v1alpha1.Trigger, error) + List(opts v1.ListOptions) (*v1alpha1.TriggerList, error) + Watch(opts v1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.Trigger, err error) + TriggerExpansion +} + +// triggers implements TriggerInterface +type triggers struct { + client rest.Interface + ns string +} + +// newTriggers returns a Triggers +func newTriggers(c *EventingV1alpha1Client, namespace string) *triggers { + return &triggers{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the trigger, and returns the corresponding trigger object, and an error if there is any. +func (c *triggers) Get(name string, options v1.GetOptions) (result *v1alpha1.Trigger, err error) { + result = &v1alpha1.Trigger{} + err = c.client.Get(). + Namespace(c.ns). + Resource("triggers"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of Triggers that match those selectors. +func (c *triggers) List(opts v1.ListOptions) (result *v1alpha1.TriggerList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha1.TriggerList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("triggers"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested triggers. +func (c *triggers) Watch(opts v1.ListOptions) (watch.Interface, error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + opts.Watch = true + return c.client.Get(). + Namespace(c.ns). + Resource("triggers"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch() +} + +// Create takes the representation of a trigger and creates it. Returns the server's representation of the trigger, and an error, if there is any. +func (c *triggers) Create(trigger *v1alpha1.Trigger) (result *v1alpha1.Trigger, err error) { + result = &v1alpha1.Trigger{} + err = c.client.Post(). + Namespace(c.ns). + Resource("triggers"). + Body(trigger). + Do(). + Into(result) + return +} + +// Update takes the representation of a trigger and updates it. Returns the server's representation of the trigger, and an error, if there is any. +func (c *triggers) Update(trigger *v1alpha1.Trigger) (result *v1alpha1.Trigger, err error) { + result = &v1alpha1.Trigger{} + err = c.client.Put(). + Namespace(c.ns). + Resource("triggers"). + Name(trigger.Name). + Body(trigger). + Do(). + Into(result) + return +} + +// UpdateStatus was generated because the type contains a Status member. +// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). + +func (c *triggers) UpdateStatus(trigger *v1alpha1.Trigger) (result *v1alpha1.Trigger, err error) { + result = &v1alpha1.Trigger{} + err = c.client.Put(). + Namespace(c.ns). + Resource("triggers"). + Name(trigger.Name). + SubResource("status"). + Body(trigger). + Do(). + Into(result) + return +} + +// Delete takes name of the trigger and deletes it. Returns an error if one occurs. +func (c *triggers) Delete(name string, options *v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("triggers"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *triggers) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + var timeout time.Duration + if listOptions.TimeoutSeconds != nil { + timeout = time.Duration(*listOptions.TimeoutSeconds) * time.Second + } + return c.client.Delete(). + Namespace(c.ns). + Resource("triggers"). + VersionedParams(&listOptions, scheme.ParameterCodec). + Timeout(timeout). + Body(options). + Do(). + Error() +} + +// Patch applies the patch and returns the patched trigger. +func (c *triggers) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.Trigger, err error) { + result = &v1alpha1.Trigger{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("triggers"). + SubResource(subresources...). + Name(name). + Body(data). + Do(). + Into(result) + return +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 72b916bff1..6b43b11489 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -627,6 +627,8 @@ knative.dev/eventing/pkg/apis/messaging/v1alpha1 knative.dev/eventing/pkg/apis/sources knative.dev/eventing/pkg/apis/sources/v1alpha1 knative.dev/eventing/pkg/client/clientset/versioned/scheme +knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1alpha1 +knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1alpha1/fake knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1 knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1/fake knative.dev/eventing/pkg/logging