From 4024c835115c0d4cefcadf2662abe7e9aa99e10e Mon Sep 17 00:00:00 2001 From: Ville Aikas <11279988+vaikas@users.noreply.github.com> Date: Thu, 30 Jan 2020 08:34:27 -0800 Subject: [PATCH] Eventtypes v1beta1 (#2466) * port over from v1alpha1 * add gen types * change uris from strings to api.URLvalidation, tests * oops... forgot this one --- Gopkg.lock | 4 +- .../eventing/v1beta1/eventtype_defaults.go | 29 ++ .../v1beta1/eventtype_defaults_test.go | 87 ++++++ pkg/apis/eventing/v1beta1/eventtype_types.go | 101 +++++++ .../eventing/v1beta1/eventtype_validation.go | 72 +++++ .../v1beta1/eventtype_validation_test.go | 271 ++++++++++++++++++ .../eventing/v1beta1/zz_generated.deepcopy.go | 100 +++++++ .../typed/eventing/v1beta1/eventing_client.go | 5 + .../typed/eventing/v1beta1/eventtype.go | 191 ++++++++++++ .../v1beta1/fake/fake_eventing_client.go | 4 + .../eventing/v1beta1/fake/fake_eventtype.go | 140 +++++++++ .../eventing/v1beta1/generated_expansion.go | 2 + .../eventing/v1beta1/eventtype.go | 89 ++++++ .../eventing/v1beta1/interface.go | 7 + .../informers/externalversions/generic.go | 2 + .../eventing/v1beta1/eventtype/eventtype.go | 52 ++++ .../eventing/v1beta1/eventtype/fake/fake.go | 40 +++ .../listers/eventing/v1beta1/eventtype.go | 94 ++++++ .../eventing/v1beta1/expansion_generated.go | 8 + vendor/knative.dev/pkg/Gopkg.lock | 4 +- 20 files changed, 1298 insertions(+), 4 deletions(-) create mode 100644 pkg/apis/eventing/v1beta1/eventtype_defaults.go create mode 100644 pkg/apis/eventing/v1beta1/eventtype_defaults_test.go create mode 100644 pkg/apis/eventing/v1beta1/eventtype_types.go create mode 100644 pkg/apis/eventing/v1beta1/eventtype_validation.go create mode 100644 pkg/apis/eventing/v1beta1/eventtype_validation_test.go create mode 100644 pkg/client/clientset/versioned/typed/eventing/v1beta1/eventtype.go create mode 100644 pkg/client/clientset/versioned/typed/eventing/v1beta1/fake/fake_eventtype.go create mode 100644 pkg/client/informers/externalversions/eventing/v1beta1/eventtype.go create mode 100644 pkg/client/injection/informers/eventing/v1beta1/eventtype/eventtype.go create mode 100644 pkg/client/injection/informers/eventing/v1beta1/eventtype/fake/fake.go create mode 100644 pkg/client/listers/eventing/v1beta1/eventtype.go diff --git a/Gopkg.lock b/Gopkg.lock index 46f4841694d..56446bbd578 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -1305,7 +1305,7 @@ [[projects]] branch = "master" - digest = "1:5acceb9ddfc654a91e633bb00531fc719fcaedda25d621162385ba5c2badc849" + digest = "1:120a79e601bf2ec3496b4ce628d06ae32ab34ce198f3c7ab2f791c6e44f7e2d1" name = "knative.dev/pkg" packages = [ "apis", @@ -1409,7 +1409,7 @@ "webhook/resourcesemantics/validation", ] pruneopts = "T" - revision = "2fbb9db15cbb7971ad2b1f4266a437f5dcc33a51" + revision = "dd62a102dde95f26991c2797603194e4e7831f48" [[projects]] branch = "master" diff --git a/pkg/apis/eventing/v1beta1/eventtype_defaults.go b/pkg/apis/eventing/v1beta1/eventtype_defaults.go new file mode 100644 index 00000000000..bdcfbf3573d --- /dev/null +++ b/pkg/apis/eventing/v1beta1/eventtype_defaults.go @@ -0,0 +1,29 @@ +/* +Copyright 2020 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 v1beta1 + +import "context" + +func (et *EventType) SetDefaults(ctx context.Context) { + et.Spec.SetDefaults(ctx) +} + +func (ets *EventTypeSpec) SetDefaults(ctx context.Context) { + if ets.Broker == "" { + ets.Broker = "default" + } +} diff --git a/pkg/apis/eventing/v1beta1/eventtype_defaults_test.go b/pkg/apis/eventing/v1beta1/eventtype_defaults_test.go new file mode 100644 index 00000000000..0a5cc1dc5bc --- /dev/null +++ b/pkg/apis/eventing/v1beta1/eventtype_defaults_test.go @@ -0,0 +1,87 @@ +/* +Copyright 2020 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 v1beta1 + +import ( + "context" + "testing" + + "github.com/google/go-cmp/cmp" + + "knative.dev/pkg/apis" +) + +func TestEventTypeDefaults(t *testing.T) { + testSource := apis.HTTP("test-source") + testSchema := apis.HTTP("test-schema") + testCases := map[string]struct { + initial EventType + expected EventType + }{ + "nil spec": { + initial: EventType{}, + expected: EventType{ + Spec: EventTypeSpec{ + Broker: "default", + }, + }, + }, + "broker empty": { + initial: EventType{ + Spec: EventTypeSpec{ + Type: "test-type", + Source: *testSource, + Broker: "", + Schema: testSchema, + }, + }, + expected: EventType{ + Spec: EventTypeSpec{ + Type: "test-type", + Source: *testSource, + Broker: "default", + Schema: testSchema, + }, + }, + }, + "broker not set": { + initial: EventType{ + Spec: EventTypeSpec{ + Type: "test-type", + Source: *testSource, + Schema: testSchema, + }, + }, + expected: EventType{ + Spec: EventTypeSpec{ + Type: "test-type", + Source: *testSource, + Broker: "default", + Schema: testSchema, + }, + }, + }, + } + for n, tc := range testCases { + t.Run(n, func(t *testing.T) { + tc.initial.SetDefaults(context.TODO()) + if diff := cmp.Diff(tc.expected, tc.initial); diff != "" { + t.Fatalf("Unexpected defaults (-want, +got): %s", diff) + } + }) + } +} diff --git a/pkg/apis/eventing/v1beta1/eventtype_types.go b/pkg/apis/eventing/v1beta1/eventtype_types.go new file mode 100644 index 00000000000..328f35bf3c8 --- /dev/null +++ b/pkg/apis/eventing/v1beta1/eventtype_types.go @@ -0,0 +1,101 @@ +/* + * Copyright 2020 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 v1beta1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" + "knative.dev/pkg/apis" + duckv1 "knative.dev/pkg/apis/duck/v1" + "knative.dev/pkg/kmeta" +) + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +type EventType struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + + // Spec defines the desired state of the EventType. + Spec EventTypeSpec `json:"spec,omitempty"` + + // Status represents the current state of the EventType. + // This data may be out of date. + // +optional + Status EventTypeStatus `json:"status,omitempty"` +} + +var ( + // Check that EventType can be validated, can be defaulted, and has immutable fields. + _ apis.Validatable = (*EventType)(nil) + _ apis.Defaultable = (*EventType)(nil) + + // Check that EventType can return its spec untyped. + _ apis.HasSpec = (*EventType)(nil) + + _ runtime.Object = (*EventType)(nil) + + // Check that we can create OwnerReferences to an EventType. + _ kmeta.OwnerRefable = (*EventType)(nil) +) + +type EventTypeSpec struct { + // Type represents the CloudEvents type. It is authoritative. + Type string `json:"type"` + // Source is a URI, it represents the CloudEvents source. + Source apis.URL `json:"source"` + // Schema is a URI, it represents the CloudEvents schemaurl extension attribute. + // It may be a JSON schema, a protobuf schema, etc. It is optional. + // +optional + Schema *apis.URL `json:"schema,omitempty"` + // Broker refers to the Broker that can provide the EventType. + Broker string `json:"broker"` + // Description is an optional field used to describe the EventType, in any meaningful way. + // +optional + Description string `json:"description,omitempty"` +} + +// EventTypeStatus represents the current state of a EventType. +type EventTypeStatus struct { + // inherits duck/v1 Status, which currently provides: + // * ObservedGeneration - the 'Generation' of the Service that was last processed by the controller. + // * Conditions - the latest available observations of a resource's current state. + duckv1.Status `json:",inline"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// EventTypeList is a collection of EventTypes. +type EventTypeList struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ListMeta `json:"metadata,omitempty"` + Items []EventType `json:"items"` +} + +// GetGroupVersionKind returns GroupVersionKind for EventType +func (p *EventType) GetGroupVersionKind() schema.GroupVersionKind { + return SchemeGroupVersion.WithKind("EventType") +} + +// GetUntypedSpec returns the spec of the EventType. +func (e *EventType) GetUntypedSpec() interface{} { + return e.Spec +} diff --git a/pkg/apis/eventing/v1beta1/eventtype_validation.go b/pkg/apis/eventing/v1beta1/eventtype_validation.go new file mode 100644 index 00000000000..2827d1eb158 --- /dev/null +++ b/pkg/apis/eventing/v1beta1/eventtype_validation.go @@ -0,0 +1,72 @@ +/* +Copyright 2020 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 v1beta1 + +import ( + "context" + + "github.com/google/go-cmp/cmp/cmpopts" + + "knative.dev/pkg/apis" + "knative.dev/pkg/kmp" +) + +func (et *EventType) Validate(ctx context.Context) *apis.FieldError { + return et.Spec.Validate(ctx).ViaField("spec") +} + +func (ets *EventTypeSpec) Validate(ctx context.Context) *apis.FieldError { + var errs *apis.FieldError + if ets.Type == "" { + fe := apis.ErrMissingField("type") + errs = errs.Also(fe) + } + if ets.Source.IsEmpty() { + // TODO validate is a valid URI. + fe := apis.ErrMissingField("source") + errs = errs.Also(fe) + } + if ets.Broker == "" { + fe := apis.ErrMissingField("broker") + errs = errs.Also(fe) + } + // TODO validate Schema is a valid URI. + return errs +} + +func (et *EventType) CheckImmutableFields(ctx context.Context, original *EventType) *apis.FieldError { + if original == nil { + return nil + } + + // All but Description field immutable. + ignoreArguments := cmpopts.IgnoreFields(EventTypeSpec{}, "Description") + if diff, err := kmp.ShortDiff(original.Spec, et.Spec, ignoreArguments); err != nil { + return &apis.FieldError{ + Message: "Failed to diff EventType", + Paths: []string{"spec"}, + Details: err.Error(), + } + } else if diff != "" { + return &apis.FieldError{ + Message: "Immutable fields changed (-old +new)", + Paths: []string{"spec"}, + Details: diff, + } + } + return nil +} diff --git a/pkg/apis/eventing/v1beta1/eventtype_validation_test.go b/pkg/apis/eventing/v1beta1/eventtype_validation_test.go new file mode 100644 index 00000000000..2686f12fed2 --- /dev/null +++ b/pkg/apis/eventing/v1beta1/eventtype_validation_test.go @@ -0,0 +1,271 @@ +/* +Copyright 2020 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 v1beta1 + +import ( + "context" + "testing" + + "github.com/google/go-cmp/cmp" + "knative.dev/pkg/apis" +) + +func TestEventTypeValidation(t *testing.T) { + name := "invalid type and source and broker" + broker := &EventType{Spec: EventTypeSpec{}} + + want := &apis.FieldError{ + Paths: []string{"spec.type", "spec.source", "spec.broker"}, + Message: "missing field(s)", + } + + t.Run(name, func(t *testing.T) { + got := broker.Validate(context.TODO()) + if diff := cmp.Diff(want.Error(), got.Error()); diff != "" { + t.Errorf("EventType.Validate (-want, +got) = %v", diff) + } + }) +} + +func TestEventTypeSpecValidation(t *testing.T) { + testSource := apis.HTTP("test-source") + tests := []struct { + name string + ets *EventTypeSpec + want *apis.FieldError + }{{ + name: "invalid eventtype spec", + ets: &EventTypeSpec{}, + want: func() *apis.FieldError { + fe := apis.ErrMissingField("type", "source", "broker") + return fe + }(), + }, { + name: "invalid eventtype type", + ets: &EventTypeSpec{ + Source: *testSource, + Broker: "test-broker", + }, + want: func() *apis.FieldError { + fe := apis.ErrMissingField("type") + return fe + }(), + }, { + name: "invalid eventtype source", + ets: &EventTypeSpec{ + Type: "test-type", + Broker: "test-broker", + }, + want: func() *apis.FieldError { + fe := apis.ErrMissingField("source") + return fe + }(), + }, { + name: "invalid eventtype broker", + ets: &EventTypeSpec{ + Type: "test-type", + Source: *testSource, + }, + want: func() *apis.FieldError { + fe := apis.ErrMissingField("broker") + return fe + }(), + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + got := test.ets.Validate(context.TODO()) + if diff := cmp.Diff(test.want.Error(), got.Error()); diff != "" { + t.Errorf("%s: Validate EventTypeSpec (-want, +got) = %v", test.name, diff) + } + }) + } +} + +func TestEventTypeImmutableFields(t *testing.T) { + differentSource := apis.HTTP("original-source") + testSource := apis.HTTP("test-source") + testSchema := apis.HTTP("test-schema") + differentSchema := apis.HTTP("original-schema") + tests := []struct { + name string + current *EventType + original *EventType + want *apis.FieldError + }{{ + name: "good (no change)", + current: &EventType{ + Spec: EventTypeSpec{ + Type: "test-type", + Source: *testSource, + Broker: "test-broker", + Schema: testSchema, + }, + }, + original: &EventType{ + Spec: EventTypeSpec{ + Type: "test-type", + Source: *testSource, + Broker: "test-broker", + Schema: testSchema, + }, + }, + want: nil, + }, { + name: "new nil is ok", + current: &EventType{ + Spec: EventTypeSpec{ + Type: "test-type", + Source: *testSource, + Broker: "test-broker", + Schema: testSchema, + }, + }, + original: nil, + want: nil, + }, { + name: "bad (broker change)", + current: &EventType{ + Spec: EventTypeSpec{ + Type: "test-type", + Source: *testSource, + Broker: "test-broker", + }, + }, + original: &EventType{ + Spec: EventTypeSpec{ + Type: "test-type", + Source: *testSource, + Broker: "original-broker", + }, + }, + want: &apis.FieldError{ + Message: "Immutable fields changed (-old +new)", + Paths: []string{"spec"}, + Details: `{v1beta1.EventTypeSpec}.Broker: + -: "original-broker" + +: "test-broker" +`, + }, + }, { + name: "bad (type change)", + current: &EventType{ + Spec: EventTypeSpec{ + Type: "test-type", + Source: *testSource, + Broker: "test-broker", + }, + }, + original: &EventType{ + Spec: EventTypeSpec{ + Type: "original-type", + Source: *testSource, + Broker: "test-broker", + }, + }, + want: &apis.FieldError{ + Message: "Immutable fields changed (-old +new)", + Paths: []string{"spec"}, + Details: `{v1beta1.EventTypeSpec}.Type: + -: "original-type" + +: "test-type" +`, + }, + }, { + name: "bad (source change)", + current: &EventType{ + Spec: EventTypeSpec{ + Type: "test-type", + Source: *testSource, + Broker: "test-broker", + }, + }, + original: &EventType{ + Spec: EventTypeSpec{ + Type: "test-type", + Source: *differentSource, + Broker: "test-broker", + }, + }, + want: &apis.FieldError{ + Message: "Immutable fields changed (-old +new)", + Paths: []string{"spec"}, + Details: `{v1beta1.EventTypeSpec}.Source.Host: + -: "original-source" + +: "test-source" +`, + }, + }, { + name: "bad (schema change)", + current: &EventType{ + Spec: EventTypeSpec{ + Type: "test-type", + Source: *testSource, + Broker: "test-broker", + Schema: testSchema, + }, + }, + original: &EventType{ + Spec: EventTypeSpec{ + Type: "test-type", + Source: *testSource, + Broker: "test-broker", + Schema: differentSchema, + }, + }, + want: &apis.FieldError{ + Message: "Immutable fields changed (-old +new)", + Paths: []string{"spec"}, + Details: `{v1beta1.EventTypeSpec}.Schema.Host: + -: "original-schema" + +: "test-schema" +`, + }, + }, { + name: "good (description change)", + current: &EventType{ + Spec: EventTypeSpec{ + Type: "test-type", + Source: *testSource, + Broker: "test-broker", + Schema: testSchema, + Description: "test-description", + }, + }, + original: &EventType{ + Spec: EventTypeSpec{ + Type: "test-type", + Source: *testSource, + Broker: "test-broker", + Schema: testSchema, + Description: "original-description", + }, + }, + want: nil, + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + got := test.current.CheckImmutableFields(context.TODO(), test.original) + if diff := cmp.Diff(test.want.Error(), got.Error()); diff != "" { + t.Errorf("CheckImmutableFields (-want, +got) = %v", diff) + } + }) + } +} diff --git a/pkg/apis/eventing/v1beta1/zz_generated.deepcopy.go b/pkg/apis/eventing/v1beta1/zz_generated.deepcopy.go index 3b563c1c734..dfcc85f5e89 100644 --- a/pkg/apis/eventing/v1beta1/zz_generated.deepcopy.go +++ b/pkg/apis/eventing/v1beta1/zz_generated.deepcopy.go @@ -132,6 +132,106 @@ func (in *BrokerStatus) DeepCopy() *BrokerStatus { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *EventType) DeepCopyInto(out *EventType) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EventType. +func (in *EventType) DeepCopy() *EventType { + if in == nil { + return nil + } + out := new(EventType) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *EventType) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *EventTypeList) DeepCopyInto(out *EventTypeList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]EventType, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EventTypeList. +func (in *EventTypeList) DeepCopy() *EventTypeList { + if in == nil { + return nil + } + out := new(EventTypeList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *EventTypeList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *EventTypeSpec) DeepCopyInto(out *EventTypeSpec) { + *out = *in + in.Source.DeepCopyInto(&out.Source) + if in.Schema != nil { + in, out := &in.Schema, &out.Schema + *out = new(apis.URL) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EventTypeSpec. +func (in *EventTypeSpec) DeepCopy() *EventTypeSpec { + if in == nil { + return nil + } + out := new(EventTypeSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *EventTypeStatus) DeepCopyInto(out *EventTypeStatus) { + *out = *in + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EventTypeStatus. +func (in *EventTypeStatus) DeepCopy() *EventTypeStatus { + if in == nil { + return nil + } + out := new(EventTypeStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Trigger) DeepCopyInto(out *Trigger) { *out = *in diff --git a/pkg/client/clientset/versioned/typed/eventing/v1beta1/eventing_client.go b/pkg/client/clientset/versioned/typed/eventing/v1beta1/eventing_client.go index c89dd72d9f2..624522b69b7 100644 --- a/pkg/client/clientset/versioned/typed/eventing/v1beta1/eventing_client.go +++ b/pkg/client/clientset/versioned/typed/eventing/v1beta1/eventing_client.go @@ -27,6 +27,7 @@ import ( type EventingV1beta1Interface interface { RESTClient() rest.Interface BrokersGetter + EventTypesGetter TriggersGetter } @@ -39,6 +40,10 @@ func (c *EventingV1beta1Client) Brokers(namespace string) BrokerInterface { return newBrokers(c, namespace) } +func (c *EventingV1beta1Client) EventTypes(namespace string) EventTypeInterface { + return newEventTypes(c, namespace) +} + func (c *EventingV1beta1Client) Triggers(namespace string) TriggerInterface { return newTriggers(c, namespace) } diff --git a/pkg/client/clientset/versioned/typed/eventing/v1beta1/eventtype.go b/pkg/client/clientset/versioned/typed/eventing/v1beta1/eventtype.go new file mode 100644 index 00000000000..2ce8cf2925f --- /dev/null +++ b/pkg/client/clientset/versioned/typed/eventing/v1beta1/eventtype.go @@ -0,0 +1,191 @@ +/* +Copyright 2020 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 v1beta1 + +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" + v1beta1 "knative.dev/eventing/pkg/apis/eventing/v1beta1" + 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(*v1beta1.EventType) (*v1beta1.EventType, error) + Update(*v1beta1.EventType) (*v1beta1.EventType, error) + UpdateStatus(*v1beta1.EventType) (*v1beta1.EventType, error) + Delete(name string, options *v1.DeleteOptions) error + DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error + Get(name string, options v1.GetOptions) (*v1beta1.EventType, error) + List(opts v1.ListOptions) (*v1beta1.EventTypeList, error) + Watch(opts v1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.EventType, err error) + EventTypeExpansion +} + +// eventTypes implements EventTypeInterface +type eventTypes struct { + client rest.Interface + ns string +} + +// newEventTypes returns a EventTypes +func newEventTypes(c *EventingV1beta1Client, 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 *v1beta1.EventType, err error) { + result = &v1beta1.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 *v1beta1.EventTypeList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta1.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 *v1beta1.EventType) (result *v1beta1.EventType, err error) { + result = &v1beta1.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 *v1beta1.EventType) (result *v1beta1.EventType, err error) { + result = &v1beta1.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 *v1beta1.EventType) (result *v1beta1.EventType, err error) { + result = &v1beta1.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 *v1beta1.EventType, err error) { + result = &v1beta1.EventType{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("eventtypes"). + SubResource(subresources...). + Name(name). + Body(data). + Do(). + Into(result) + return +} diff --git a/pkg/client/clientset/versioned/typed/eventing/v1beta1/fake/fake_eventing_client.go b/pkg/client/clientset/versioned/typed/eventing/v1beta1/fake/fake_eventing_client.go index 946b0323c78..cd80f1c58f3 100644 --- a/pkg/client/clientset/versioned/typed/eventing/v1beta1/fake/fake_eventing_client.go +++ b/pkg/client/clientset/versioned/typed/eventing/v1beta1/fake/fake_eventing_client.go @@ -32,6 +32,10 @@ func (c *FakeEventingV1beta1) Brokers(namespace string) v1beta1.BrokerInterface return &FakeBrokers{c, namespace} } +func (c *FakeEventingV1beta1) EventTypes(namespace string) v1beta1.EventTypeInterface { + return &FakeEventTypes{c, namespace} +} + func (c *FakeEventingV1beta1) Triggers(namespace string) v1beta1.TriggerInterface { return &FakeTriggers{c, namespace} } diff --git a/pkg/client/clientset/versioned/typed/eventing/v1beta1/fake/fake_eventtype.go b/pkg/client/clientset/versioned/typed/eventing/v1beta1/fake/fake_eventtype.go new file mode 100644 index 00000000000..d91c11f781e --- /dev/null +++ b/pkg/client/clientset/versioned/typed/eventing/v1beta1/fake/fake_eventtype.go @@ -0,0 +1,140 @@ +/* +Copyright 2020 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" + v1beta1 "knative.dev/eventing/pkg/apis/eventing/v1beta1" +) + +// FakeEventTypes implements EventTypeInterface +type FakeEventTypes struct { + Fake *FakeEventingV1beta1 + ns string +} + +var eventtypesResource = schema.GroupVersionResource{Group: "eventing.knative.dev", Version: "v1beta1", Resource: "eventtypes"} + +var eventtypesKind = schema.GroupVersionKind{Group: "eventing.knative.dev", Version: "v1beta1", 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 *v1beta1.EventType, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(eventtypesResource, c.ns, name), &v1beta1.EventType{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.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 *v1beta1.EventTypeList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(eventtypesResource, eventtypesKind, c.ns, opts), &v1beta1.EventTypeList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1beta1.EventTypeList{ListMeta: obj.(*v1beta1.EventTypeList).ListMeta} + for _, item := range obj.(*v1beta1.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 *v1beta1.EventType) (result *v1beta1.EventType, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(eventtypesResource, c.ns, eventType), &v1beta1.EventType{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.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 *v1beta1.EventType) (result *v1beta1.EventType, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(eventtypesResource, c.ns, eventType), &v1beta1.EventType{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.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 *v1beta1.EventType) (*v1beta1.EventType, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(eventtypesResource, "status", c.ns, eventType), &v1beta1.EventType{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.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), &v1beta1.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, &v1beta1.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 *v1beta1.EventType, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(eventtypesResource, c.ns, name, pt, data, subresources...), &v1beta1.EventType{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.EventType), err +} diff --git a/pkg/client/clientset/versioned/typed/eventing/v1beta1/generated_expansion.go b/pkg/client/clientset/versioned/typed/eventing/v1beta1/generated_expansion.go index 1fb6fcec994..fcc48085aaa 100644 --- a/pkg/client/clientset/versioned/typed/eventing/v1beta1/generated_expansion.go +++ b/pkg/client/clientset/versioned/typed/eventing/v1beta1/generated_expansion.go @@ -20,4 +20,6 @@ package v1beta1 type BrokerExpansion interface{} +type EventTypeExpansion interface{} + type TriggerExpansion interface{} diff --git a/pkg/client/informers/externalversions/eventing/v1beta1/eventtype.go b/pkg/client/informers/externalversions/eventing/v1beta1/eventtype.go new file mode 100644 index 00000000000..910c5f8055b --- /dev/null +++ b/pkg/client/informers/externalversions/eventing/v1beta1/eventtype.go @@ -0,0 +1,89 @@ +/* +Copyright 2020 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 informer-gen. DO NOT EDIT. + +package v1beta1 + +import ( + time "time" + + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" + eventingv1beta1 "knative.dev/eventing/pkg/apis/eventing/v1beta1" + versioned "knative.dev/eventing/pkg/client/clientset/versioned" + internalinterfaces "knative.dev/eventing/pkg/client/informers/externalversions/internalinterfaces" + v1beta1 "knative.dev/eventing/pkg/client/listers/eventing/v1beta1" +) + +// EventTypeInformer provides access to a shared informer and lister for +// EventTypes. +type EventTypeInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1beta1.EventTypeLister +} + +type eventTypeInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewEventTypeInformer constructs a new informer for EventType type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewEventTypeInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredEventTypeInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredEventTypeInformer constructs a new informer for EventType type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredEventTypeInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.EventingV1beta1().EventTypes(namespace).List(options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.EventingV1beta1().EventTypes(namespace).Watch(options) + }, + }, + &eventingv1beta1.EventType{}, + resyncPeriod, + indexers, + ) +} + +func (f *eventTypeInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredEventTypeInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *eventTypeInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&eventingv1beta1.EventType{}, f.defaultInformer) +} + +func (f *eventTypeInformer) Lister() v1beta1.EventTypeLister { + return v1beta1.NewEventTypeLister(f.Informer().GetIndexer()) +} diff --git a/pkg/client/informers/externalversions/eventing/v1beta1/interface.go b/pkg/client/informers/externalversions/eventing/v1beta1/interface.go index d79127971c9..d3d2347116e 100644 --- a/pkg/client/informers/externalversions/eventing/v1beta1/interface.go +++ b/pkg/client/informers/externalversions/eventing/v1beta1/interface.go @@ -26,6 +26,8 @@ import ( type Interface interface { // Brokers returns a BrokerInformer. Brokers() BrokerInformer + // EventTypes returns a EventTypeInformer. + EventTypes() EventTypeInformer // Triggers returns a TriggerInformer. Triggers() TriggerInformer } @@ -46,6 +48,11 @@ func (v *version) Brokers() BrokerInformer { return &brokerInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} } +// EventTypes returns a EventTypeInformer. +func (v *version) EventTypes() EventTypeInformer { + return &eventTypeInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + // Triggers returns a TriggerInformer. func (v *version) Triggers() TriggerInformer { return &triggerInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} diff --git a/pkg/client/informers/externalversions/generic.go b/pkg/client/informers/externalversions/generic.go index abf561518b7..7dffab4441b 100644 --- a/pkg/client/informers/externalversions/generic.go +++ b/pkg/client/informers/externalversions/generic.go @@ -74,6 +74,8 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource // Group=eventing.knative.dev, Version=v1beta1 case v1beta1.SchemeGroupVersion.WithResource("brokers"): return &genericInformer{resource: resource.GroupResource(), informer: f.Eventing().V1beta1().Brokers().Informer()}, nil + case v1beta1.SchemeGroupVersion.WithResource("eventtypes"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Eventing().V1beta1().EventTypes().Informer()}, nil case v1beta1.SchemeGroupVersion.WithResource("triggers"): return &genericInformer{resource: resource.GroupResource(), informer: f.Eventing().V1beta1().Triggers().Informer()}, nil diff --git a/pkg/client/injection/informers/eventing/v1beta1/eventtype/eventtype.go b/pkg/client/injection/informers/eventing/v1beta1/eventtype/eventtype.go new file mode 100644 index 00000000000..63ac9f14b8d --- /dev/null +++ b/pkg/client/injection/informers/eventing/v1beta1/eventtype/eventtype.go @@ -0,0 +1,52 @@ +/* +Copyright 2020 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 injection-gen. DO NOT EDIT. + +package eventtype + +import ( + "context" + + v1beta1 "knative.dev/eventing/pkg/client/informers/externalversions/eventing/v1beta1" + factory "knative.dev/eventing/pkg/client/injection/informers/factory" + controller "knative.dev/pkg/controller" + injection "knative.dev/pkg/injection" + logging "knative.dev/pkg/logging" +) + +func init() { + injection.Default.RegisterInformer(withInformer) +} + +// Key is used for associating the Informer inside the context.Context. +type Key struct{} + +func withInformer(ctx context.Context) (context.Context, controller.Informer) { + f := factory.Get(ctx) + inf := f.Eventing().V1beta1().EventTypes() + return context.WithValue(ctx, Key{}, inf), inf.Informer() +} + +// Get extracts the typed informer from the context. +func Get(ctx context.Context) v1beta1.EventTypeInformer { + untyped := ctx.Value(Key{}) + if untyped == nil { + logging.FromContext(ctx).Panic( + "Unable to fetch knative.dev/eventing/pkg/client/informers/externalversions/eventing/v1beta1.EventTypeInformer from context.") + } + return untyped.(v1beta1.EventTypeInformer) +} diff --git a/pkg/client/injection/informers/eventing/v1beta1/eventtype/fake/fake.go b/pkg/client/injection/informers/eventing/v1beta1/eventtype/fake/fake.go new file mode 100644 index 00000000000..ab799ac215e --- /dev/null +++ b/pkg/client/injection/informers/eventing/v1beta1/eventtype/fake/fake.go @@ -0,0 +1,40 @@ +/* +Copyright 2020 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 injection-gen. DO NOT EDIT. + +package fake + +import ( + "context" + + eventtype "knative.dev/eventing/pkg/client/injection/informers/eventing/v1beta1/eventtype" + fake "knative.dev/eventing/pkg/client/injection/informers/factory/fake" + controller "knative.dev/pkg/controller" + injection "knative.dev/pkg/injection" +) + +var Get = eventtype.Get + +func init() { + injection.Fake.RegisterInformer(withInformer) +} + +func withInformer(ctx context.Context) (context.Context, controller.Informer) { + f := fake.Get(ctx) + inf := f.Eventing().V1beta1().EventTypes() + return context.WithValue(ctx, eventtype.Key{}, inf), inf.Informer() +} diff --git a/pkg/client/listers/eventing/v1beta1/eventtype.go b/pkg/client/listers/eventing/v1beta1/eventtype.go new file mode 100644 index 00000000000..282f4a4b811 --- /dev/null +++ b/pkg/client/listers/eventing/v1beta1/eventtype.go @@ -0,0 +1,94 @@ +/* +Copyright 2020 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 lister-gen. DO NOT EDIT. + +package v1beta1 + +import ( + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" + v1beta1 "knative.dev/eventing/pkg/apis/eventing/v1beta1" +) + +// EventTypeLister helps list EventTypes. +type EventTypeLister interface { + // List lists all EventTypes in the indexer. + List(selector labels.Selector) (ret []*v1beta1.EventType, err error) + // EventTypes returns an object that can list and get EventTypes. + EventTypes(namespace string) EventTypeNamespaceLister + EventTypeListerExpansion +} + +// eventTypeLister implements the EventTypeLister interface. +type eventTypeLister struct { + indexer cache.Indexer +} + +// NewEventTypeLister returns a new EventTypeLister. +func NewEventTypeLister(indexer cache.Indexer) EventTypeLister { + return &eventTypeLister{indexer: indexer} +} + +// List lists all EventTypes in the indexer. +func (s *eventTypeLister) List(selector labels.Selector) (ret []*v1beta1.EventType, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1beta1.EventType)) + }) + return ret, err +} + +// EventTypes returns an object that can list and get EventTypes. +func (s *eventTypeLister) EventTypes(namespace string) EventTypeNamespaceLister { + return eventTypeNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// EventTypeNamespaceLister helps list and get EventTypes. +type EventTypeNamespaceLister interface { + // List lists all EventTypes in the indexer for a given namespace. + List(selector labels.Selector) (ret []*v1beta1.EventType, err error) + // Get retrieves the EventType from the indexer for a given namespace and name. + Get(name string) (*v1beta1.EventType, error) + EventTypeNamespaceListerExpansion +} + +// eventTypeNamespaceLister implements the EventTypeNamespaceLister +// interface. +type eventTypeNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all EventTypes in the indexer for a given namespace. +func (s eventTypeNamespaceLister) List(selector labels.Selector) (ret []*v1beta1.EventType, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1beta1.EventType)) + }) + return ret, err +} + +// Get retrieves the EventType from the indexer for a given namespace and name. +func (s eventTypeNamespaceLister) Get(name string) (*v1beta1.EventType, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1beta1.Resource("eventtype"), name) + } + return obj.(*v1beta1.EventType), nil +} diff --git a/pkg/client/listers/eventing/v1beta1/expansion_generated.go b/pkg/client/listers/eventing/v1beta1/expansion_generated.go index 1462c32e6b5..06aa7ee7c31 100644 --- a/pkg/client/listers/eventing/v1beta1/expansion_generated.go +++ b/pkg/client/listers/eventing/v1beta1/expansion_generated.go @@ -26,6 +26,14 @@ type BrokerListerExpansion interface{} // BrokerNamespaceLister. type BrokerNamespaceListerExpansion interface{} +// EventTypeListerExpansion allows custom methods to be added to +// EventTypeLister. +type EventTypeListerExpansion interface{} + +// EventTypeNamespaceListerExpansion allows custom methods to be added to +// EventTypeNamespaceLister. +type EventTypeNamespaceListerExpansion interface{} + // TriggerListerExpansion allows custom methods to be added to // TriggerLister. type TriggerListerExpansion interface{} diff --git a/vendor/knative.dev/pkg/Gopkg.lock b/vendor/knative.dev/pkg/Gopkg.lock index abd5fe3700c..8a395679a61 100644 --- a/vendor/knative.dev/pkg/Gopkg.lock +++ b/vendor/knative.dev/pkg/Gopkg.lock @@ -1323,14 +1323,14 @@ [[projects]] branch = "master" - digest = "1:4ba0f80b3feed917d2c9a1aa79ea95836c3aef84589431cff77ffd01615a1150" + digest = "1:f0fb577e7a666886e560755c78e19b56b23303575677a9beca899316eb6a137c" name = "knative.dev/test-infra" packages = [ "scripts", "tools/dep-collector", ] pruneopts = "UT" - revision = "d5990f0e5a05d5819a40ad3b4de6227406850b48" + revision = "5779f9c9458d0a85f734c0cad43c1510aa00b498" [[projects]] digest = "1:8730e0150dfb2b7e173890c8b9868e7a273082ef8e39f4940e3506a481cf895c"