From 67fa2fedcec2cf047b4ba79c5df9a83081c39ab3 Mon Sep 17 00:00:00 2001 From: Matt Moore Date: Fri, 27 Mar 2020 13:17:52 -0700 Subject: [PATCH] [master] Auto-update dependencies (#722) Produced via: `./hack/update-deps.sh --upgrade && ./hack/update-codegen.sh` /assign grantr nachocano /cc grantr nachocano --- Gopkg.lock | 10 +- .../config/200-channel-broker-binding.yaml | 1 - .../200-channel-broker-clusterrole.yaml | 1 - .../config/300-configmappropagation.yaml | 1 - .../eventing/config/300-containersource.yaml | 1 + .../config/400-config-br-default-channel.yaml | 1 - .../config/400-config-br-defaults.yaml | 2 +- .../config/500-broker-controller.yaml | 1 - .../200-channel-broker-clusterrole.yaml | 1 + .../300-configmappropagation.yaml | 1 + .../400-config-br-default-channel.yaml | 1 + .../400-config-br-defaults.yaml | 1 + .../channel-broker/500-broker-controller.yaml | 1 + .../400-config-br-default-channel.yaml | 1 + .../eventing/pkg/apis/sources/register.go | 6 + .../sources/v1alpha2/container_defaults.go | 42 ++++ .../sources/v1alpha2/container_lifecycle.go | 92 +++++++++ .../apis/sources/v1alpha2/container_types.go | 92 +++++++++ .../sources/v1alpha2/container_validation.go | 59 ++++++ .../pkg/apis/sources/v1alpha2/register.go | 2 + .../sources/v1alpha2/zz_generated.deepcopy.go | 96 +++++++++ .../typed/sources/v1alpha2/containersource.go | 191 ++++++++++++++++++ .../v1alpha2/fake/fake_containersource.go | 140 +++++++++++++ .../v1alpha2/fake/fake_sources_client.go | 4 + .../sources/v1alpha2/generated_expansion.go | 2 + .../typed/sources/v1alpha2/sources_client.go | 5 + .../informers/externalversions/generic.go | 2 + .../sources/v1alpha2/containersource.go | 89 ++++++++ .../sources/v1alpha2/interface.go | 7 + .../sources/v1alpha2/containersource.go | 94 +++++++++ .../sources/v1alpha2/expansion_generated.go | 8 + .../pkg/reconciler/testing/containersource.go | 103 ++++++++++ .../pkg/reconciler/testing/listers.go | 12 ++ .../pkg/reconciler/testing/pingsource.go | 11 + .../knative.dev/eventing/test/e2e-common.sh | 7 +- vendor/knative.dev/eventing/test/e2e-tests.sh | 4 - .../knative.dev/eventing/test/lib/creation.go | 11 + .../serving/pkg/apis/config/defaults.go | 6 +- 38 files changed, 1086 insertions(+), 23 deletions(-) delete mode 120000 vendor/knative.dev/eventing/config/200-channel-broker-binding.yaml delete mode 120000 vendor/knative.dev/eventing/config/200-channel-broker-clusterrole.yaml delete mode 120000 vendor/knative.dev/eventing/config/300-configmappropagation.yaml create mode 120000 vendor/knative.dev/eventing/config/300-containersource.yaml delete mode 120000 vendor/knative.dev/eventing/config/400-config-br-default-channel.yaml delete mode 120000 vendor/knative.dev/eventing/config/500-broker-controller.yaml create mode 120000 vendor/knative.dev/eventing/config/brokers/channel-broker/200-channel-broker-clusterrole.yaml create mode 120000 vendor/knative.dev/eventing/config/brokers/channel-broker/300-configmappropagation.yaml create mode 120000 vendor/knative.dev/eventing/config/brokers/channel-broker/400-config-br-default-channel.yaml create mode 120000 vendor/knative.dev/eventing/config/brokers/channel-broker/400-config-br-defaults.yaml create mode 120000 vendor/knative.dev/eventing/config/brokers/channel-broker/500-broker-controller.yaml create mode 120000 vendor/knative.dev/eventing/config/brokers/mt-channel-broker/400-config-br-default-channel.yaml create mode 100644 vendor/knative.dev/eventing/pkg/apis/sources/v1alpha2/container_defaults.go create mode 100644 vendor/knative.dev/eventing/pkg/apis/sources/v1alpha2/container_lifecycle.go create mode 100644 vendor/knative.dev/eventing/pkg/apis/sources/v1alpha2/container_types.go create mode 100644 vendor/knative.dev/eventing/pkg/apis/sources/v1alpha2/container_validation.go create mode 100644 vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha2/containersource.go create mode 100644 vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha2/fake/fake_containersource.go create mode 100644 vendor/knative.dev/eventing/pkg/client/informers/externalversions/sources/v1alpha2/containersource.go create mode 100644 vendor/knative.dev/eventing/pkg/client/listers/sources/v1alpha2/containersource.go create mode 100644 vendor/knative.dev/eventing/pkg/reconciler/testing/containersource.go diff --git a/Gopkg.lock b/Gopkg.lock index 747ef6c81f..9fd32c6b32 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -1438,7 +1438,7 @@ [[projects]] branch = "master" - digest = "1:213b2f54af186f00f05ece9a6d4f3d9e1a3cb713e535e655e23042dab5142ac1" + digest = "1:b03a0a6cfe1ff13202380dbf1af1b60628764a4e62c6601800e9c1e7b1d26205" name = "knative.dev/eventing" packages = [ "pkg/apis/config", @@ -1534,7 +1534,7 @@ "test/test_images/transformevents", ] pruneopts = "UT" - revision = "bf7b1bcb500c0bd1ec2b9300ebbf246152a7ab7c" + revision = "bcfe43a96be1b0dca208921971f98f118dbff328" [[projects]] branch = "master" @@ -1623,7 +1623,7 @@ [[projects]] branch = "master" - digest = "1:4e2670fac5b2a25699102035493f3d4b9964fdcb87299d20ea37573a22b5db6c" + digest = "1:5d8a44f8116d701577d08b8bf209eef77875ed30c598238e0eaf5a549d45e2c9" name = "knative.dev/serving" packages = [ "pkg/apis/autoscaling", @@ -1672,7 +1672,7 @@ "pkg/client/listers/serving/v1beta1", ] pruneopts = "NUT" - revision = "54cbd0ecf2f8247b5a93a2c0e6785e541ad2d399" + revision = "72db94b4990111120afe768faa60b612c007849f" [[projects]] branch = "master" @@ -1683,7 +1683,7 @@ "tools/dep-collector", ] pruneopts = "UT" - revision = "9a6c4b1d41ce980537cebe2b34c4b8c92fbd2b47" + revision = "5c80391d7529640b44e193307289baac4b53b20b" [[projects]] digest = "1:8730e0150dfb2b7e173890c8b9868e7a273082ef8e39f4940e3506a481cf895c" diff --git a/vendor/knative.dev/eventing/config/200-channel-broker-binding.yaml b/vendor/knative.dev/eventing/config/200-channel-broker-binding.yaml deleted file mode 120000 index ac54ef0334..0000000000 --- a/vendor/knative.dev/eventing/config/200-channel-broker-binding.yaml +++ /dev/null @@ -1 +0,0 @@ -brokers/channel-broker/200-channel-broker-binding.yaml \ No newline at end of file diff --git a/vendor/knative.dev/eventing/config/200-channel-broker-clusterrole.yaml b/vendor/knative.dev/eventing/config/200-channel-broker-clusterrole.yaml deleted file mode 120000 index b0aec1ce71..0000000000 --- a/vendor/knative.dev/eventing/config/200-channel-broker-clusterrole.yaml +++ /dev/null @@ -1 +0,0 @@ -brokers/channel-broker/roles/controller-clusterroles.yaml \ No newline at end of file diff --git a/vendor/knative.dev/eventing/config/300-configmappropagation.yaml b/vendor/knative.dev/eventing/config/300-configmappropagation.yaml deleted file mode 120000 index 98fc7ef3e1..0000000000 --- a/vendor/knative.dev/eventing/config/300-configmappropagation.yaml +++ /dev/null @@ -1 +0,0 @@ -brokers/channel-broker/resources/configmappropagation.yaml \ No newline at end of file diff --git a/vendor/knative.dev/eventing/config/300-containersource.yaml b/vendor/knative.dev/eventing/config/300-containersource.yaml new file mode 120000 index 0000000000..3ffe43ecf6 --- /dev/null +++ b/vendor/knative.dev/eventing/config/300-containersource.yaml @@ -0,0 +1 @@ +core/resources/containersource.yaml \ No newline at end of file diff --git a/vendor/knative.dev/eventing/config/400-config-br-default-channel.yaml b/vendor/knative.dev/eventing/config/400-config-br-default-channel.yaml deleted file mode 120000 index 4ab2b34f9e..0000000000 --- a/vendor/knative.dev/eventing/config/400-config-br-default-channel.yaml +++ /dev/null @@ -1 +0,0 @@ -core/configmaps/default-imc.yaml \ No newline at end of file diff --git a/vendor/knative.dev/eventing/config/400-config-br-defaults.yaml b/vendor/knative.dev/eventing/config/400-config-br-defaults.yaml index df14d23770..f85262644b 120000 --- a/vendor/knative.dev/eventing/config/400-config-br-defaults.yaml +++ b/vendor/knative.dev/eventing/config/400-config-br-defaults.yaml @@ -1 +1 @@ -core/configmaps/default-broker.yaml \ No newline at end of file +brokers/channel-broker/configmaps/default-broker.yaml \ No newline at end of file diff --git a/vendor/knative.dev/eventing/config/500-broker-controller.yaml b/vendor/knative.dev/eventing/config/500-broker-controller.yaml deleted file mode 120000 index c716eef7dd..0000000000 --- a/vendor/knative.dev/eventing/config/500-broker-controller.yaml +++ /dev/null @@ -1 +0,0 @@ -brokers/channel-broker/deployments/controller.yaml \ No newline at end of file diff --git a/vendor/knative.dev/eventing/config/brokers/channel-broker/200-channel-broker-clusterrole.yaml b/vendor/knative.dev/eventing/config/brokers/channel-broker/200-channel-broker-clusterrole.yaml new file mode 120000 index 0000000000..30646a228a --- /dev/null +++ b/vendor/knative.dev/eventing/config/brokers/channel-broker/200-channel-broker-clusterrole.yaml @@ -0,0 +1 @@ +roles/controller-clusterroles.yaml \ No newline at end of file diff --git a/vendor/knative.dev/eventing/config/brokers/channel-broker/300-configmappropagation.yaml b/vendor/knative.dev/eventing/config/brokers/channel-broker/300-configmappropagation.yaml new file mode 120000 index 0000000000..299cbf86a8 --- /dev/null +++ b/vendor/knative.dev/eventing/config/brokers/channel-broker/300-configmappropagation.yaml @@ -0,0 +1 @@ +resources/configmappropagation.yaml \ No newline at end of file diff --git a/vendor/knative.dev/eventing/config/brokers/channel-broker/400-config-br-default-channel.yaml b/vendor/knative.dev/eventing/config/brokers/channel-broker/400-config-br-default-channel.yaml new file mode 120000 index 0000000000..a8c0c16d9d --- /dev/null +++ b/vendor/knative.dev/eventing/config/brokers/channel-broker/400-config-br-default-channel.yaml @@ -0,0 +1 @@ +configmaps/default-imc.yaml \ No newline at end of file diff --git a/vendor/knative.dev/eventing/config/brokers/channel-broker/400-config-br-defaults.yaml b/vendor/knative.dev/eventing/config/brokers/channel-broker/400-config-br-defaults.yaml new file mode 120000 index 0000000000..9c79342f94 --- /dev/null +++ b/vendor/knative.dev/eventing/config/brokers/channel-broker/400-config-br-defaults.yaml @@ -0,0 +1 @@ +configmaps/default-broker.yaml \ No newline at end of file diff --git a/vendor/knative.dev/eventing/config/brokers/channel-broker/500-broker-controller.yaml b/vendor/knative.dev/eventing/config/brokers/channel-broker/500-broker-controller.yaml new file mode 120000 index 0000000000..7a5f7f74af --- /dev/null +++ b/vendor/knative.dev/eventing/config/brokers/channel-broker/500-broker-controller.yaml @@ -0,0 +1 @@ +deployments/controller.yaml \ No newline at end of file diff --git a/vendor/knative.dev/eventing/config/brokers/mt-channel-broker/400-config-br-default-channel.yaml b/vendor/knative.dev/eventing/config/brokers/mt-channel-broker/400-config-br-default-channel.yaml new file mode 120000 index 0000000000..a8c0c16d9d --- /dev/null +++ b/vendor/knative.dev/eventing/config/brokers/mt-channel-broker/400-config-br-default-channel.yaml @@ -0,0 +1 @@ +configmaps/default-imc.yaml \ No newline at end of file diff --git a/vendor/knative.dev/eventing/pkg/apis/sources/register.go b/vendor/knative.dev/eventing/pkg/apis/sources/register.go index 427b8aad84..55b4a748b1 100644 --- a/vendor/knative.dev/eventing/pkg/apis/sources/register.go +++ b/vendor/knative.dev/eventing/pkg/apis/sources/register.go @@ -50,4 +50,10 @@ var ( Group: GroupName, Resource: "sinkbindings", } + + // ContainerSourceResource respresents a Knative Eventing Sources ContainerSource + ContainerSourceResource = schema.GroupResource{ + Group: GroupName, + Resource: "containersources", + } ) diff --git a/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha2/container_defaults.go b/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha2/container_defaults.go new file mode 100644 index 0000000000..adaadb3fb9 --- /dev/null +++ b/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha2/container_defaults.go @@ -0,0 +1,42 @@ +/* +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 v1alpha2 + +import ( + "context" + "fmt" + + corev1 "k8s.io/api/core/v1" + "knative.dev/pkg/apis" +) + +func (s *ContainerSource) SetDefaults(ctx context.Context) { + withName := apis.WithinParent(ctx, s.ObjectMeta) + s.Spec.SetDefaults(withName) +} + +func (ss *ContainerSourceSpec) SetDefaults(ctx context.Context) { + containers := make([]corev1.Container, 0, len(ss.Template.Spec.Containers)) + for i, c := range ss.Template.Spec.Containers { + // If the Container specified has no name, then default to "_". + if c.Name == "" { + c.Name = fmt.Sprintf("%s-%d", apis.ParentMeta(ctx).Name, i) + } + containers = append(containers, c) + } + ss.Template.Spec.Containers = containers +} diff --git a/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha2/container_lifecycle.go b/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha2/container_lifecycle.go new file mode 100644 index 0000000000..7cecfd380d --- /dev/null +++ b/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha2/container_lifecycle.go @@ -0,0 +1,92 @@ +/* +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 v1alpha2 + +import ( + appsv1 "k8s.io/api/apps/v1" + corev1 "k8s.io/api/core/v1" + "knative.dev/eventing/pkg/apis/duck" + "knative.dev/pkg/apis" +) + +const ( + // ContainerSourceConditionReady has status True when the ContainerSource is ready to send events. + ContainerSourceConditionReady = apis.ConditionReady + + // ContainerSourceConditionSinkBindingReady has status True when the ContainerSource's SinkBinding is ready. + ContainerSourceConditionSinkBindingReady apis.ConditionType = "SinkBindingReady" + + // ContainerSourceConditionReceiveAdapterReady has status True when the ContainerSource's ReceiveAdapter is ready. + ContainerSourceConditionReceiveAdapterReady apis.ConditionType = "ReceiveAdapterReady" +) + +var containerCondSet = apis.NewLivingConditionSet( + ContainerSourceConditionSinkBindingReady, + ContainerSourceConditionReceiveAdapterReady, +) + +// GetCondition returns the condition currently associated with the given type, or nil. +func (s *ContainerSourceStatus) GetCondition(t apis.ConditionType) *apis.Condition { + return containerCondSet.Manage(s).GetCondition(t) +} + +// IsReady returns true if the resource is ready overall. +func (s *ContainerSourceStatus) IsReady() bool { + return containerCondSet.Manage(s).IsHappy() +} + +// InitializeConditions sets relevant unset conditions to Unknown state. +func (s *ContainerSourceStatus) InitializeConditions() { + containerCondSet.Manage(s).InitializeConditions() +} + +// PropagateSinkBindingStatus uses the availability of the provided Deployment to determine if +// ContainerSourceConditionSinkBindingReady should be marked as true, false or unknown. +func (s *ContainerSourceStatus) PropagateSinkBindingStatus(status *SinkBindingStatus) { + // Do not copy conditions nor observedGeneration + conditions := s.Conditions + observedGeneration := s.ObservedGeneration + s.SourceStatus = status.SourceStatus + s.Conditions = conditions + s.ObservedGeneration = observedGeneration + + cond := status.GetCondition(apis.ConditionReady) + switch { + case cond == nil: + containerCondSet.Manage(s).MarkUnknown(ContainerSourceConditionSinkBindingReady, "", "") + case cond.Status == corev1.ConditionTrue: + containerCondSet.Manage(s).MarkTrue(ContainerSourceConditionSinkBindingReady) + case cond.Status == corev1.ConditionFalse: + containerCondSet.Manage(s).MarkFalse(ContainerSourceConditionSinkBindingReady, cond.Reason, cond.Message) + case cond.Status == corev1.ConditionUnknown: + containerCondSet.Manage(s).MarkUnknown(ContainerSourceConditionSinkBindingReady, cond.Reason, cond.Message) + default: + containerCondSet.Manage(s).MarkUnknown(ContainerSourceConditionSinkBindingReady, cond.Reason, cond.Message) + } +} + +// PropagateReceiveAdapterStatus uses the availability of the provided Deployment to determine if +// ContainerSourceConditionReceiveAdapterReady should be marked as true or false. +func (s *ContainerSourceStatus) PropagateReceiveAdapterStatus(d *appsv1.Deployment) { + if duck.DeploymentIsAvailable(&d.Status, false) { + containerCondSet.Manage(s).MarkTrue(ContainerSourceConditionReceiveAdapterReady) + } else { + // I don't know how to propagate the status well, so just give the name of the Deployment + // for now. + containerCondSet.Manage(s).MarkFalse(ContainerSourceConditionReceiveAdapterReady, "DeploymentUnavailable", "The Deployment '%s' is unavailable.", d.Name) + } +} diff --git a/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha2/container_types.go b/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha2/container_types.go new file mode 100644 index 0000000000..795fdd97e1 --- /dev/null +++ b/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha2/container_types.go @@ -0,0 +1,92 @@ +/* +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 v1alpha2 + +import ( + corev1 "k8s.io/api/core/v1" + 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 +// +genreconciler +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// ContainerSource is the Schema for the containersources API +type ContainerSource struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec ContainerSourceSpec `json:"spec,omitempty"` + Status ContainerSourceStatus `json:"status,omitempty"` +} + +var ( + _ runtime.Object = (*ContainerSource)(nil) + _ kmeta.OwnerRefable = (*ContainerSource)(nil) + _ apis.Validatable = (*ContainerSource)(nil) + _ apis.Defaultable = (*ContainerSource)(nil) + _ apis.HasSpec = (*ContainerSource)(nil) +) + +// ContainerSourceSpec defines the desired state of ContainerSource +type ContainerSourceSpec struct { + // inherits duck/v1 SourceSpec, which currently provides: + // * Sink - a reference to an object that will resolve to a domain name or + // a URI directly to use as the sink. + // * CloudEventOverrides - defines overrides to control the output format + // and modifications of the event sent to the sink. + duckv1.SourceSpec `json:",inline"` + + // Template describes the pods that will be created + Template corev1.PodTemplateSpec `json:"template"` +} + +// GetGroupVersionKind returns the GroupVersionKind. +func (s *ContainerSource) GetGroupVersionKind() schema.GroupVersionKind { + return SchemeGroupVersion.WithKind("ContainerSource") +} + +// ContainerSourceStatus defines the observed state of ContainerSource +type ContainerSourceStatus struct { + // inherits duck/v1 SourceStatus, 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. + // * SinkURI - the current active sink URI that has been configured for the + // Source. + duckv1.SourceStatus `json:",inline"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// ContainerSourceList contains a list of ContainerSource +type ContainerSourceList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []ContainerSource `json:"items"` +} + +// GetUntypedSpec returns the spec of the ContainerSource. +func (c *ContainerSource) GetUntypedSpec() interface{} { + return c.Spec +} diff --git a/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha2/container_validation.go b/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha2/container_validation.go new file mode 100644 index 0000000000..167435bfa1 --- /dev/null +++ b/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha2/container_validation.go @@ -0,0 +1,59 @@ +/* +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 v1alpha2 + +import ( + "context" + + corev1 "k8s.io/api/core/v1" + "knative.dev/pkg/apis" +) + +func (c *ContainerSource) Validate(ctx context.Context) *apis.FieldError { + return c.Spec.Validate(ctx).ViaField("spec") +} + +func (cs *ContainerSourceSpec) Validate(ctx context.Context) *apis.FieldError { + var errs *apis.FieldError + if fe := cs.Sink.Validate(ctx); fe != nil { + errs = errs.Also(fe.ViaField("sink")) + } + + // Validate there is at least a container + if cs.Template.Spec.Containers == nil || len(cs.Template.Spec.Containers) == 0 { + fe := apis.ErrMissingField("containers") + errs = errs.Also(fe) + } else { + for i, c := range cs.Template.Spec.Containers { + if ce := isValidContainer(&c); ce != nil { + errs = errs.Also(ce.ViaFieldIndex("containers", i)) + } + } + } + return errs +} + +func isValidContainer(c *corev1.Container) *apis.FieldError { + var errs *apis.FieldError + if c.Name == "" { + errs = errs.Also(apis.ErrMissingField("name")) + } + if c.Image == "" { + errs = errs.Also(apis.ErrMissingField("image")) + } + return errs +} diff --git a/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha2/register.go b/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha2/register.go index 9f57ddeb4a..e33d6c76ca 100644 --- a/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha2/register.go +++ b/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha2/register.go @@ -51,6 +51,8 @@ func addKnownTypes(scheme *runtime.Scheme) error { &PingSourceList{}, &SinkBinding{}, &SinkBindingList{}, + &ContainerSource{}, + &ContainerSourceList{}, ) metav1.AddToGroupVersion(scheme, SchemeGroupVersion) return nil diff --git a/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha2/zz_generated.deepcopy.go b/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha2/zz_generated.deepcopy.go index eb0f9f7092..7bf7ad702c 100644 --- a/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha2/zz_generated.deepcopy.go +++ b/vendor/knative.dev/eventing/pkg/apis/sources/v1alpha2/zz_generated.deepcopy.go @@ -163,6 +163,102 @@ func (in *ApiServerSourceStatus) DeepCopy() *ApiServerSourceStatus { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ContainerSource) DeepCopyInto(out *ContainerSource) { + *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 ContainerSource. +func (in *ContainerSource) DeepCopy() *ContainerSource { + if in == nil { + return nil + } + out := new(ContainerSource) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ContainerSource) 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 *ContainerSourceList) DeepCopyInto(out *ContainerSourceList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]ContainerSource, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ContainerSourceList. +func (in *ContainerSourceList) DeepCopy() *ContainerSourceList { + if in == nil { + return nil + } + out := new(ContainerSourceList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ContainerSourceList) 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 *ContainerSourceSpec) DeepCopyInto(out *ContainerSourceSpec) { + *out = *in + in.SourceSpec.DeepCopyInto(&out.SourceSpec) + in.Template.DeepCopyInto(&out.Template) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ContainerSourceSpec. +func (in *ContainerSourceSpec) DeepCopy() *ContainerSourceSpec { + if in == nil { + return nil + } + out := new(ContainerSourceSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ContainerSourceStatus) DeepCopyInto(out *ContainerSourceStatus) { + *out = *in + in.SourceStatus.DeepCopyInto(&out.SourceStatus) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ContainerSourceStatus. +func (in *ContainerSourceStatus) DeepCopy() *ContainerSourceStatus { + if in == nil { + return nil + } + out := new(ContainerSourceStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *PingSource) DeepCopyInto(out *PingSource) { *out = *in diff --git a/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha2/containersource.go b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha2/containersource.go new file mode 100644 index 0000000000..1e884bf20c --- /dev/null +++ b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha2/containersource.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 v1alpha2 + +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" + v1alpha2 "knative.dev/eventing/pkg/apis/sources/v1alpha2" + scheme "knative.dev/eventing/pkg/client/clientset/versioned/scheme" +) + +// ContainerSourcesGetter has a method to return a ContainerSourceInterface. +// A group's client should implement this interface. +type ContainerSourcesGetter interface { + ContainerSources(namespace string) ContainerSourceInterface +} + +// ContainerSourceInterface has methods to work with ContainerSource resources. +type ContainerSourceInterface interface { + Create(*v1alpha2.ContainerSource) (*v1alpha2.ContainerSource, error) + Update(*v1alpha2.ContainerSource) (*v1alpha2.ContainerSource, error) + UpdateStatus(*v1alpha2.ContainerSource) (*v1alpha2.ContainerSource, error) + Delete(name string, options *v1.DeleteOptions) error + DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error + Get(name string, options v1.GetOptions) (*v1alpha2.ContainerSource, error) + List(opts v1.ListOptions) (*v1alpha2.ContainerSourceList, error) + Watch(opts v1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha2.ContainerSource, err error) + ContainerSourceExpansion +} + +// containerSources implements ContainerSourceInterface +type containerSources struct { + client rest.Interface + ns string +} + +// newContainerSources returns a ContainerSources +func newContainerSources(c *SourcesV1alpha2Client, namespace string) *containerSources { + return &containerSources{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the containerSource, and returns the corresponding containerSource object, and an error if there is any. +func (c *containerSources) Get(name string, options v1.GetOptions) (result *v1alpha2.ContainerSource, err error) { + result = &v1alpha2.ContainerSource{} + err = c.client.Get(). + Namespace(c.ns). + Resource("containersources"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of ContainerSources that match those selectors. +func (c *containerSources) List(opts v1.ListOptions) (result *v1alpha2.ContainerSourceList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1alpha2.ContainerSourceList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("containersources"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested containerSources. +func (c *containerSources) 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("containersources"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch() +} + +// Create takes the representation of a containerSource and creates it. Returns the server's representation of the containerSource, and an error, if there is any. +func (c *containerSources) Create(containerSource *v1alpha2.ContainerSource) (result *v1alpha2.ContainerSource, err error) { + result = &v1alpha2.ContainerSource{} + err = c.client.Post(). + Namespace(c.ns). + Resource("containersources"). + Body(containerSource). + Do(). + Into(result) + return +} + +// Update takes the representation of a containerSource and updates it. Returns the server's representation of the containerSource, and an error, if there is any. +func (c *containerSources) Update(containerSource *v1alpha2.ContainerSource) (result *v1alpha2.ContainerSource, err error) { + result = &v1alpha2.ContainerSource{} + err = c.client.Put(). + Namespace(c.ns). + Resource("containersources"). + Name(containerSource.Name). + Body(containerSource). + 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 *containerSources) UpdateStatus(containerSource *v1alpha2.ContainerSource) (result *v1alpha2.ContainerSource, err error) { + result = &v1alpha2.ContainerSource{} + err = c.client.Put(). + Namespace(c.ns). + Resource("containersources"). + Name(containerSource.Name). + SubResource("status"). + Body(containerSource). + Do(). + Into(result) + return +} + +// Delete takes name of the containerSource and deletes it. Returns an error if one occurs. +func (c *containerSources) Delete(name string, options *v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("containersources"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *containerSources) 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("containersources"). + VersionedParams(&listOptions, scheme.ParameterCodec). + Timeout(timeout). + Body(options). + Do(). + Error() +} + +// Patch applies the patch and returns the patched containerSource. +func (c *containerSources) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha2.ContainerSource, err error) { + result = &v1alpha2.ContainerSource{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("containersources"). + SubResource(subresources...). + Name(name). + Body(data). + Do(). + Into(result) + return +} diff --git a/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha2/fake/fake_containersource.go b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha2/fake/fake_containersource.go new file mode 100644 index 0000000000..c990e643f2 --- /dev/null +++ b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha2/fake/fake_containersource.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" + v1alpha2 "knative.dev/eventing/pkg/apis/sources/v1alpha2" +) + +// FakeContainerSources implements ContainerSourceInterface +type FakeContainerSources struct { + Fake *FakeSourcesV1alpha2 + ns string +} + +var containersourcesResource = schema.GroupVersionResource{Group: "sources.knative.dev", Version: "v1alpha2", Resource: "containersources"} + +var containersourcesKind = schema.GroupVersionKind{Group: "sources.knative.dev", Version: "v1alpha2", Kind: "ContainerSource"} + +// Get takes name of the containerSource, and returns the corresponding containerSource object, and an error if there is any. +func (c *FakeContainerSources) Get(name string, options v1.GetOptions) (result *v1alpha2.ContainerSource, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(containersourcesResource, c.ns, name), &v1alpha2.ContainerSource{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha2.ContainerSource), err +} + +// List takes label and field selectors, and returns the list of ContainerSources that match those selectors. +func (c *FakeContainerSources) List(opts v1.ListOptions) (result *v1alpha2.ContainerSourceList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(containersourcesResource, containersourcesKind, c.ns, opts), &v1alpha2.ContainerSourceList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1alpha2.ContainerSourceList{ListMeta: obj.(*v1alpha2.ContainerSourceList).ListMeta} + for _, item := range obj.(*v1alpha2.ContainerSourceList).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 containerSources. +func (c *FakeContainerSources) Watch(opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(containersourcesResource, c.ns, opts)) + +} + +// Create takes the representation of a containerSource and creates it. Returns the server's representation of the containerSource, and an error, if there is any. +func (c *FakeContainerSources) Create(containerSource *v1alpha2.ContainerSource) (result *v1alpha2.ContainerSource, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(containersourcesResource, c.ns, containerSource), &v1alpha2.ContainerSource{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha2.ContainerSource), err +} + +// Update takes the representation of a containerSource and updates it. Returns the server's representation of the containerSource, and an error, if there is any. +func (c *FakeContainerSources) Update(containerSource *v1alpha2.ContainerSource) (result *v1alpha2.ContainerSource, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(containersourcesResource, c.ns, containerSource), &v1alpha2.ContainerSource{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha2.ContainerSource), 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 *FakeContainerSources) UpdateStatus(containerSource *v1alpha2.ContainerSource) (*v1alpha2.ContainerSource, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(containersourcesResource, "status", c.ns, containerSource), &v1alpha2.ContainerSource{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha2.ContainerSource), err +} + +// Delete takes name of the containerSource and deletes it. Returns an error if one occurs. +func (c *FakeContainerSources) Delete(name string, options *v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(containersourcesResource, c.ns, name), &v1alpha2.ContainerSource{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeContainerSources) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(containersourcesResource, c.ns, listOptions) + + _, err := c.Fake.Invokes(action, &v1alpha2.ContainerSourceList{}) + return err +} + +// Patch applies the patch and returns the patched containerSource. +func (c *FakeContainerSources) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha2.ContainerSource, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(containersourcesResource, c.ns, name, pt, data, subresources...), &v1alpha2.ContainerSource{}) + + if obj == nil { + return nil, err + } + return obj.(*v1alpha2.ContainerSource), err +} diff --git a/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha2/fake/fake_sources_client.go b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha2/fake/fake_sources_client.go index 3459a1a0d5..fb6365ba9d 100644 --- a/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha2/fake/fake_sources_client.go +++ b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha2/fake/fake_sources_client.go @@ -32,6 +32,10 @@ func (c *FakeSourcesV1alpha2) ApiServerSources(namespace string) v1alpha2.ApiSer return &FakeApiServerSources{c, namespace} } +func (c *FakeSourcesV1alpha2) ContainerSources(namespace string) v1alpha2.ContainerSourceInterface { + return &FakeContainerSources{c, namespace} +} + func (c *FakeSourcesV1alpha2) PingSources(namespace string) v1alpha2.PingSourceInterface { return &FakePingSources{c, namespace} } diff --git a/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha2/generated_expansion.go b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha2/generated_expansion.go index c4f05376cf..b2816d38c5 100644 --- a/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha2/generated_expansion.go +++ b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha2/generated_expansion.go @@ -20,6 +20,8 @@ package v1alpha2 type ApiServerSourceExpansion interface{} +type ContainerSourceExpansion interface{} + type PingSourceExpansion interface{} type SinkBindingExpansion interface{} diff --git a/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha2/sources_client.go b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha2/sources_client.go index 1061b14e0f..e573e6dcad 100644 --- a/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha2/sources_client.go +++ b/vendor/knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha2/sources_client.go @@ -27,6 +27,7 @@ import ( type SourcesV1alpha2Interface interface { RESTClient() rest.Interface ApiServerSourcesGetter + ContainerSourcesGetter PingSourcesGetter SinkBindingsGetter } @@ -40,6 +41,10 @@ func (c *SourcesV1alpha2Client) ApiServerSources(namespace string) ApiServerSour return newApiServerSources(c, namespace) } +func (c *SourcesV1alpha2Client) ContainerSources(namespace string) ContainerSourceInterface { + return newContainerSources(c, namespace) +} + func (c *SourcesV1alpha2Client) PingSources(namespace string) PingSourceInterface { return newPingSources(c, namespace) } diff --git a/vendor/knative.dev/eventing/pkg/client/informers/externalversions/generic.go b/vendor/knative.dev/eventing/pkg/client/informers/externalversions/generic.go index 67f03eec65..5732560b6c 100644 --- a/vendor/knative.dev/eventing/pkg/client/informers/externalversions/generic.go +++ b/vendor/knative.dev/eventing/pkg/client/informers/externalversions/generic.go @@ -119,6 +119,8 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource // Group=sources.knative.dev, Version=v1alpha2 case v1alpha2.SchemeGroupVersion.WithResource("apiserversources"): return &genericInformer{resource: resource.GroupResource(), informer: f.Sources().V1alpha2().ApiServerSources().Informer()}, nil + case v1alpha2.SchemeGroupVersion.WithResource("containersources"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Sources().V1alpha2().ContainerSources().Informer()}, nil case v1alpha2.SchemeGroupVersion.WithResource("pingsources"): return &genericInformer{resource: resource.GroupResource(), informer: f.Sources().V1alpha2().PingSources().Informer()}, nil case v1alpha2.SchemeGroupVersion.WithResource("sinkbindings"): diff --git a/vendor/knative.dev/eventing/pkg/client/informers/externalversions/sources/v1alpha2/containersource.go b/vendor/knative.dev/eventing/pkg/client/informers/externalversions/sources/v1alpha2/containersource.go new file mode 100644 index 0000000000..0c25af1ed5 --- /dev/null +++ b/vendor/knative.dev/eventing/pkg/client/informers/externalversions/sources/v1alpha2/containersource.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 v1alpha2 + +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" + sourcesv1alpha2 "knative.dev/eventing/pkg/apis/sources/v1alpha2" + versioned "knative.dev/eventing/pkg/client/clientset/versioned" + internalinterfaces "knative.dev/eventing/pkg/client/informers/externalversions/internalinterfaces" + v1alpha2 "knative.dev/eventing/pkg/client/listers/sources/v1alpha2" +) + +// ContainerSourceInformer provides access to a shared informer and lister for +// ContainerSources. +type ContainerSourceInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1alpha2.ContainerSourceLister +} + +type containerSourceInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewContainerSourceInformer constructs a new informer for ContainerSource 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 NewContainerSourceInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredContainerSourceInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredContainerSourceInformer constructs a new informer for ContainerSource 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 NewFilteredContainerSourceInformer(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.SourcesV1alpha2().ContainerSources(namespace).List(options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.SourcesV1alpha2().ContainerSources(namespace).Watch(options) + }, + }, + &sourcesv1alpha2.ContainerSource{}, + resyncPeriod, + indexers, + ) +} + +func (f *containerSourceInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredContainerSourceInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *containerSourceInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&sourcesv1alpha2.ContainerSource{}, f.defaultInformer) +} + +func (f *containerSourceInformer) Lister() v1alpha2.ContainerSourceLister { + return v1alpha2.NewContainerSourceLister(f.Informer().GetIndexer()) +} diff --git a/vendor/knative.dev/eventing/pkg/client/informers/externalversions/sources/v1alpha2/interface.go b/vendor/knative.dev/eventing/pkg/client/informers/externalversions/sources/v1alpha2/interface.go index 33a90142ca..164586caa3 100644 --- a/vendor/knative.dev/eventing/pkg/client/informers/externalversions/sources/v1alpha2/interface.go +++ b/vendor/knative.dev/eventing/pkg/client/informers/externalversions/sources/v1alpha2/interface.go @@ -26,6 +26,8 @@ import ( type Interface interface { // ApiServerSources returns a ApiServerSourceInformer. ApiServerSources() ApiServerSourceInformer + // ContainerSources returns a ContainerSourceInformer. + ContainerSources() ContainerSourceInformer // PingSources returns a PingSourceInformer. PingSources() PingSourceInformer // SinkBindings returns a SinkBindingInformer. @@ -48,6 +50,11 @@ func (v *version) ApiServerSources() ApiServerSourceInformer { return &apiServerSourceInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} } +// ContainerSources returns a ContainerSourceInformer. +func (v *version) ContainerSources() ContainerSourceInformer { + return &containerSourceInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + // PingSources returns a PingSourceInformer. func (v *version) PingSources() PingSourceInformer { return &pingSourceInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} diff --git a/vendor/knative.dev/eventing/pkg/client/listers/sources/v1alpha2/containersource.go b/vendor/knative.dev/eventing/pkg/client/listers/sources/v1alpha2/containersource.go new file mode 100644 index 0000000000..df3ef81142 --- /dev/null +++ b/vendor/knative.dev/eventing/pkg/client/listers/sources/v1alpha2/containersource.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 v1alpha2 + +import ( + "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/labels" + "k8s.io/client-go/tools/cache" + v1alpha2 "knative.dev/eventing/pkg/apis/sources/v1alpha2" +) + +// ContainerSourceLister helps list ContainerSources. +type ContainerSourceLister interface { + // List lists all ContainerSources in the indexer. + List(selector labels.Selector) (ret []*v1alpha2.ContainerSource, err error) + // ContainerSources returns an object that can list and get ContainerSources. + ContainerSources(namespace string) ContainerSourceNamespaceLister + ContainerSourceListerExpansion +} + +// containerSourceLister implements the ContainerSourceLister interface. +type containerSourceLister struct { + indexer cache.Indexer +} + +// NewContainerSourceLister returns a new ContainerSourceLister. +func NewContainerSourceLister(indexer cache.Indexer) ContainerSourceLister { + return &containerSourceLister{indexer: indexer} +} + +// List lists all ContainerSources in the indexer. +func (s *containerSourceLister) List(selector labels.Selector) (ret []*v1alpha2.ContainerSource, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha2.ContainerSource)) + }) + return ret, err +} + +// ContainerSources returns an object that can list and get ContainerSources. +func (s *containerSourceLister) ContainerSources(namespace string) ContainerSourceNamespaceLister { + return containerSourceNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// ContainerSourceNamespaceLister helps list and get ContainerSources. +type ContainerSourceNamespaceLister interface { + // List lists all ContainerSources in the indexer for a given namespace. + List(selector labels.Selector) (ret []*v1alpha2.ContainerSource, err error) + // Get retrieves the ContainerSource from the indexer for a given namespace and name. + Get(name string) (*v1alpha2.ContainerSource, error) + ContainerSourceNamespaceListerExpansion +} + +// containerSourceNamespaceLister implements the ContainerSourceNamespaceLister +// interface. +type containerSourceNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all ContainerSources in the indexer for a given namespace. +func (s containerSourceNamespaceLister) List(selector labels.Selector) (ret []*v1alpha2.ContainerSource, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1alpha2.ContainerSource)) + }) + return ret, err +} + +// Get retrieves the ContainerSource from the indexer for a given namespace and name. +func (s containerSourceNamespaceLister) Get(name string) (*v1alpha2.ContainerSource, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1alpha2.Resource("containersource"), name) + } + return obj.(*v1alpha2.ContainerSource), nil +} diff --git a/vendor/knative.dev/eventing/pkg/client/listers/sources/v1alpha2/expansion_generated.go b/vendor/knative.dev/eventing/pkg/client/listers/sources/v1alpha2/expansion_generated.go index 59db08d0ca..41255a85f6 100644 --- a/vendor/knative.dev/eventing/pkg/client/listers/sources/v1alpha2/expansion_generated.go +++ b/vendor/knative.dev/eventing/pkg/client/listers/sources/v1alpha2/expansion_generated.go @@ -26,6 +26,14 @@ type ApiServerSourceListerExpansion interface{} // ApiServerSourceNamespaceLister. type ApiServerSourceNamespaceListerExpansion interface{} +// ContainerSourceListerExpansion allows custom methods to be added to +// ContainerSourceLister. +type ContainerSourceListerExpansion interface{} + +// ContainerSourceNamespaceListerExpansion allows custom methods to be added to +// ContainerSourceNamespaceLister. +type ContainerSourceNamespaceListerExpansion interface{} + // PingSourceListerExpansion allows custom methods to be added to // PingSourceLister. type PingSourceListerExpansion interface{} diff --git a/vendor/knative.dev/eventing/pkg/reconciler/testing/containersource.go b/vendor/knative.dev/eventing/pkg/reconciler/testing/containersource.go new file mode 100644 index 0000000000..ebbbd7fce6 --- /dev/null +++ b/vendor/knative.dev/eventing/pkg/reconciler/testing/containersource.go @@ -0,0 +1,103 @@ +/* +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 testing + +import ( + "context" + "time" + + appsv1 "k8s.io/api/apps/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/types" + sourcesv1alpha2 "knative.dev/eventing/pkg/apis/sources/v1alpha2" +) + +// ContainerSourceOption enables further configuration of a ContainerSource. +type ContainerSourceOption func(*sourcesv1alpha2.ContainerSource) + +// NewContainerSource creates a ContainerSource with ContainerSourceOptions +func NewContainerSource(name, namespace string, o ...ContainerSourceOption) *sourcesv1alpha2.ContainerSource { + c := &sourcesv1alpha2.ContainerSource{ + ObjectMeta: metav1.ObjectMeta{ + Name: name, + Namespace: namespace, + }, + } + for _, opt := range o { + opt(c) + } + c.SetDefaults(context.Background()) + return c +} + +func WithContainerSourceUID(uid types.UID) ContainerSourceOption { + return func(s *sourcesv1alpha2.ContainerSource) { + s.UID = uid + } +} + +// WithInitContainerSourceConditions initializes the ContainerSource's conditions. +func WithInitContainerSourceConditions(s *sourcesv1alpha2.ContainerSource) { + s.Status.InitializeConditions() +} + +func WithContainerSourcePropagateReceiveAdapterStatus(d *appsv1.Deployment) ContainerSourceOption { + return func(s *sourcesv1alpha2.ContainerSource) { + s.Status.PropagateReceiveAdapterStatus(d) + } +} + +func WithContainerSourcePropagateSinkbindingStatus(status *sourcesv1alpha2.SinkBindingStatus) ContainerSourceOption { + return func(s *sourcesv1alpha2.ContainerSource) { + s.Status.PropagateSinkBindingStatus(status) + } +} + +func WithContainerSourceDeleted(c *sourcesv1alpha2.ContainerSource) { + t := metav1.NewTime(time.Unix(1e9, 0)) + c.ObjectMeta.SetDeletionTimestamp(&t) +} + +func WithContainerSourceSpec(spec sourcesv1alpha2.ContainerSourceSpec) ContainerSourceOption { + return func(c *sourcesv1alpha2.ContainerSource) { + c.Spec = spec + } +} + +func WithContainerSourceLabels(labels map[string]string) ContainerSourceOption { + return func(c *sourcesv1alpha2.ContainerSource) { + c.Labels = labels + } +} + +func WithContainerSourceAnnotations(annotations map[string]string) ContainerSourceOption { + return func(c *sourcesv1alpha2.ContainerSource) { + c.Annotations = annotations + } +} + +func WithContainerSourceStatusObservedGeneration(generation int64) ContainerSourceOption { + return func(c *sourcesv1alpha2.ContainerSource) { + c.Status.ObservedGeneration = generation + } +} + +func WithContainerSourceObjectMetaGeneration(generation int64) ContainerSourceOption { + return func(c *sourcesv1alpha2.ContainerSource) { + c.ObjectMeta.Generation = generation + } +} diff --git a/vendor/knative.dev/eventing/pkg/reconciler/testing/listers.go b/vendor/knative.dev/eventing/pkg/reconciler/testing/listers.go index 3365e97c6f..f56ddda4b9 100644 --- a/vendor/knative.dev/eventing/pkg/reconciler/testing/listers.go +++ b/vendor/knative.dev/eventing/pkg/reconciler/testing/listers.go @@ -164,10 +164,22 @@ func (l *Listers) GetPingSourceLister() sourcelisters.PingSourceLister { return sourcelisters.NewPingSourceLister(l.indexerFor(&sourcesv1alpha1.PingSource{})) } +func (l *Listers) GetSinkBindingLister() sourcelisters.SinkBindingLister { + return sourcelisters.NewSinkBindingLister(l.indexerFor(&sourcesv1alpha1.SinkBinding{})) +} + func (l *Listers) GetPingSourceV1alpha2Lister() sourcev1alpha2listers.PingSourceLister { return sourcev1alpha2listers.NewPingSourceLister(l.indexerFor(&sourcesv1alpha2.PingSource{})) } +func (l *Listers) GetContainerSourceLister() sourcev1alpha2listers.ContainerSourceLister { + return sourcev1alpha2listers.NewContainerSourceLister(l.indexerFor(&sourcesv1alpha2.ContainerSource{})) +} + +func (l *Listers) GetSinkBindingV1alpha2Lister() sourcev1alpha2listers.SinkBindingLister { + return sourcev1alpha2listers.NewSinkBindingLister(l.indexerFor(&sourcesv1alpha2.SinkBinding{})) +} + func (l *Listers) GetDeploymentLister() appsv1listers.DeploymentLister { return appsv1listers.NewDeploymentLister(l.indexerFor(&appsv1.Deployment{})) } diff --git a/vendor/knative.dev/eventing/pkg/reconciler/testing/pingsource.go b/vendor/knative.dev/eventing/pkg/reconciler/testing/pingsource.go index 61bdb45091..e3aacf5bd7 100644 --- a/vendor/knative.dev/eventing/pkg/reconciler/testing/pingsource.go +++ b/vendor/knative.dev/eventing/pkg/reconciler/testing/pingsource.go @@ -210,3 +210,14 @@ func WithPingSourceObjectMetaGeneration(generation int64) PingSourceOption { c.ObjectMeta.Generation = generation } } + +func WithPingSourceV1A2Finalizers(finalizers ...string) PingSourceV1A2Option { + return func(c *v1alpha2.PingSource) { + c.Finalizers = finalizers + } +} + +func WithPingSourceV1A2Deleted(c *v1alpha2.PingSource) { + t := metav1.NewTime(time.Unix(1e9, 0)) + c.SetDeletionTimestamp(&t) +} diff --git a/vendor/knative.dev/eventing/test/e2e-common.sh b/vendor/knative.dev/eventing/test/e2e-common.sh index 5926c329ae..435af1110c 100755 --- a/vendor/knative.dev/eventing/test/e2e-common.sh +++ b/vendor/knative.dev/eventing/test/e2e-common.sh @@ -37,7 +37,7 @@ readonly IN_MEMORY_CHANNEL_CRD_CONFIG_DIR="config/channels/in-memory-channel" readonly MT_CHANNEL_BASED_BROKER_CONFIG_DIR="config/brokers/mt-channel-broker" # Channel Based Broker Controller. -readonly CHANNEL_BASED_BROKER_CONTROLLER="config/500-broker-controller.yaml" +readonly CHANNEL_BASED_BROKER_CONTROLLER="config/brokers/channel-broker" # Setup the Knative environment for running tests. This installs # Everything from the config dir but then removes the Channel Based Broker. @@ -48,10 +48,6 @@ function knative_setup() { echo "Installing Knative Eventing" ko apply --strict -f ${EVENTING_CONFIG} || return 1 - # Remove the Channel Based Broker so it will not interfere with other tests later - echo "Uninstalling Channel Based Broker Controller" - uninstall_broker || fail_test "Could not uninstall Channel Based Broker" - wait_until_pods_running knative-eventing || fail_test "Knative Eventing did not come up" echo "Installing Knative Monitoring" @@ -60,6 +56,7 @@ function knative_setup() { function install_broker() { ko apply --strict -f ${CHANNEL_BASED_BROKER_CONTROLLER} || return 1 + wait_until_pods_running knative-eventing || fail_test "Knative Eventing with Broker did not come up" } function install_mt_broker() { diff --git a/vendor/knative.dev/eventing/test/e2e-tests.sh b/vendor/knative.dev/eventing/test/e2e-tests.sh index 1494239d78..8b840ebcf8 100755 --- a/vendor/knative.dev/eventing/test/e2e-tests.sh +++ b/vendor/knative.dev/eventing/test/e2e-tests.sh @@ -30,15 +30,11 @@ source $(dirname $0)/e2e-common.sh initialize $@ --skip-istio-addon -# TODO: https://github.com/knative/eventing/issues/2808 install_broker || fail_test "Could not install Channel Based Broker" echo "Running tests with Channel Based Broker" go_test_e2e -timeout=20m -parallel=12 ./test/e2e ./test/conformance -brokerclass=ChannelBasedBroker -channels=messaging.knative.dev/v1alpha1:InMemoryChannel,messaging.knative.dev/v1alpha1:Channel,messaging.knative.dev/v1beta1:InMemoryChannel || fail_test -# TODO: https://github.com/knative/eventing/issues/2808 -# This only uninstalls the controller, better would be to uninstall the CRDs -# and everything. But for tests this is fine for now. uninstall_broker || fail_test "Could not uninstall Channel Based Broker" install_mt_broker || fail_test "Could not uninstall MT Channel Based Broker" diff --git a/vendor/knative.dev/eventing/test/lib/creation.go b/vendor/knative.dev/eventing/test/lib/creation.go index 57612ad689..c3c8cd7d1c 100644 --- a/vendor/knative.dev/eventing/test/lib/creation.go +++ b/vendor/knative.dev/eventing/test/lib/creation.go @@ -301,6 +301,17 @@ func (client *Client) CreateApiServerSourceOrFail(apiServerSource *sourcesv1alph client.Tracker.AddObj(apiServerSource) } +// CreateContainerSourceV1Alpha2OrFail will create a ContainerSource. +func (client *Client) CreateContainerSourceV1Alpha2OrFail(containerSource *sourcesv1alpha2.ContainerSource) { + client.T.Logf("Creating containersource %+v", containerSource) + containerInterface := client.Eventing.SourcesV1alpha2().ContainerSources(client.Namespace) + _, err := containerInterface.Create(containerSource) + if err != nil { + client.T.Fatalf("Failed to create containersource %q: %v", containerSource.Name, err) + } + client.Tracker.AddObj(containerSource) +} + // CreatePingSourceV1Alpha1OrFail will create an PingSource func (client *Client) CreatePingSourceV1Alpha1OrFail(pingSource *sourcesv1alpha1.PingSource) { client.T.Logf("Creating pingsource %+v", pingSource) diff --git a/vendor/knative.dev/serving/pkg/apis/config/defaults.go b/vendor/knative.dev/serving/pkg/apis/config/defaults.go index 50a54488e0..6c9358a6a7 100644 --- a/vendor/knative.dev/serving/pkg/apis/config/defaults.go +++ b/vendor/knative.dev/serving/pkg/apis/config/defaults.go @@ -90,11 +90,11 @@ func NewDefaultsConfigFromMap(data map[string]string) (*Defaults, error) { field: &nc.ContainerConcurrencyMaxLimit, }} { if raw, ok := data[i64.key]; ok { - if val, err := strconv.ParseInt(raw, 10, 64); err != nil { + val, err := strconv.ParseInt(raw, 10, 64) + if err != nil { return nil, err - } else { - *i64.field = val } + *i64.field = val } }