From 65fddd58444e9e2438a94bd9f1a50f05b267783d Mon Sep 17 00:00:00 2001 From: Ville Aikas Date: Wed, 15 Jan 2020 20:19:52 -0800 Subject: [PATCH 1/7] add parallel/sequence types --- hack/update-codegen.sh | 4 +- pkg/apis/flows/v1beta1/doc.go | 20 + pkg/apis/flows/v1beta1/parallel_types.go | 162 ++++++++ pkg/apis/flows/v1beta1/register.go | 55 +++ pkg/apis/flows/v1beta1/sequence_types.go | 138 +++++++ .../flows/v1beta1/zz_generated.deepcopy.go | 391 ++++++++++++++++++ 6 files changed, 768 insertions(+), 2 deletions(-) create mode 100644 pkg/apis/flows/v1beta1/doc.go create mode 100644 pkg/apis/flows/v1beta1/parallel_types.go create mode 100644 pkg/apis/flows/v1beta1/register.go create mode 100644 pkg/apis/flows/v1beta1/sequence_types.go create mode 100644 pkg/apis/flows/v1beta1/zz_generated.deepcopy.go diff --git a/hack/update-codegen.sh b/hack/update-codegen.sh index b6f57248a20..7c09af61363 100755 --- a/hack/update-codegen.sh +++ b/hack/update-codegen.sh @@ -30,7 +30,7 @@ KNATIVE_CODEGEN_PKG=${KNATIVE_CODEGEN_PKG:-$(cd ${REPO_ROOT_DIR}; ls -d -1 $(dir # instead of the $GOPATH directly. For normal projects this can be dropped. ${CODEGEN_PKG}/generate-groups.sh "deepcopy,client,informer,lister" \ knative.dev/eventing/pkg/client knative.dev/eventing/pkg/apis \ - "eventing:v1alpha1 messaging:v1alpha1 messaging:v1beta1 flows:v1alpha1 sources:v1alpha1" \ + "eventing:v1alpha1 messaging:v1alpha1 messaging:v1beta1 flows:v1alpha1 flows:v1beta1 sources:v1alpha1" \ --go-header-file ${REPO_ROOT_DIR}/hack/boilerplate/boilerplate.go.txt # TODO(#2312): Remove this after v0.13. @@ -48,7 +48,7 @@ ${CODEGEN_PKG}/generate-groups.sh "deepcopy" \ # Knative Injection ${KNATIVE_CODEGEN_PKG}/hack/generate-knative.sh "injection" \ knative.dev/eventing/pkg/client knative.dev/eventing/pkg/apis \ - "eventing:v1alpha1 messaging:v1alpha1 messaging:v1beta1 flows:v1alpha1 sources:v1alpha1 duck:v1alpha1 duck:v1beta1" \ + "eventing:v1alpha1 messaging:v1alpha1 messaging:v1beta1 flows:v1alpha1 flows:v1beta1 sources:v1alpha1 duck:v1alpha1 duck:v1beta1" \ --go-header-file ${REPO_ROOT_DIR}/hack/boilerplate/boilerplate.go.txt # TODO(#2312): Remove this after v0.13. diff --git a/pkg/apis/flows/v1beta1/doc.go b/pkg/apis/flows/v1beta1/doc.go new file mode 100644 index 00000000000..4b77f180564 --- /dev/null +++ b/pkg/apis/flows/v1beta1/doc.go @@ -0,0 +1,20 @@ +/* +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 is the v1beta1 version of the API. +// +k8s:deepcopy-gen=package +// +groupName=flows.knative.dev +package v1beta1 diff --git a/pkg/apis/flows/v1beta1/parallel_types.go b/pkg/apis/flows/v1beta1/parallel_types.go new file mode 100644 index 00000000000..5cb66da3732 --- /dev/null +++ b/pkg/apis/flows/v1beta1/parallel_types.go @@ -0,0 +1,162 @@ +/* + * 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 ( + 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" + + // DO NOT SUBMIT. Change to v1beta1 before merge + eventingduckv1alpha1 "knative.dev/eventing/pkg/apis/duck/v1alpha1" + "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 +// Parallel defines conditional branches that will be wired in +// series through Channels and Subscriptions. +type Parallel struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + + // Spec defines the desired state of the Parallel. + Spec ParallelSpec `json:"spec,omitempty"` + + // Status represents the current state of the Parallel. This data may be out of + // date. + // +optional + Status ParallelStatus `json:"status,omitempty"` +} + +var ( + // Check that Parallel can be validated and defaulted. + _ apis.Validatable = (*Parallel)(nil) + _ apis.Defaultable = (*Parallel)(nil) + + // Check that Parallel can return its spec untyped. + _ apis.HasSpec = (*Parallel)(nil) + + // TODO: make appropriate fields immutable. + //_ apis.Immutable = (*Parallel)(nil) + + _ runtime.Object = (*Parallel)(nil) + + // Check that we can create OwnerReferences to a Parallel. + _ kmeta.OwnerRefable = (*Parallel)(nil) +) + +type ParallelSpec struct { + // Branches is the list of Filter/Subscribers pairs. + Branches []ParallelBranch `json:"branches"` + + // ChannelTemplate specifies which Channel CRD to use. If left unspecified, it is set to the default Channel CRD + // for the namespace (or cluster, in case there are no defaults for the namespace). + // +optional + // DO NOT SUBMIT. Change to v1beta1 before merge + ChannelTemplate *eventingduckv1alpha1.ChannelTemplateSpec `json:"channelTemplate"` + + // Reply is a Reference to where the result of a case Subscriber gets sent to + // when the case does not have a Reply + // +optional + Reply *duckv1.Destination `json:"reply,omitempty"` +} + +type ParallelBranch struct { + // Filter is the expression guarding the branch + Filter *duckv1.Destination `json:"filter,omitempty"` + + // Subscriber receiving the event when the filter passes + Subscriber duckv1.Destination `json:"subscriber"` + + // Reply is a Reference to where the result of Subscriber of this case gets sent to. + // If not specified, sent the result to the Parallel Reply + // +optional + Reply *duckv1.Destination `json:"reply,omitempty"` +} + +// ParallelStatus represents the current state of a Parallel. +type ParallelStatus 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"` + + // IngressChannelStatus corresponds to the ingress channel status. + IngressChannelStatus ParallelChannelStatus `json:"ingressChannelStatus"` + + // BranchStatuses is an array of corresponding to branch statuses. + // Matches the Spec.Branches array in the order. + BranchStatuses []ParallelBranchStatus `json:"branchStatuses"` + + // AddressStatus is the starting point to this Parallel. Sending to this + // will target the first subscriber. + // It generally has the form {channel}.{namespace}.svc.{cluster domain name} + duckv1.AddressStatus `json:",inline"` +} + +// ParallelBranchStatus represents the current state of a Parallel branch +type ParallelBranchStatus struct { + // FilterSubscriptionStatus corresponds to the filter subscription status. + FilterSubscriptionStatus ParallelSubscriptionStatus `json:"filterSubscriptionStatus"` + + // FilterChannelStatus corresponds to the filter channel status. + FilterChannelStatus ParallelChannelStatus `json:"filterChannelStatus"` + + // SubscriptionStatus corresponds to the subscriber subscription status. + SubscriptionStatus ParallelSubscriptionStatus `json:"subscriberSubscriptionStatus"` +} + +type ParallelChannelStatus struct { + // Channel is the reference to the underlying channel. + Channel corev1.ObjectReference `json:"channel"` + + // ReadyCondition indicates whether the Channel is ready or not. + ReadyCondition apis.Condition `json:"ready"` +} + +type ParallelSubscriptionStatus struct { + // Subscription is the reference to the underlying Subscription. + Subscription corev1.ObjectReference `json:"subscription"` + + // ReadyCondition indicates whether the Subscription is ready or not. + ReadyCondition apis.Condition `json:"ready"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// ParallelList is a collection of Parallels. +type ParallelList struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ListMeta `json:"metadata,omitempty"` + Items []Parallel `json:"items"` +} + +// GetGroupVersionKind returns GroupVersionKind for Parallel +func (p *Parallel) GetGroupVersionKind() schema.GroupVersionKind { + return SchemeGroupVersion.WithKind("Parallel") +} + +// GetUntypedSpec returns the spec of the Parallel. +func (p *Parallel) GetUntypedSpec() interface{} { + return p.Spec +} diff --git a/pkg/apis/flows/v1beta1/register.go b/pkg/apis/flows/v1beta1/register.go new file mode 100644 index 00000000000..8d46f4fb470 --- /dev/null +++ b/pkg/apis/flows/v1beta1/register.go @@ -0,0 +1,55 @@ +/* +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 ( + "knative.dev/eventing/pkg/apis/flows" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +// SchemeGroupVersion is group version used to register these objects +var SchemeGroupVersion = schema.GroupVersion{Group: flows.GroupName, Version: "v1beta1"} + +// Kind takes an unqualified kind and returns back a Group qualified GroupKind +func Kind(kind string) schema.GroupKind { + return SchemeGroupVersion.WithKind(kind).GroupKind() +} + +// Resource takes an unqualified resource and returns a Group qualified GroupResource +func Resource(resource string) schema.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + +var ( + SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) + AddToScheme = SchemeBuilder.AddToScheme +) + +// Adds the list of known types to Scheme. +func addKnownTypes(scheme *runtime.Scheme) error { + scheme.AddKnownTypes(SchemeGroupVersion, + &Sequence{}, + &SequenceList{}, + &Parallel{}, + &ParallelList{}, + ) + metav1.AddToGroupVersion(scheme, SchemeGroupVersion) + return nil +} diff --git a/pkg/apis/flows/v1beta1/sequence_types.go b/pkg/apis/flows/v1beta1/sequence_types.go new file mode 100644 index 00000000000..8a3bf32f2f3 --- /dev/null +++ b/pkg/apis/flows/v1beta1/sequence_types.go @@ -0,0 +1,138 @@ +/* + * 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 ( + 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" + + // DO NOT SUBMIT. Change to v1beta1 before merge + eventingduckv1alpha1 "knative.dev/eventing/pkg/apis/duck/v1alpha1" + "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 +// Sequence defines a sequence of Subscribers that will be wired in +// series through Channels and Subscriptions. +type Sequence struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ObjectMeta `json:"metadata,omitempty"` + + // Spec defines the desired state of the Sequence. + Spec SequenceSpec `json:"spec,omitempty"` + + // Status represents the current state of the Sequence. This data may be out of + // date. + // +optional + Status SequenceStatus `json:"status,omitempty"` +} + +var ( + // Check that Sequence can be validated and defaulted. + _ apis.Validatable = (*Sequence)(nil) + _ apis.Defaultable = (*Sequence)(nil) + + // Check that Sequence can return its spec untyped. + _ apis.HasSpec = (*Sequence)(nil) + + // TODO: make appropriate fields immutable. + //_ apis.Immutable = (*Sequence)(nil) + + _ runtime.Object = (*Sequence)(nil) + + // Check that we can create OwnerReferences to a Sequence. + _ kmeta.OwnerRefable = (*Sequence)(nil) +) + +type SequenceSpec struct { + // Steps is the list of Destinations (processors / functions) that will be called in the order + // provided. + Steps []duckv1.Destination `json:"steps"` + + // ChannelTemplate specifies which Channel CRD to use. If left unspecified, it is set to the default Channel CRD + // for the namespace (or cluster, in case there are no defaults for the namespace). + // +optional + // DO NOT SUBMIT. Change to v1beta1 before merge + ChannelTemplate *eventingduckv1alpha1.ChannelTemplateSpec `json:"channelTemplate,omitempty"` + + // Reply is a Reference to where the result of the last Subscriber gets sent to. + // +optional + Reply *duckv1.Destination `json:"reply,omitempty"` +} + +type SequenceChannelStatus struct { + // Channel is the reference to the underlying channel. + Channel corev1.ObjectReference `json:"channel"` + + // ReadyCondition indicates whether the Channel is ready or not. + ReadyCondition apis.Condition `json:"ready"` +} + +type SequenceSubscriptionStatus struct { + // Subscription is the reference to the underlying Subscription. + Subscription corev1.ObjectReference `json:"subscription"` + + // ReadyCondition indicates whether the Subscription is ready or not. + ReadyCondition apis.Condition `json:"ready"` +} + +// SequenceStatus represents the current state of a Sequence. +type SequenceStatus 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"` + + // SubscriptionStatuses is an array of corresponding Subscription statuses. + // Matches the Spec.Steps array in the order. + SubscriptionStatuses []SequenceSubscriptionStatus `json:"subscriptionStatuses"` + + // ChannelStatuses is an array of corresponding Channel statuses. + // Matches the Spec.Steps array in the order. + ChannelStatuses []SequenceChannelStatus `json:"channelStatuses"` + + // AddressStatus is the starting point to this Sequence. Sending to this + // will target the first subscriber. + // It generally has the form {channel}.{namespace}.svc.{cluster domain name} + duckv1.AddressStatus `json:",inline"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// SequenceList is a collection of Sequences. +type SequenceList struct { + metav1.TypeMeta `json:",inline"` + // +optional + metav1.ListMeta `json:"metadata,omitempty"` + Items []Sequence `json:"items"` +} + +// GetGroupVersionKind returns GroupVersionKind for InMemoryChannels +func (p *Sequence) GetGroupVersionKind() schema.GroupVersionKind { + return SchemeGroupVersion.WithKind("Sequence") +} + +// GetUntypedSpec returns the spec of the Sequence. +func (s *Sequence) GetUntypedSpec() interface{} { + return s.Spec +} diff --git a/pkg/apis/flows/v1beta1/zz_generated.deepcopy.go b/pkg/apis/flows/v1beta1/zz_generated.deepcopy.go new file mode 100644 index 00000000000..8b958cb7b36 --- /dev/null +++ b/pkg/apis/flows/v1beta1/zz_generated.deepcopy.go @@ -0,0 +1,391 @@ +// +build !ignore_autogenerated + +/* +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 deepcopy-gen. DO NOT EDIT. + +package v1beta1 + +import ( + runtime "k8s.io/apimachinery/pkg/runtime" + v1alpha1 "knative.dev/eventing/pkg/apis/duck/v1alpha1" + v1 "knative.dev/pkg/apis/duck/v1" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Parallel) DeepCopyInto(out *Parallel) { + *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 Parallel. +func (in *Parallel) DeepCopy() *Parallel { + if in == nil { + return nil + } + out := new(Parallel) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Parallel) 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 *ParallelBranch) DeepCopyInto(out *ParallelBranch) { + *out = *in + if in.Filter != nil { + in, out := &in.Filter, &out.Filter + *out = new(v1.Destination) + (*in).DeepCopyInto(*out) + } + in.Subscriber.DeepCopyInto(&out.Subscriber) + if in.Reply != nil { + in, out := &in.Reply, &out.Reply + *out = new(v1.Destination) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ParallelBranch. +func (in *ParallelBranch) DeepCopy() *ParallelBranch { + if in == nil { + return nil + } + out := new(ParallelBranch) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ParallelBranchStatus) DeepCopyInto(out *ParallelBranchStatus) { + *out = *in + in.FilterSubscriptionStatus.DeepCopyInto(&out.FilterSubscriptionStatus) + in.FilterChannelStatus.DeepCopyInto(&out.FilterChannelStatus) + in.SubscriptionStatus.DeepCopyInto(&out.SubscriptionStatus) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ParallelBranchStatus. +func (in *ParallelBranchStatus) DeepCopy() *ParallelBranchStatus { + if in == nil { + return nil + } + out := new(ParallelBranchStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ParallelChannelStatus) DeepCopyInto(out *ParallelChannelStatus) { + *out = *in + out.Channel = in.Channel + in.ReadyCondition.DeepCopyInto(&out.ReadyCondition) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ParallelChannelStatus. +func (in *ParallelChannelStatus) DeepCopy() *ParallelChannelStatus { + if in == nil { + return nil + } + out := new(ParallelChannelStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ParallelList) DeepCopyInto(out *ParallelList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Parallel, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ParallelList. +func (in *ParallelList) DeepCopy() *ParallelList { + if in == nil { + return nil + } + out := new(ParallelList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ParallelList) 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 *ParallelSpec) DeepCopyInto(out *ParallelSpec) { + *out = *in + if in.Branches != nil { + in, out := &in.Branches, &out.Branches + *out = make([]ParallelBranch, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.ChannelTemplate != nil { + in, out := &in.ChannelTemplate, &out.ChannelTemplate + *out = new(v1alpha1.ChannelTemplateSpec) + (*in).DeepCopyInto(*out) + } + if in.Reply != nil { + in, out := &in.Reply, &out.Reply + *out = new(v1.Destination) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ParallelSpec. +func (in *ParallelSpec) DeepCopy() *ParallelSpec { + if in == nil { + return nil + } + out := new(ParallelSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ParallelStatus) DeepCopyInto(out *ParallelStatus) { + *out = *in + in.Status.DeepCopyInto(&out.Status) + in.IngressChannelStatus.DeepCopyInto(&out.IngressChannelStatus) + if in.BranchStatuses != nil { + in, out := &in.BranchStatuses, &out.BranchStatuses + *out = make([]ParallelBranchStatus, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + in.AddressStatus.DeepCopyInto(&out.AddressStatus) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ParallelStatus. +func (in *ParallelStatus) DeepCopy() *ParallelStatus { + if in == nil { + return nil + } + out := new(ParallelStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ParallelSubscriptionStatus) DeepCopyInto(out *ParallelSubscriptionStatus) { + *out = *in + out.Subscription = in.Subscription + in.ReadyCondition.DeepCopyInto(&out.ReadyCondition) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ParallelSubscriptionStatus. +func (in *ParallelSubscriptionStatus) DeepCopy() *ParallelSubscriptionStatus { + if in == nil { + return nil + } + out := new(ParallelSubscriptionStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Sequence) DeepCopyInto(out *Sequence) { + *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 Sequence. +func (in *Sequence) DeepCopy() *Sequence { + if in == nil { + return nil + } + out := new(Sequence) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Sequence) 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 *SequenceChannelStatus) DeepCopyInto(out *SequenceChannelStatus) { + *out = *in + out.Channel = in.Channel + in.ReadyCondition.DeepCopyInto(&out.ReadyCondition) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SequenceChannelStatus. +func (in *SequenceChannelStatus) DeepCopy() *SequenceChannelStatus { + if in == nil { + return nil + } + out := new(SequenceChannelStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SequenceList) DeepCopyInto(out *SequenceList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Sequence, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SequenceList. +func (in *SequenceList) DeepCopy() *SequenceList { + if in == nil { + return nil + } + out := new(SequenceList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *SequenceList) 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 *SequenceSpec) DeepCopyInto(out *SequenceSpec) { + *out = *in + if in.Steps != nil { + in, out := &in.Steps, &out.Steps + *out = make([]v1.Destination, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.ChannelTemplate != nil { + in, out := &in.ChannelTemplate, &out.ChannelTemplate + *out = new(v1alpha1.ChannelTemplateSpec) + (*in).DeepCopyInto(*out) + } + if in.Reply != nil { + in, out := &in.Reply, &out.Reply + *out = new(v1.Destination) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SequenceSpec. +func (in *SequenceSpec) DeepCopy() *SequenceSpec { + if in == nil { + return nil + } + out := new(SequenceSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SequenceStatus) DeepCopyInto(out *SequenceStatus) { + *out = *in + in.Status.DeepCopyInto(&out.Status) + if in.SubscriptionStatuses != nil { + in, out := &in.SubscriptionStatuses, &out.SubscriptionStatuses + *out = make([]SequenceSubscriptionStatus, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.ChannelStatuses != nil { + in, out := &in.ChannelStatuses, &out.ChannelStatuses + *out = make([]SequenceChannelStatus, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + in.AddressStatus.DeepCopyInto(&out.AddressStatus) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SequenceStatus. +func (in *SequenceStatus) DeepCopy() *SequenceStatus { + if in == nil { + return nil + } + out := new(SequenceStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SequenceSubscriptionStatus) DeepCopyInto(out *SequenceSubscriptionStatus) { + *out = *in + out.Subscription = in.Subscription + in.ReadyCondition.DeepCopyInto(&out.ReadyCondition) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SequenceSubscriptionStatus. +func (in *SequenceSubscriptionStatus) DeepCopy() *SequenceSubscriptionStatus { + if in == nil { + return nil + } + out := new(SequenceSubscriptionStatus) + in.DeepCopyInto(out) + return out +} From df77eeaa6014ce5518766ccde0fbe17f180ba35e Mon Sep 17 00:00:00 2001 From: Ville Aikas Date: Wed, 15 Jan 2020 20:20:19 -0800 Subject: [PATCH 2/7] codegen for parallel/sequence --- pkg/client/clientset/versioned/clientset.go | 14 ++ .../versioned/fake/clientset_generated.go | 7 + .../clientset/versioned/fake/register.go | 2 + .../clientset/versioned/scheme/register.go | 2 + .../versioned/typed/flows/v1beta1/doc.go | 20 ++ .../versioned/typed/flows/v1beta1/fake/doc.go | 20 ++ .../flows/v1beta1/fake/fake_flows_client.go | 44 ++++ .../typed/flows/v1beta1/fake/fake_parallel.go | 140 +++++++++++++ .../typed/flows/v1beta1/fake/fake_sequence.go | 140 +++++++++++++ .../typed/flows/v1beta1/flows_client.go | 94 +++++++++ .../flows/v1beta1/generated_expansion.go | 23 +++ .../versioned/typed/flows/v1beta1/parallel.go | 191 ++++++++++++++++++ .../versioned/typed/flows/v1beta1/sequence.go | 191 ++++++++++++++++++ .../externalversions/flows/interface.go | 8 + .../flows/v1beta1/interface.go | 52 +++++ .../flows/v1beta1/parallel.go | 89 ++++++++ .../flows/v1beta1/sequence.go | 89 ++++++++ .../informers/externalversions/generic.go | 7 + .../flows/v1beta1/parallel/fake/fake.go | 40 ++++ .../flows/v1beta1/parallel/parallel.go | 52 +++++ .../flows/v1beta1/sequence/fake/fake.go | 40 ++++ .../flows/v1beta1/sequence/sequence.go | 52 +++++ .../flows/v1beta1/expansion_generated.go | 35 ++++ pkg/client/listers/flows/v1beta1/parallel.go | 94 +++++++++ pkg/client/listers/flows/v1beta1/sequence.go | 94 +++++++++ 25 files changed, 1540 insertions(+) create mode 100644 pkg/client/clientset/versioned/typed/flows/v1beta1/doc.go create mode 100644 pkg/client/clientset/versioned/typed/flows/v1beta1/fake/doc.go create mode 100644 pkg/client/clientset/versioned/typed/flows/v1beta1/fake/fake_flows_client.go create mode 100644 pkg/client/clientset/versioned/typed/flows/v1beta1/fake/fake_parallel.go create mode 100644 pkg/client/clientset/versioned/typed/flows/v1beta1/fake/fake_sequence.go create mode 100644 pkg/client/clientset/versioned/typed/flows/v1beta1/flows_client.go create mode 100644 pkg/client/clientset/versioned/typed/flows/v1beta1/generated_expansion.go create mode 100644 pkg/client/clientset/versioned/typed/flows/v1beta1/parallel.go create mode 100644 pkg/client/clientset/versioned/typed/flows/v1beta1/sequence.go create mode 100644 pkg/client/informers/externalversions/flows/v1beta1/interface.go create mode 100644 pkg/client/informers/externalversions/flows/v1beta1/parallel.go create mode 100644 pkg/client/informers/externalversions/flows/v1beta1/sequence.go create mode 100644 pkg/client/injection/informers/flows/v1beta1/parallel/fake/fake.go create mode 100644 pkg/client/injection/informers/flows/v1beta1/parallel/parallel.go create mode 100644 pkg/client/injection/informers/flows/v1beta1/sequence/fake/fake.go create mode 100644 pkg/client/injection/informers/flows/v1beta1/sequence/sequence.go create mode 100644 pkg/client/listers/flows/v1beta1/expansion_generated.go create mode 100644 pkg/client/listers/flows/v1beta1/parallel.go create mode 100644 pkg/client/listers/flows/v1beta1/sequence.go diff --git a/pkg/client/clientset/versioned/clientset.go b/pkg/client/clientset/versioned/clientset.go index 5f4a22a0a59..b405acda2db 100644 --- a/pkg/client/clientset/versioned/clientset.go +++ b/pkg/client/clientset/versioned/clientset.go @@ -26,6 +26,7 @@ import ( flowcontrol "k8s.io/client-go/util/flowcontrol" eventingv1alpha1 "knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1alpha1" flowsv1alpha1 "knative.dev/eventing/pkg/client/clientset/versioned/typed/flows/v1alpha1" + flowsv1beta1 "knative.dev/eventing/pkg/client/clientset/versioned/typed/flows/v1beta1" messagingv1alpha1 "knative.dev/eventing/pkg/client/clientset/versioned/typed/messaging/v1alpha1" messagingv1beta1 "knative.dev/eventing/pkg/client/clientset/versioned/typed/messaging/v1beta1" sourcesv1alpha1 "knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1" @@ -35,6 +36,7 @@ type Interface interface { Discovery() discovery.DiscoveryInterface EventingV1alpha1() eventingv1alpha1.EventingV1alpha1Interface FlowsV1alpha1() flowsv1alpha1.FlowsV1alpha1Interface + FlowsV1beta1() flowsv1beta1.FlowsV1beta1Interface MessagingV1alpha1() messagingv1alpha1.MessagingV1alpha1Interface MessagingV1beta1() messagingv1beta1.MessagingV1beta1Interface SourcesV1alpha1() sourcesv1alpha1.SourcesV1alpha1Interface @@ -46,6 +48,7 @@ type Clientset struct { *discovery.DiscoveryClient eventingV1alpha1 *eventingv1alpha1.EventingV1alpha1Client flowsV1alpha1 *flowsv1alpha1.FlowsV1alpha1Client + flowsV1beta1 *flowsv1beta1.FlowsV1beta1Client messagingV1alpha1 *messagingv1alpha1.MessagingV1alpha1Client messagingV1beta1 *messagingv1beta1.MessagingV1beta1Client sourcesV1alpha1 *sourcesv1alpha1.SourcesV1alpha1Client @@ -61,6 +64,11 @@ func (c *Clientset) FlowsV1alpha1() flowsv1alpha1.FlowsV1alpha1Interface { return c.flowsV1alpha1 } +// FlowsV1beta1 retrieves the FlowsV1beta1Client +func (c *Clientset) FlowsV1beta1() flowsv1beta1.FlowsV1beta1Interface { + return c.flowsV1beta1 +} + // MessagingV1alpha1 retrieves the MessagingV1alpha1Client func (c *Clientset) MessagingV1alpha1() messagingv1alpha1.MessagingV1alpha1Interface { return c.messagingV1alpha1 @@ -105,6 +113,10 @@ func NewForConfig(c *rest.Config) (*Clientset, error) { if err != nil { return nil, err } + cs.flowsV1beta1, err = flowsv1beta1.NewForConfig(&configShallowCopy) + if err != nil { + return nil, err + } cs.messagingV1alpha1, err = messagingv1alpha1.NewForConfig(&configShallowCopy) if err != nil { return nil, err @@ -131,6 +143,7 @@ func NewForConfigOrDie(c *rest.Config) *Clientset { var cs Clientset cs.eventingV1alpha1 = eventingv1alpha1.NewForConfigOrDie(c) cs.flowsV1alpha1 = flowsv1alpha1.NewForConfigOrDie(c) + cs.flowsV1beta1 = flowsv1beta1.NewForConfigOrDie(c) cs.messagingV1alpha1 = messagingv1alpha1.NewForConfigOrDie(c) cs.messagingV1beta1 = messagingv1beta1.NewForConfigOrDie(c) cs.sourcesV1alpha1 = sourcesv1alpha1.NewForConfigOrDie(c) @@ -144,6 +157,7 @@ func New(c rest.Interface) *Clientset { var cs Clientset cs.eventingV1alpha1 = eventingv1alpha1.New(c) cs.flowsV1alpha1 = flowsv1alpha1.New(c) + cs.flowsV1beta1 = flowsv1beta1.New(c) cs.messagingV1alpha1 = messagingv1alpha1.New(c) cs.messagingV1beta1 = messagingv1beta1.New(c) cs.sourcesV1alpha1 = sourcesv1alpha1.New(c) diff --git a/pkg/client/clientset/versioned/fake/clientset_generated.go b/pkg/client/clientset/versioned/fake/clientset_generated.go index 74fa682d0fc..32851e5bbeb 100644 --- a/pkg/client/clientset/versioned/fake/clientset_generated.go +++ b/pkg/client/clientset/versioned/fake/clientset_generated.go @@ -29,6 +29,8 @@ import ( fakeeventingv1alpha1 "knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1alpha1/fake" flowsv1alpha1 "knative.dev/eventing/pkg/client/clientset/versioned/typed/flows/v1alpha1" fakeflowsv1alpha1 "knative.dev/eventing/pkg/client/clientset/versioned/typed/flows/v1alpha1/fake" + flowsv1beta1 "knative.dev/eventing/pkg/client/clientset/versioned/typed/flows/v1beta1" + fakeflowsv1beta1 "knative.dev/eventing/pkg/client/clientset/versioned/typed/flows/v1beta1/fake" messagingv1alpha1 "knative.dev/eventing/pkg/client/clientset/versioned/typed/messaging/v1alpha1" fakemessagingv1alpha1 "knative.dev/eventing/pkg/client/clientset/versioned/typed/messaging/v1alpha1/fake" messagingv1beta1 "knative.dev/eventing/pkg/client/clientset/versioned/typed/messaging/v1beta1" @@ -94,6 +96,11 @@ func (c *Clientset) FlowsV1alpha1() flowsv1alpha1.FlowsV1alpha1Interface { return &fakeflowsv1alpha1.FakeFlowsV1alpha1{Fake: &c.Fake} } +// FlowsV1beta1 retrieves the FlowsV1beta1Client +func (c *Clientset) FlowsV1beta1() flowsv1beta1.FlowsV1beta1Interface { + return &fakeflowsv1beta1.FakeFlowsV1beta1{Fake: &c.Fake} +} + // MessagingV1alpha1 retrieves the MessagingV1alpha1Client func (c *Clientset) MessagingV1alpha1() messagingv1alpha1.MessagingV1alpha1Interface { return &fakemessagingv1alpha1.FakeMessagingV1alpha1{Fake: &c.Fake} diff --git a/pkg/client/clientset/versioned/fake/register.go b/pkg/client/clientset/versioned/fake/register.go index 8bc0390bdd1..a481ad7e9d2 100644 --- a/pkg/client/clientset/versioned/fake/register.go +++ b/pkg/client/clientset/versioned/fake/register.go @@ -26,6 +26,7 @@ import ( utilruntime "k8s.io/apimachinery/pkg/util/runtime" eventingv1alpha1 "knative.dev/eventing/pkg/apis/eventing/v1alpha1" flowsv1alpha1 "knative.dev/eventing/pkg/apis/flows/v1alpha1" + flowsv1beta1 "knative.dev/eventing/pkg/apis/flows/v1beta1" messagingv1alpha1 "knative.dev/eventing/pkg/apis/messaging/v1alpha1" messagingv1beta1 "knative.dev/eventing/pkg/apis/messaging/v1beta1" sourcesv1alpha1 "knative.dev/eventing/pkg/apis/sources/v1alpha1" @@ -37,6 +38,7 @@ var parameterCodec = runtime.NewParameterCodec(scheme) var localSchemeBuilder = runtime.SchemeBuilder{ eventingv1alpha1.AddToScheme, flowsv1alpha1.AddToScheme, + flowsv1beta1.AddToScheme, messagingv1alpha1.AddToScheme, messagingv1beta1.AddToScheme, sourcesv1alpha1.AddToScheme, diff --git a/pkg/client/clientset/versioned/scheme/register.go b/pkg/client/clientset/versioned/scheme/register.go index e65a7eb6c6c..4dc64df2757 100644 --- a/pkg/client/clientset/versioned/scheme/register.go +++ b/pkg/client/clientset/versioned/scheme/register.go @@ -26,6 +26,7 @@ import ( utilruntime "k8s.io/apimachinery/pkg/util/runtime" eventingv1alpha1 "knative.dev/eventing/pkg/apis/eventing/v1alpha1" flowsv1alpha1 "knative.dev/eventing/pkg/apis/flows/v1alpha1" + flowsv1beta1 "knative.dev/eventing/pkg/apis/flows/v1beta1" messagingv1alpha1 "knative.dev/eventing/pkg/apis/messaging/v1alpha1" messagingv1beta1 "knative.dev/eventing/pkg/apis/messaging/v1beta1" sourcesv1alpha1 "knative.dev/eventing/pkg/apis/sources/v1alpha1" @@ -37,6 +38,7 @@ var ParameterCodec = runtime.NewParameterCodec(Scheme) var localSchemeBuilder = runtime.SchemeBuilder{ eventingv1alpha1.AddToScheme, flowsv1alpha1.AddToScheme, + flowsv1beta1.AddToScheme, messagingv1alpha1.AddToScheme, messagingv1beta1.AddToScheme, sourcesv1alpha1.AddToScheme, diff --git a/pkg/client/clientset/versioned/typed/flows/v1beta1/doc.go b/pkg/client/clientset/versioned/typed/flows/v1beta1/doc.go new file mode 100644 index 00000000000..b641cb37309 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/flows/v1beta1/doc.go @@ -0,0 +1,20 @@ +/* +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. + +// This package has the automatically generated typed clients. +package v1beta1 diff --git a/pkg/client/clientset/versioned/typed/flows/v1beta1/fake/doc.go b/pkg/client/clientset/versioned/typed/flows/v1beta1/fake/doc.go new file mode 100644 index 00000000000..c7f6e65cab8 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/flows/v1beta1/fake/doc.go @@ -0,0 +1,20 @@ +/* +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 has the automatically generated clients. +package fake diff --git a/pkg/client/clientset/versioned/typed/flows/v1beta1/fake/fake_flows_client.go b/pkg/client/clientset/versioned/typed/flows/v1beta1/fake/fake_flows_client.go new file mode 100644 index 00000000000..4a9af8d1318 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/flows/v1beta1/fake/fake_flows_client.go @@ -0,0 +1,44 @@ +/* +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 ( + rest "k8s.io/client-go/rest" + testing "k8s.io/client-go/testing" + v1beta1 "knative.dev/eventing/pkg/client/clientset/versioned/typed/flows/v1beta1" +) + +type FakeFlowsV1beta1 struct { + *testing.Fake +} + +func (c *FakeFlowsV1beta1) Parallels(namespace string) v1beta1.ParallelInterface { + return &FakeParallels{c, namespace} +} + +func (c *FakeFlowsV1beta1) Sequences(namespace string) v1beta1.SequenceInterface { + return &FakeSequences{c, namespace} +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FakeFlowsV1beta1) RESTClient() rest.Interface { + var ret *rest.RESTClient + return ret +} diff --git a/pkg/client/clientset/versioned/typed/flows/v1beta1/fake/fake_parallel.go b/pkg/client/clientset/versioned/typed/flows/v1beta1/fake/fake_parallel.go new file mode 100644 index 00000000000..2e8ba42ba4a --- /dev/null +++ b/pkg/client/clientset/versioned/typed/flows/v1beta1/fake/fake_parallel.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/flows/v1beta1" +) + +// FakeParallels implements ParallelInterface +type FakeParallels struct { + Fake *FakeFlowsV1beta1 + ns string +} + +var parallelsResource = schema.GroupVersionResource{Group: "flows.knative.dev", Version: "v1beta1", Resource: "parallels"} + +var parallelsKind = schema.GroupVersionKind{Group: "flows.knative.dev", Version: "v1beta1", Kind: "Parallel"} + +// Get takes name of the parallel, and returns the corresponding parallel object, and an error if there is any. +func (c *FakeParallels) Get(name string, options v1.GetOptions) (result *v1beta1.Parallel, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(parallelsResource, c.ns, name), &v1beta1.Parallel{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.Parallel), err +} + +// List takes label and field selectors, and returns the list of Parallels that match those selectors. +func (c *FakeParallels) List(opts v1.ListOptions) (result *v1beta1.ParallelList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(parallelsResource, parallelsKind, c.ns, opts), &v1beta1.ParallelList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1beta1.ParallelList{ListMeta: obj.(*v1beta1.ParallelList).ListMeta} + for _, item := range obj.(*v1beta1.ParallelList).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 parallels. +func (c *FakeParallels) Watch(opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(parallelsResource, c.ns, opts)) + +} + +// Create takes the representation of a parallel and creates it. Returns the server's representation of the parallel, and an error, if there is any. +func (c *FakeParallels) Create(parallel *v1beta1.Parallel) (result *v1beta1.Parallel, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(parallelsResource, c.ns, parallel), &v1beta1.Parallel{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.Parallel), err +} + +// Update takes the representation of a parallel and updates it. Returns the server's representation of the parallel, and an error, if there is any. +func (c *FakeParallels) Update(parallel *v1beta1.Parallel) (result *v1beta1.Parallel, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(parallelsResource, c.ns, parallel), &v1beta1.Parallel{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.Parallel), 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 *FakeParallels) UpdateStatus(parallel *v1beta1.Parallel) (*v1beta1.Parallel, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(parallelsResource, "status", c.ns, parallel), &v1beta1.Parallel{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.Parallel), err +} + +// Delete takes name of the parallel and deletes it. Returns an error if one occurs. +func (c *FakeParallels) Delete(name string, options *v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(parallelsResource, c.ns, name), &v1beta1.Parallel{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeParallels) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(parallelsResource, c.ns, listOptions) + + _, err := c.Fake.Invokes(action, &v1beta1.ParallelList{}) + return err +} + +// Patch applies the patch and returns the patched parallel. +func (c *FakeParallels) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.Parallel, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(parallelsResource, c.ns, name, pt, data, subresources...), &v1beta1.Parallel{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.Parallel), err +} diff --git a/pkg/client/clientset/versioned/typed/flows/v1beta1/fake/fake_sequence.go b/pkg/client/clientset/versioned/typed/flows/v1beta1/fake/fake_sequence.go new file mode 100644 index 00000000000..d6fff3cc30f --- /dev/null +++ b/pkg/client/clientset/versioned/typed/flows/v1beta1/fake/fake_sequence.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/flows/v1beta1" +) + +// FakeSequences implements SequenceInterface +type FakeSequences struct { + Fake *FakeFlowsV1beta1 + ns string +} + +var sequencesResource = schema.GroupVersionResource{Group: "flows.knative.dev", Version: "v1beta1", Resource: "sequences"} + +var sequencesKind = schema.GroupVersionKind{Group: "flows.knative.dev", Version: "v1beta1", Kind: "Sequence"} + +// Get takes name of the sequence, and returns the corresponding sequence object, and an error if there is any. +func (c *FakeSequences) Get(name string, options v1.GetOptions) (result *v1beta1.Sequence, err error) { + obj, err := c.Fake. + Invokes(testing.NewGetAction(sequencesResource, c.ns, name), &v1beta1.Sequence{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.Sequence), err +} + +// List takes label and field selectors, and returns the list of Sequences that match those selectors. +func (c *FakeSequences) List(opts v1.ListOptions) (result *v1beta1.SequenceList, err error) { + obj, err := c.Fake. + Invokes(testing.NewListAction(sequencesResource, sequencesKind, c.ns, opts), &v1beta1.SequenceList{}) + + if obj == nil { + return nil, err + } + + label, _, _ := testing.ExtractFromListOptions(opts) + if label == nil { + label = labels.Everything() + } + list := &v1beta1.SequenceList{ListMeta: obj.(*v1beta1.SequenceList).ListMeta} + for _, item := range obj.(*v1beta1.SequenceList).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 sequences. +func (c *FakeSequences) Watch(opts v1.ListOptions) (watch.Interface, error) { + return c.Fake. + InvokesWatch(testing.NewWatchAction(sequencesResource, c.ns, opts)) + +} + +// Create takes the representation of a sequence and creates it. Returns the server's representation of the sequence, and an error, if there is any. +func (c *FakeSequences) Create(sequence *v1beta1.Sequence) (result *v1beta1.Sequence, err error) { + obj, err := c.Fake. + Invokes(testing.NewCreateAction(sequencesResource, c.ns, sequence), &v1beta1.Sequence{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.Sequence), err +} + +// Update takes the representation of a sequence and updates it. Returns the server's representation of the sequence, and an error, if there is any. +func (c *FakeSequences) Update(sequence *v1beta1.Sequence) (result *v1beta1.Sequence, err error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateAction(sequencesResource, c.ns, sequence), &v1beta1.Sequence{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.Sequence), 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 *FakeSequences) UpdateStatus(sequence *v1beta1.Sequence) (*v1beta1.Sequence, error) { + obj, err := c.Fake. + Invokes(testing.NewUpdateSubresourceAction(sequencesResource, "status", c.ns, sequence), &v1beta1.Sequence{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.Sequence), err +} + +// Delete takes name of the sequence and deletes it. Returns an error if one occurs. +func (c *FakeSequences) Delete(name string, options *v1.DeleteOptions) error { + _, err := c.Fake. + Invokes(testing.NewDeleteAction(sequencesResource, c.ns, name), &v1beta1.Sequence{}) + + return err +} + +// DeleteCollection deletes a collection of objects. +func (c *FakeSequences) DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error { + action := testing.NewDeleteCollectionAction(sequencesResource, c.ns, listOptions) + + _, err := c.Fake.Invokes(action, &v1beta1.SequenceList{}) + return err +} + +// Patch applies the patch and returns the patched sequence. +func (c *FakeSequences) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.Sequence, err error) { + obj, err := c.Fake. + Invokes(testing.NewPatchSubresourceAction(sequencesResource, c.ns, name, pt, data, subresources...), &v1beta1.Sequence{}) + + if obj == nil { + return nil, err + } + return obj.(*v1beta1.Sequence), err +} diff --git a/pkg/client/clientset/versioned/typed/flows/v1beta1/flows_client.go b/pkg/client/clientset/versioned/typed/flows/v1beta1/flows_client.go new file mode 100644 index 00000000000..9be8f9810cc --- /dev/null +++ b/pkg/client/clientset/versioned/typed/flows/v1beta1/flows_client.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 client-gen. DO NOT EDIT. + +package v1beta1 + +import ( + rest "k8s.io/client-go/rest" + v1beta1 "knative.dev/eventing/pkg/apis/flows/v1beta1" + "knative.dev/eventing/pkg/client/clientset/versioned/scheme" +) + +type FlowsV1beta1Interface interface { + RESTClient() rest.Interface + ParallelsGetter + SequencesGetter +} + +// FlowsV1beta1Client is used to interact with features provided by the flows.knative.dev group. +type FlowsV1beta1Client struct { + restClient rest.Interface +} + +func (c *FlowsV1beta1Client) Parallels(namespace string) ParallelInterface { + return newParallels(c, namespace) +} + +func (c *FlowsV1beta1Client) Sequences(namespace string) SequenceInterface { + return newSequences(c, namespace) +} + +// NewForConfig creates a new FlowsV1beta1Client for the given config. +func NewForConfig(c *rest.Config) (*FlowsV1beta1Client, error) { + config := *c + if err := setConfigDefaults(&config); err != nil { + return nil, err + } + client, err := rest.RESTClientFor(&config) + if err != nil { + return nil, err + } + return &FlowsV1beta1Client{client}, nil +} + +// NewForConfigOrDie creates a new FlowsV1beta1Client for the given config and +// panics if there is an error in the config. +func NewForConfigOrDie(c *rest.Config) *FlowsV1beta1Client { + client, err := NewForConfig(c) + if err != nil { + panic(err) + } + return client +} + +// New creates a new FlowsV1beta1Client for the given RESTClient. +func New(c rest.Interface) *FlowsV1beta1Client { + return &FlowsV1beta1Client{c} +} + +func setConfigDefaults(config *rest.Config) error { + gv := v1beta1.SchemeGroupVersion + config.GroupVersion = &gv + config.APIPath = "/apis" + config.NegotiatedSerializer = scheme.Codecs.WithoutConversion() + + if config.UserAgent == "" { + config.UserAgent = rest.DefaultKubernetesUserAgent() + } + + return nil +} + +// RESTClient returns a RESTClient that is used to communicate +// with API server by this client implementation. +func (c *FlowsV1beta1Client) RESTClient() rest.Interface { + if c == nil { + return nil + } + return c.restClient +} diff --git a/pkg/client/clientset/versioned/typed/flows/v1beta1/generated_expansion.go b/pkg/client/clientset/versioned/typed/flows/v1beta1/generated_expansion.go new file mode 100644 index 00000000000..ae8752c73f4 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/flows/v1beta1/generated_expansion.go @@ -0,0 +1,23 @@ +/* +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 + +type ParallelExpansion interface{} + +type SequenceExpansion interface{} diff --git a/pkg/client/clientset/versioned/typed/flows/v1beta1/parallel.go b/pkg/client/clientset/versioned/typed/flows/v1beta1/parallel.go new file mode 100644 index 00000000000..163fd30b958 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/flows/v1beta1/parallel.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/flows/v1beta1" + scheme "knative.dev/eventing/pkg/client/clientset/versioned/scheme" +) + +// ParallelsGetter has a method to return a ParallelInterface. +// A group's client should implement this interface. +type ParallelsGetter interface { + Parallels(namespace string) ParallelInterface +} + +// ParallelInterface has methods to work with Parallel resources. +type ParallelInterface interface { + Create(*v1beta1.Parallel) (*v1beta1.Parallel, error) + Update(*v1beta1.Parallel) (*v1beta1.Parallel, error) + UpdateStatus(*v1beta1.Parallel) (*v1beta1.Parallel, error) + Delete(name string, options *v1.DeleteOptions) error + DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error + Get(name string, options v1.GetOptions) (*v1beta1.Parallel, error) + List(opts v1.ListOptions) (*v1beta1.ParallelList, error) + Watch(opts v1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.Parallel, err error) + ParallelExpansion +} + +// parallels implements ParallelInterface +type parallels struct { + client rest.Interface + ns string +} + +// newParallels returns a Parallels +func newParallels(c *FlowsV1beta1Client, namespace string) *parallels { + return ¶llels{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the parallel, and returns the corresponding parallel object, and an error if there is any. +func (c *parallels) Get(name string, options v1.GetOptions) (result *v1beta1.Parallel, err error) { + result = &v1beta1.Parallel{} + err = c.client.Get(). + Namespace(c.ns). + Resource("parallels"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of Parallels that match those selectors. +func (c *parallels) List(opts v1.ListOptions) (result *v1beta1.ParallelList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta1.ParallelList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("parallels"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested parallels. +func (c *parallels) 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("parallels"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch() +} + +// Create takes the representation of a parallel and creates it. Returns the server's representation of the parallel, and an error, if there is any. +func (c *parallels) Create(parallel *v1beta1.Parallel) (result *v1beta1.Parallel, err error) { + result = &v1beta1.Parallel{} + err = c.client.Post(). + Namespace(c.ns). + Resource("parallels"). + Body(parallel). + Do(). + Into(result) + return +} + +// Update takes the representation of a parallel and updates it. Returns the server's representation of the parallel, and an error, if there is any. +func (c *parallels) Update(parallel *v1beta1.Parallel) (result *v1beta1.Parallel, err error) { + result = &v1beta1.Parallel{} + err = c.client.Put(). + Namespace(c.ns). + Resource("parallels"). + Name(parallel.Name). + Body(parallel). + 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 *parallels) UpdateStatus(parallel *v1beta1.Parallel) (result *v1beta1.Parallel, err error) { + result = &v1beta1.Parallel{} + err = c.client.Put(). + Namespace(c.ns). + Resource("parallels"). + Name(parallel.Name). + SubResource("status"). + Body(parallel). + Do(). + Into(result) + return +} + +// Delete takes name of the parallel and deletes it. Returns an error if one occurs. +func (c *parallels) Delete(name string, options *v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("parallels"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *parallels) 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("parallels"). + VersionedParams(&listOptions, scheme.ParameterCodec). + Timeout(timeout). + Body(options). + Do(). + Error() +} + +// Patch applies the patch and returns the patched parallel. +func (c *parallels) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.Parallel, err error) { + result = &v1beta1.Parallel{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("parallels"). + SubResource(subresources...). + Name(name). + Body(data). + Do(). + Into(result) + return +} diff --git a/pkg/client/clientset/versioned/typed/flows/v1beta1/sequence.go b/pkg/client/clientset/versioned/typed/flows/v1beta1/sequence.go new file mode 100644 index 00000000000..f1cfcc46b4e --- /dev/null +++ b/pkg/client/clientset/versioned/typed/flows/v1beta1/sequence.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/flows/v1beta1" + scheme "knative.dev/eventing/pkg/client/clientset/versioned/scheme" +) + +// SequencesGetter has a method to return a SequenceInterface. +// A group's client should implement this interface. +type SequencesGetter interface { + Sequences(namespace string) SequenceInterface +} + +// SequenceInterface has methods to work with Sequence resources. +type SequenceInterface interface { + Create(*v1beta1.Sequence) (*v1beta1.Sequence, error) + Update(*v1beta1.Sequence) (*v1beta1.Sequence, error) + UpdateStatus(*v1beta1.Sequence) (*v1beta1.Sequence, error) + Delete(name string, options *v1.DeleteOptions) error + DeleteCollection(options *v1.DeleteOptions, listOptions v1.ListOptions) error + Get(name string, options v1.GetOptions) (*v1beta1.Sequence, error) + List(opts v1.ListOptions) (*v1beta1.SequenceList, error) + Watch(opts v1.ListOptions) (watch.Interface, error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.Sequence, err error) + SequenceExpansion +} + +// sequences implements SequenceInterface +type sequences struct { + client rest.Interface + ns string +} + +// newSequences returns a Sequences +func newSequences(c *FlowsV1beta1Client, namespace string) *sequences { + return &sequences{ + client: c.RESTClient(), + ns: namespace, + } +} + +// Get takes name of the sequence, and returns the corresponding sequence object, and an error if there is any. +func (c *sequences) Get(name string, options v1.GetOptions) (result *v1beta1.Sequence, err error) { + result = &v1beta1.Sequence{} + err = c.client.Get(). + Namespace(c.ns). + Resource("sequences"). + Name(name). + VersionedParams(&options, scheme.ParameterCodec). + Do(). + Into(result) + return +} + +// List takes label and field selectors, and returns the list of Sequences that match those selectors. +func (c *sequences) List(opts v1.ListOptions) (result *v1beta1.SequenceList, err error) { + var timeout time.Duration + if opts.TimeoutSeconds != nil { + timeout = time.Duration(*opts.TimeoutSeconds) * time.Second + } + result = &v1beta1.SequenceList{} + err = c.client.Get(). + Namespace(c.ns). + Resource("sequences"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Do(). + Into(result) + return +} + +// Watch returns a watch.Interface that watches the requested sequences. +func (c *sequences) 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("sequences"). + VersionedParams(&opts, scheme.ParameterCodec). + Timeout(timeout). + Watch() +} + +// Create takes the representation of a sequence and creates it. Returns the server's representation of the sequence, and an error, if there is any. +func (c *sequences) Create(sequence *v1beta1.Sequence) (result *v1beta1.Sequence, err error) { + result = &v1beta1.Sequence{} + err = c.client.Post(). + Namespace(c.ns). + Resource("sequences"). + Body(sequence). + Do(). + Into(result) + return +} + +// Update takes the representation of a sequence and updates it. Returns the server's representation of the sequence, and an error, if there is any. +func (c *sequences) Update(sequence *v1beta1.Sequence) (result *v1beta1.Sequence, err error) { + result = &v1beta1.Sequence{} + err = c.client.Put(). + Namespace(c.ns). + Resource("sequences"). + Name(sequence.Name). + Body(sequence). + 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 *sequences) UpdateStatus(sequence *v1beta1.Sequence) (result *v1beta1.Sequence, err error) { + result = &v1beta1.Sequence{} + err = c.client.Put(). + Namespace(c.ns). + Resource("sequences"). + Name(sequence.Name). + SubResource("status"). + Body(sequence). + Do(). + Into(result) + return +} + +// Delete takes name of the sequence and deletes it. Returns an error if one occurs. +func (c *sequences) Delete(name string, options *v1.DeleteOptions) error { + return c.client.Delete(). + Namespace(c.ns). + Resource("sequences"). + Name(name). + Body(options). + Do(). + Error() +} + +// DeleteCollection deletes a collection of objects. +func (c *sequences) 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("sequences"). + VersionedParams(&listOptions, scheme.ParameterCodec). + Timeout(timeout). + Body(options). + Do(). + Error() +} + +// Patch applies the patch and returns the patched sequence. +func (c *sequences) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.Sequence, err error) { + result = &v1beta1.Sequence{} + err = c.client.Patch(pt). + Namespace(c.ns). + Resource("sequences"). + SubResource(subresources...). + Name(name). + Body(data). + Do(). + Into(result) + return +} diff --git a/pkg/client/informers/externalversions/flows/interface.go b/pkg/client/informers/externalversions/flows/interface.go index 471aba0666e..49930a40638 100644 --- a/pkg/client/informers/externalversions/flows/interface.go +++ b/pkg/client/informers/externalversions/flows/interface.go @@ -20,6 +20,7 @@ package flows import ( v1alpha1 "knative.dev/eventing/pkg/client/informers/externalversions/flows/v1alpha1" + v1beta1 "knative.dev/eventing/pkg/client/informers/externalversions/flows/v1beta1" internalinterfaces "knative.dev/eventing/pkg/client/informers/externalversions/internalinterfaces" ) @@ -27,6 +28,8 @@ import ( type Interface interface { // V1alpha1 provides access to shared informers for resources in V1alpha1. V1alpha1() v1alpha1.Interface + // V1beta1 provides access to shared informers for resources in V1beta1. + V1beta1() v1beta1.Interface } type group struct { @@ -44,3 +47,8 @@ func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakList func (g *group) V1alpha1() v1alpha1.Interface { return v1alpha1.New(g.factory, g.namespace, g.tweakListOptions) } + +// V1beta1 returns a new v1beta1.Interface. +func (g *group) V1beta1() v1beta1.Interface { + return v1beta1.New(g.factory, g.namespace, g.tweakListOptions) +} diff --git a/pkg/client/informers/externalversions/flows/v1beta1/interface.go b/pkg/client/informers/externalversions/flows/v1beta1/interface.go new file mode 100644 index 00000000000..54ea25fee1b --- /dev/null +++ b/pkg/client/informers/externalversions/flows/v1beta1/interface.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 informer-gen. DO NOT EDIT. + +package v1beta1 + +import ( + internalinterfaces "knative.dev/eventing/pkg/client/informers/externalversions/internalinterfaces" +) + +// Interface provides access to all the informers in this group version. +type Interface interface { + // Parallels returns a ParallelInformer. + Parallels() ParallelInformer + // Sequences returns a SequenceInformer. + Sequences() SequenceInformer +} + +type version struct { + factory internalinterfaces.SharedInformerFactory + namespace string + tweakListOptions internalinterfaces.TweakListOptionsFunc +} + +// New returns a new Interface. +func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakListOptions internalinterfaces.TweakListOptionsFunc) Interface { + return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} +} + +// Parallels returns a ParallelInformer. +func (v *version) Parallels() ParallelInformer { + return ¶llelInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + +// Sequences returns a SequenceInformer. +func (v *version) Sequences() SequenceInformer { + return &sequenceInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} diff --git a/pkg/client/informers/externalversions/flows/v1beta1/parallel.go b/pkg/client/informers/externalversions/flows/v1beta1/parallel.go new file mode 100644 index 00000000000..ea8949a8453 --- /dev/null +++ b/pkg/client/informers/externalversions/flows/v1beta1/parallel.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" + flowsv1beta1 "knative.dev/eventing/pkg/apis/flows/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/flows/v1beta1" +) + +// ParallelInformer provides access to a shared informer and lister for +// Parallels. +type ParallelInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1beta1.ParallelLister +} + +type parallelInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewParallelInformer constructs a new informer for Parallel 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 NewParallelInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredParallelInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredParallelInformer constructs a new informer for Parallel 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 NewFilteredParallelInformer(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.FlowsV1beta1().Parallels(namespace).List(options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.FlowsV1beta1().Parallels(namespace).Watch(options) + }, + }, + &flowsv1beta1.Parallel{}, + resyncPeriod, + indexers, + ) +} + +func (f *parallelInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredParallelInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *parallelInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&flowsv1beta1.Parallel{}, f.defaultInformer) +} + +func (f *parallelInformer) Lister() v1beta1.ParallelLister { + return v1beta1.NewParallelLister(f.Informer().GetIndexer()) +} diff --git a/pkg/client/informers/externalversions/flows/v1beta1/sequence.go b/pkg/client/informers/externalversions/flows/v1beta1/sequence.go new file mode 100644 index 00000000000..bc3c3141a59 --- /dev/null +++ b/pkg/client/informers/externalversions/flows/v1beta1/sequence.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" + flowsv1beta1 "knative.dev/eventing/pkg/apis/flows/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/flows/v1beta1" +) + +// SequenceInformer provides access to a shared informer and lister for +// Sequences. +type SequenceInformer interface { + Informer() cache.SharedIndexInformer + Lister() v1beta1.SequenceLister +} + +type sequenceInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewSequenceInformer constructs a new informer for Sequence 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 NewSequenceInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredSequenceInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredSequenceInformer constructs a new informer for Sequence 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 NewFilteredSequenceInformer(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.FlowsV1beta1().Sequences(namespace).List(options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.FlowsV1beta1().Sequences(namespace).Watch(options) + }, + }, + &flowsv1beta1.Sequence{}, + resyncPeriod, + indexers, + ) +} + +func (f *sequenceInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredSequenceInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *sequenceInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&flowsv1beta1.Sequence{}, f.defaultInformer) +} + +func (f *sequenceInformer) Lister() v1beta1.SequenceLister { + return v1beta1.NewSequenceLister(f.Informer().GetIndexer()) +} diff --git a/pkg/client/informers/externalversions/generic.go b/pkg/client/informers/externalversions/generic.go index 7eacaab1074..cc86623fe48 100644 --- a/pkg/client/informers/externalversions/generic.go +++ b/pkg/client/informers/externalversions/generic.go @@ -25,6 +25,7 @@ import ( cache "k8s.io/client-go/tools/cache" v1alpha1 "knative.dev/eventing/pkg/apis/eventing/v1alpha1" flowsv1alpha1 "knative.dev/eventing/pkg/apis/flows/v1alpha1" + v1beta1 "knative.dev/eventing/pkg/apis/flows/v1beta1" messagingv1alpha1 "knative.dev/eventing/pkg/apis/messaging/v1alpha1" v1beta1 "knative.dev/eventing/pkg/apis/messaging/v1beta1" sourcesv1alpha1 "knative.dev/eventing/pkg/apis/sources/v1alpha1" @@ -70,6 +71,12 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource case flowsv1alpha1.SchemeGroupVersion.WithResource("sequences"): return &genericInformer{resource: resource.GroupResource(), informer: f.Flows().V1alpha1().Sequences().Informer()}, nil + // Group=flows.knative.dev, Version=v1beta1 + case v1beta1.SchemeGroupVersion.WithResource("parallels"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Flows().V1beta1().Parallels().Informer()}, nil + case v1beta1.SchemeGroupVersion.WithResource("sequences"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Flows().V1beta1().Sequences().Informer()}, nil + // Group=messaging.knative.dev, Version=v1alpha1 case messagingv1alpha1.SchemeGroupVersion.WithResource("channels"): return &genericInformer{resource: resource.GroupResource(), informer: f.Messaging().V1alpha1().Channels().Informer()}, nil diff --git a/pkg/client/injection/informers/flows/v1beta1/parallel/fake/fake.go b/pkg/client/injection/informers/flows/v1beta1/parallel/fake/fake.go new file mode 100644 index 00000000000..2e2b5075052 --- /dev/null +++ b/pkg/client/injection/informers/flows/v1beta1/parallel/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" + + fake "knative.dev/eventing/pkg/client/injection/informers/factory/fake" + parallel "knative.dev/eventing/pkg/client/injection/informers/flows/v1beta1/parallel" + controller "knative.dev/pkg/controller" + injection "knative.dev/pkg/injection" +) + +var Get = parallel.Get + +func init() { + injection.Fake.RegisterInformer(withInformer) +} + +func withInformer(ctx context.Context) (context.Context, controller.Informer) { + f := fake.Get(ctx) + inf := f.Flows().V1beta1().Parallels() + return context.WithValue(ctx, parallel.Key{}, inf), inf.Informer() +} diff --git a/pkg/client/injection/informers/flows/v1beta1/parallel/parallel.go b/pkg/client/injection/informers/flows/v1beta1/parallel/parallel.go new file mode 100644 index 00000000000..b8781d4d425 --- /dev/null +++ b/pkg/client/injection/informers/flows/v1beta1/parallel/parallel.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 parallel + +import ( + "context" + + v1beta1 "knative.dev/eventing/pkg/client/informers/externalversions/flows/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.Flows().V1beta1().Parallels() + return context.WithValue(ctx, Key{}, inf), inf.Informer() +} + +// Get extracts the typed informer from the context. +func Get(ctx context.Context) v1beta1.ParallelInformer { + untyped := ctx.Value(Key{}) + if untyped == nil { + logging.FromContext(ctx).Panic( + "Unable to fetch knative.dev/eventing/pkg/client/informers/externalversions/flows/v1beta1.ParallelInformer from context.") + } + return untyped.(v1beta1.ParallelInformer) +} diff --git a/pkg/client/injection/informers/flows/v1beta1/sequence/fake/fake.go b/pkg/client/injection/informers/flows/v1beta1/sequence/fake/fake.go new file mode 100644 index 00000000000..0416c9a08cc --- /dev/null +++ b/pkg/client/injection/informers/flows/v1beta1/sequence/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" + + fake "knative.dev/eventing/pkg/client/injection/informers/factory/fake" + sequence "knative.dev/eventing/pkg/client/injection/informers/flows/v1beta1/sequence" + controller "knative.dev/pkg/controller" + injection "knative.dev/pkg/injection" +) + +var Get = sequence.Get + +func init() { + injection.Fake.RegisterInformer(withInformer) +} + +func withInformer(ctx context.Context) (context.Context, controller.Informer) { + f := fake.Get(ctx) + inf := f.Flows().V1beta1().Sequences() + return context.WithValue(ctx, sequence.Key{}, inf), inf.Informer() +} diff --git a/pkg/client/injection/informers/flows/v1beta1/sequence/sequence.go b/pkg/client/injection/informers/flows/v1beta1/sequence/sequence.go new file mode 100644 index 00000000000..6e147b702c1 --- /dev/null +++ b/pkg/client/injection/informers/flows/v1beta1/sequence/sequence.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 sequence + +import ( + "context" + + v1beta1 "knative.dev/eventing/pkg/client/informers/externalversions/flows/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.Flows().V1beta1().Sequences() + return context.WithValue(ctx, Key{}, inf), inf.Informer() +} + +// Get extracts the typed informer from the context. +func Get(ctx context.Context) v1beta1.SequenceInformer { + untyped := ctx.Value(Key{}) + if untyped == nil { + logging.FromContext(ctx).Panic( + "Unable to fetch knative.dev/eventing/pkg/client/informers/externalversions/flows/v1beta1.SequenceInformer from context.") + } + return untyped.(v1beta1.SequenceInformer) +} diff --git a/pkg/client/listers/flows/v1beta1/expansion_generated.go b/pkg/client/listers/flows/v1beta1/expansion_generated.go new file mode 100644 index 00000000000..f683f826105 --- /dev/null +++ b/pkg/client/listers/flows/v1beta1/expansion_generated.go @@ -0,0 +1,35 @@ +/* +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 + +// ParallelListerExpansion allows custom methods to be added to +// ParallelLister. +type ParallelListerExpansion interface{} + +// ParallelNamespaceListerExpansion allows custom methods to be added to +// ParallelNamespaceLister. +type ParallelNamespaceListerExpansion interface{} + +// SequenceListerExpansion allows custom methods to be added to +// SequenceLister. +type SequenceListerExpansion interface{} + +// SequenceNamespaceListerExpansion allows custom methods to be added to +// SequenceNamespaceLister. +type SequenceNamespaceListerExpansion interface{} diff --git a/pkg/client/listers/flows/v1beta1/parallel.go b/pkg/client/listers/flows/v1beta1/parallel.go new file mode 100644 index 00000000000..6c6d2d6e4db --- /dev/null +++ b/pkg/client/listers/flows/v1beta1/parallel.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/flows/v1beta1" +) + +// ParallelLister helps list Parallels. +type ParallelLister interface { + // List lists all Parallels in the indexer. + List(selector labels.Selector) (ret []*v1beta1.Parallel, err error) + // Parallels returns an object that can list and get Parallels. + Parallels(namespace string) ParallelNamespaceLister + ParallelListerExpansion +} + +// parallelLister implements the ParallelLister interface. +type parallelLister struct { + indexer cache.Indexer +} + +// NewParallelLister returns a new ParallelLister. +func NewParallelLister(indexer cache.Indexer) ParallelLister { + return ¶llelLister{indexer: indexer} +} + +// List lists all Parallels in the indexer. +func (s *parallelLister) List(selector labels.Selector) (ret []*v1beta1.Parallel, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1beta1.Parallel)) + }) + return ret, err +} + +// Parallels returns an object that can list and get Parallels. +func (s *parallelLister) Parallels(namespace string) ParallelNamespaceLister { + return parallelNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// ParallelNamespaceLister helps list and get Parallels. +type ParallelNamespaceLister interface { + // List lists all Parallels in the indexer for a given namespace. + List(selector labels.Selector) (ret []*v1beta1.Parallel, err error) + // Get retrieves the Parallel from the indexer for a given namespace and name. + Get(name string) (*v1beta1.Parallel, error) + ParallelNamespaceListerExpansion +} + +// parallelNamespaceLister implements the ParallelNamespaceLister +// interface. +type parallelNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all Parallels in the indexer for a given namespace. +func (s parallelNamespaceLister) List(selector labels.Selector) (ret []*v1beta1.Parallel, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1beta1.Parallel)) + }) + return ret, err +} + +// Get retrieves the Parallel from the indexer for a given namespace and name. +func (s parallelNamespaceLister) Get(name string) (*v1beta1.Parallel, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1beta1.Resource("parallel"), name) + } + return obj.(*v1beta1.Parallel), nil +} diff --git a/pkg/client/listers/flows/v1beta1/sequence.go b/pkg/client/listers/flows/v1beta1/sequence.go new file mode 100644 index 00000000000..92e5fe930cc --- /dev/null +++ b/pkg/client/listers/flows/v1beta1/sequence.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/flows/v1beta1" +) + +// SequenceLister helps list Sequences. +type SequenceLister interface { + // List lists all Sequences in the indexer. + List(selector labels.Selector) (ret []*v1beta1.Sequence, err error) + // Sequences returns an object that can list and get Sequences. + Sequences(namespace string) SequenceNamespaceLister + SequenceListerExpansion +} + +// sequenceLister implements the SequenceLister interface. +type sequenceLister struct { + indexer cache.Indexer +} + +// NewSequenceLister returns a new SequenceLister. +func NewSequenceLister(indexer cache.Indexer) SequenceLister { + return &sequenceLister{indexer: indexer} +} + +// List lists all Sequences in the indexer. +func (s *sequenceLister) List(selector labels.Selector) (ret []*v1beta1.Sequence, err error) { + err = cache.ListAll(s.indexer, selector, func(m interface{}) { + ret = append(ret, m.(*v1beta1.Sequence)) + }) + return ret, err +} + +// Sequences returns an object that can list and get Sequences. +func (s *sequenceLister) Sequences(namespace string) SequenceNamespaceLister { + return sequenceNamespaceLister{indexer: s.indexer, namespace: namespace} +} + +// SequenceNamespaceLister helps list and get Sequences. +type SequenceNamespaceLister interface { + // List lists all Sequences in the indexer for a given namespace. + List(selector labels.Selector) (ret []*v1beta1.Sequence, err error) + // Get retrieves the Sequence from the indexer for a given namespace and name. + Get(name string) (*v1beta1.Sequence, error) + SequenceNamespaceListerExpansion +} + +// sequenceNamespaceLister implements the SequenceNamespaceLister +// interface. +type sequenceNamespaceLister struct { + indexer cache.Indexer + namespace string +} + +// List lists all Sequences in the indexer for a given namespace. +func (s sequenceNamespaceLister) List(selector labels.Selector) (ret []*v1beta1.Sequence, err error) { + err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { + ret = append(ret, m.(*v1beta1.Sequence)) + }) + return ret, err +} + +// Get retrieves the Sequence from the indexer for a given namespace and name. +func (s sequenceNamespaceLister) Get(name string) (*v1beta1.Sequence, error) { + obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) + if err != nil { + return nil, err + } + if !exists { + return nil, errors.NewNotFound(v1beta1.Resource("sequence"), name) + } + return obj.(*v1beta1.Sequence), nil +} From 6cffb9867f0735f32cc14f89ef99f012f55fcc9d Mon Sep 17 00:00:00 2001 From: Ville Aikas Date: Thu, 16 Jan 2020 13:14:44 -0800 Subject: [PATCH 3/7] moar parallel/sequence stuff --- pkg/apis/flows/v1beta1/implements_test.go | 41 ++++ pkg/apis/flows/v1beta1/parallel_defaults.go | 37 +++ pkg/apis/flows/v1beta1/parallel_lifecycle.go | 230 ++++++++++++++++++ pkg/apis/flows/v1beta1/parallel_validation.go | 68 ++++++ pkg/apis/flows/v1beta1/sequence_defaults.go | 38 +++ .../flows/v1beta1/sequence_defaults_test.go | 107 ++++++++ pkg/apis/flows/v1beta1/sequence_lifecycle.go | 158 ++++++++++++ pkg/apis/flows/v1beta1/sequence_types_test.go | 34 +++ pkg/apis/flows/v1beta1/sequence_validation.go | 60 +++++ pkg/apis/flows/v1beta1/test_helpers.go | 39 +++ 10 files changed, 812 insertions(+) create mode 100644 pkg/apis/flows/v1beta1/implements_test.go create mode 100644 pkg/apis/flows/v1beta1/parallel_defaults.go create mode 100644 pkg/apis/flows/v1beta1/parallel_lifecycle.go create mode 100644 pkg/apis/flows/v1beta1/parallel_validation.go create mode 100644 pkg/apis/flows/v1beta1/sequence_defaults.go create mode 100644 pkg/apis/flows/v1beta1/sequence_defaults_test.go create mode 100644 pkg/apis/flows/v1beta1/sequence_lifecycle.go create mode 100644 pkg/apis/flows/v1beta1/sequence_types_test.go create mode 100644 pkg/apis/flows/v1beta1/sequence_validation.go create mode 100644 pkg/apis/flows/v1beta1/test_helpers.go diff --git a/pkg/apis/flows/v1beta1/implements_test.go b/pkg/apis/flows/v1beta1/implements_test.go new file mode 100644 index 00000000000..5a78192c732 --- /dev/null +++ b/pkg/apis/flows/v1beta1/implements_test.go @@ -0,0 +1,41 @@ +/* + * 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 ( + "testing" + + "knative.dev/pkg/apis/duck" + duckv1 "knative.dev/pkg/apis/duck/v1" +) + +func TestTypesImplements(t *testing.T) { + testCases := []struct { + instance interface{} + iface duck.Implementable + }{ + // Sequence + {instance: &Sequence{}, iface: &duckv1.Conditions{}}, + // Parallel + {instance: &Parallel{}, iface: &duckv1.Conditions{}}, + } + for _, tc := range testCases { + if err := duck.VerifyType(tc.instance, tc.iface); err != nil { + t.Error(err) + } + } +} diff --git a/pkg/apis/flows/v1beta1/parallel_defaults.go b/pkg/apis/flows/v1beta1/parallel_defaults.go new file mode 100644 index 00000000000..f98e025ef49 --- /dev/null +++ b/pkg/apis/flows/v1beta1/parallel_defaults.go @@ -0,0 +1,37 @@ +/* + * 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" + + eventingduckv1alpha1 "knative.dev/eventing/pkg/apis/duck/v1alpha1" +) + +func (s *Parallel) SetDefaults(ctx context.Context) { + if s != nil && s.Spec.ChannelTemplate == nil { + // The singleton may not have been set, if so ignore it and validation will reject the + // Channel. + if cd := eventingduckv1alpha1.ChannelDefaulterSingleton; cd != nil { + channelTemplate := cd.GetDefault(s.Namespace) + s.Spec.ChannelTemplate = channelTemplate + } + } + s.Spec.SetDefaults(ctx) +} + +func (ss *ParallelSpec) SetDefaults(ctx context.Context) {} diff --git a/pkg/apis/flows/v1beta1/parallel_lifecycle.go b/pkg/apis/flows/v1beta1/parallel_lifecycle.go new file mode 100644 index 00000000000..5de64391e72 --- /dev/null +++ b/pkg/apis/flows/v1beta1/parallel_lifecycle.go @@ -0,0 +1,230 @@ +/* + * 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 ( + "time" + + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + duckv1alpha1 "knative.dev/eventing/pkg/apis/duck/v1alpha1" + messagingv1alpha1 "knative.dev/eventing/pkg/apis/messaging/v1alpha1" + "knative.dev/pkg/apis" + pkgduckv1 "knative.dev/pkg/apis/duck/v1" +) + +var pParallelCondSet = apis.NewLivingConditionSet(ParallelConditionReady, ParallelConditionChannelsReady, ParallelConditionSubscriptionsReady, ParallelConditionAddressable) + +const ( + // StatusConditionTypeDeprecated is the status.conditions.type used to provide deprecation + // warnings. + StatusConditionTypeDeprecated = "Deprecated" +) + +const ( + // ParallelConditionReady has status True when all subconditions below have been set to True. + ParallelConditionReady = apis.ConditionReady + + // ParallelConditionChannelsReady has status True when all the channels created as part of + // this parallel are ready. + ParallelConditionChannelsReady apis.ConditionType = "ChannelsReady" + + // ParallelConditionSubscriptionsReady has status True when all the subscriptions created as part of + // this parallel are ready. + ParallelConditionSubscriptionsReady apis.ConditionType = "SubscriptionsReady" + + // ParallelConditionAddressable has status true when this Parallel meets + // the Addressable contract and has a non-empty hostname. + ParallelConditionAddressable apis.ConditionType = "Addressable" +) + +// GetCondition returns the condition currently associated with the given type, or nil. +func (ps *ParallelStatus) GetCondition(t apis.ConditionType) *apis.Condition { + return pParallelCondSet.Manage(ps).GetCondition(t) +} + +// IsReady returns true if the resource is ready overall. +func (ps *ParallelStatus) IsReady() bool { + return pParallelCondSet.Manage(ps).IsHappy() +} + +// InitializeConditions sets relevant unset conditions to Unknown state. +func (ps *ParallelStatus) InitializeConditions() { + pParallelCondSet.Manage(ps).InitializeConditions() +} + +// PropagateSubscriptionStatuses sets the ParallelConditionSubscriptionsReady based on +// the status of the incoming subscriptions. +func (ps *ParallelStatus) PropagateSubscriptionStatuses(filterSubscriptions []*messagingv1alpha1.Subscription, subscriptions []*messagingv1alpha1.Subscription) { + if ps.BranchStatuses == nil { + ps.BranchStatuses = make([]ParallelBranchStatus, len(subscriptions)) + } + allReady := true + // If there are no subscriptions, treat that as a False branch. Could go either way, but this seems right. + if len(subscriptions) == 0 { + allReady = false + } + + for i, s := range subscriptions { + ps.BranchStatuses[i].SubscriptionStatus = ParallelSubscriptionStatus{ + Subscription: corev1.ObjectReference{ + APIVersion: s.APIVersion, + Kind: s.Kind, + Name: s.Name, + Namespace: s.Namespace, + }, + } + + readyCondition := s.Status.GetCondition(messagingv1alpha1.SubscriptionConditionReady) + if readyCondition != nil { + ps.BranchStatuses[i].SubscriptionStatus.ReadyCondition = *readyCondition + if readyCondition.Status != corev1.ConditionTrue { + allReady = false + } + } else { + allReady = false + } + + fs := filterSubscriptions[i] + ps.BranchStatuses[i].FilterSubscriptionStatus = ParallelSubscriptionStatus{ + Subscription: corev1.ObjectReference{ + APIVersion: fs.APIVersion, + Kind: fs.Kind, + Name: fs.Name, + Namespace: fs.Namespace, + }, + } + readyCondition = fs.Status.GetCondition(messagingv1alpha1.SubscriptionConditionReady) + if readyCondition != nil { + ps.BranchStatuses[i].FilterSubscriptionStatus.ReadyCondition = *readyCondition + if readyCondition.Status != corev1.ConditionTrue { + allReady = false + } + } else { + allReady = false + } + + } + if allReady { + pParallelCondSet.Manage(ps).MarkTrue(ParallelConditionSubscriptionsReady) + } else { + ps.MarkSubscriptionsNotReady("SubscriptionsNotReady", "Subscriptions are not ready yet, or there are none") + } +} + +// PropagateChannelStatuses sets the ChannelStatuses and ParallelConditionChannelsReady based on the +// status of the incoming channels. +func (ps *ParallelStatus) PropagateChannelStatuses(ingressChannel *duckv1alpha1.Channelable, channels []*duckv1alpha1.Channelable) { + if ps.BranchStatuses == nil { + ps.BranchStatuses = make([]ParallelBranchStatus, len(channels)) + } + allReady := true + + ps.IngressChannelStatus.Channel = corev1.ObjectReference{ + APIVersion: ingressChannel.APIVersion, + Kind: ingressChannel.Kind, + Name: ingressChannel.Name, + Namespace: ingressChannel.Namespace, + } + + address := ingressChannel.Status.AddressStatus.Address + if address != nil { + ps.IngressChannelStatus.ReadyCondition = apis.Condition{Type: apis.ConditionReady, Status: corev1.ConditionTrue} + } else { + ps.IngressChannelStatus.ReadyCondition = apis.Condition{Type: apis.ConditionReady, Status: corev1.ConditionFalse, Reason: "NotAddressable", Message: "Channel is not addressable"} + allReady = false + } + ps.setAddress(address) + + for i, c := range channels { + ps.BranchStatuses[i].FilterChannelStatus = ParallelChannelStatus{ + Channel: corev1.ObjectReference{ + APIVersion: c.APIVersion, + Kind: c.Kind, + Name: c.Name, + Namespace: c.Namespace, + }, + } + // TODO: Once the addressable has a real status to dig through, use that here instead of + // addressable, because it might be addressable but not ready. + address := c.Status.AddressStatus.Address + if address != nil { + ps.BranchStatuses[i].FilterChannelStatus.ReadyCondition = apis.Condition{Type: apis.ConditionReady, Status: corev1.ConditionTrue} + } else { + ps.BranchStatuses[i].FilterChannelStatus.ReadyCondition = apis.Condition{Type: apis.ConditionReady, Status: corev1.ConditionFalse, Reason: "NotAddressable", Message: "Channel is not addressable"} + allReady = false + } + } + if allReady { + pParallelCondSet.Manage(ps).MarkTrue(ParallelConditionChannelsReady) + } else { + ps.MarkChannelsNotReady("ChannelsNotReady", "Channels are not ready yet, or there are none") + } +} + +func (ps *ParallelStatus) MarkChannelsNotReady(reason, messageFormat string, messageA ...interface{}) { + pParallelCondSet.Manage(ps).MarkFalse(ParallelConditionChannelsReady, reason, messageFormat, messageA...) +} + +func (ps *ParallelStatus) MarkSubscriptionsNotReady(reason, messageFormat string, messageA ...interface{}) { + pParallelCondSet.Manage(ps).MarkFalse(ParallelConditionSubscriptionsReady, reason, messageFormat, messageA...) +} + +func (ps *ParallelStatus) MarkAddressableNotReady(reason, messageFormat string, messageA ...interface{}) { + pParallelCondSet.Manage(ps).MarkFalse(ParallelConditionAddressable, reason, messageFormat, messageA...) +} + +func (ps *ParallelStatus) setAddress(address *pkgduckv1.Addressable) { + ps.Address = address + if address == nil { + pParallelCondSet.Manage(ps).MarkFalse(ParallelConditionAddressable, "emptyAddress", "addressable is nil") + } else { + pParallelCondSet.Manage(ps).MarkTrue(ParallelConditionAddressable) + } +} + +// MarkDeprecated adds a warning condition that this object's spec is using deprecated fields +// and will stop working in the future. Note that this does not affect the Ready condition. +func (ps *ParallelStatus) MarkDestinationDeprecatedRef(reason, msg string) { + dc := apis.Condition{ + Type: StatusConditionTypeDeprecated, + Reason: reason, + Status: corev1.ConditionTrue, + Severity: apis.ConditionSeverityWarning, + Message: msg, + LastTransitionTime: apis.VolatileTime{Inner: metav1.NewTime(time.Now())}, + } + for i, c := range ps.Conditions { + if c.Type == dc.Type { + ps.Conditions[i] = dc + return + } + } + ps.Conditions = append(ps.Conditions, dc) +} + +// ClearDeprecated removes the StatusConditionTypeDeprecated warning condition. Note that this does not +// affect the Ready condition. +func (ps *ParallelStatus) ClearDeprecated() { + conds := make([]apis.Condition, 0, len(ps.Conditions)) + for _, c := range ps.Conditions { + if c.Type != StatusConditionTypeDeprecated { + conds = append(conds, c) + } + } + ps.Conditions = conds +} diff --git a/pkg/apis/flows/v1beta1/parallel_validation.go b/pkg/apis/flows/v1beta1/parallel_validation.go new file mode 100644 index 00000000000..3200d025282 --- /dev/null +++ b/pkg/apis/flows/v1beta1/parallel_validation.go @@ -0,0 +1,68 @@ +/* + * 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" + + "knative.dev/pkg/apis" +) + +func (p *Parallel) Validate(ctx context.Context) *apis.FieldError { + return p.Spec.Validate(ctx).ViaField("spec") +} + +func (ps *ParallelSpec) Validate(ctx context.Context) *apis.FieldError { + var errs *apis.FieldError + + if len(ps.Branches) == 0 { + errs = errs.Also(apis.ErrMissingField("branches")) + } + + for i, s := range ps.Branches { + if err := s.Filter.Validate(ctx); err != nil { + errs = errs.Also(apis.ErrInvalidArrayValue(s, "branches.filter", i)) + } + + if e := s.Subscriber.Validate(ctx); e != nil { + errs = errs.Also(apis.ErrInvalidArrayValue(s, "branches.subscriber", i)) + } + + if e := s.Reply.Validate(ctx); e != nil { + errs = errs.Also(apis.ErrInvalidArrayValue(s, "branches.reply", i)) + } + } + + if ps.ChannelTemplate == nil { + errs = errs.Also(apis.ErrMissingField("channelTemplate")) + return errs + } + + if len(ps.ChannelTemplate.APIVersion) == 0 { + errs = errs.Also(apis.ErrMissingField("channelTemplate.apiVersion")) + } + + if len(ps.ChannelTemplate.Kind) == 0 { + errs = errs.Also(apis.ErrMissingField("channelTemplate.kind")) + } + + if err := ps.Reply.Validate(ctx); err != nil { + errs = errs.Also(err.ViaField("reply")) + } + + return errs +} diff --git a/pkg/apis/flows/v1beta1/sequence_defaults.go b/pkg/apis/flows/v1beta1/sequence_defaults.go new file mode 100644 index 00000000000..aa15654c9dd --- /dev/null +++ b/pkg/apis/flows/v1beta1/sequence_defaults.go @@ -0,0 +1,38 @@ +/* + * 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" + + // DO NOT SUBMIT. Change to v1beta1 before merge + eventingduckv1alpha1 "knative.dev/eventing/pkg/apis/duck/v1alpha1" +) + +func (s *Sequence) SetDefaults(ctx context.Context) { + if s != nil && s.Spec.ChannelTemplate == nil { + // The singleton may not have been set, if so ignore it and validation will reject the + // Channel. + if cd := eventingduckv1alpha1.ChannelDefaulterSingleton; cd != nil { + channelTemplate := cd.GetDefault(s.Namespace) + s.Spec.ChannelTemplate = channelTemplate + } + } + s.Spec.SetDefaults(ctx) +} + +func (ss *SequenceSpec) SetDefaults(ctx context.Context) {} diff --git a/pkg/apis/flows/v1beta1/sequence_defaults_test.go b/pkg/apis/flows/v1beta1/sequence_defaults_test.go new file mode 100644 index 00000000000..835d7c3432e --- /dev/null +++ b/pkg/apis/flows/v1beta1/sequence_defaults_test.go @@ -0,0 +1,107 @@ +/* + * 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" + + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + "github.com/google/go-cmp/cmp" + // DO NOT SUBMIT. Change to v1beta1 before merge + eventingduckv1alpha1 "knative.dev/eventing/pkg/apis/duck/v1alpha1" +) + +var ( + defaultTemplate = &eventingduckv1alpha1.ChannelTemplateSpec{ + TypeMeta: v1.TypeMeta{ + APIVersion: SchemeGroupVersion.String(), + Kind: "InMemoryChannel", + }, + } +) + +func TestSequenceSetDefaults(t *testing.T) { + testCases := map[string]struct { + nilChannelDefaulter bool + channelTemplate *eventingduckv1alpha1.ChannelTemplateSpec + initial Sequence + expected Sequence + }{ + "nil ChannelDefaulter": { + nilChannelDefaulter: true, + expected: Sequence{}, + }, + "unset ChannelDefaulter": { + expected: Sequence{}, + }, + "set ChannelDefaulter": { + channelTemplate: defaultChannelTemplate, + expected: Sequence{ + Spec: SequenceSpec{ + ChannelTemplate: defaultChannelTemplate, + }, + }, + }, + "template already specified": { + channelTemplate: defaultChannelTemplate, + initial: Sequence{ + Spec: SequenceSpec{ + ChannelTemplate: &eventingduckv1alpha1.ChannelTemplateSpec{ + TypeMeta: v1.TypeMeta{ + APIVersion: SchemeGroupVersion.String(), + Kind: "OtherChannel", + }, + }, + }, + }, + expected: Sequence{ + Spec: SequenceSpec{ + ChannelTemplate: &eventingduckv1alpha1.ChannelTemplateSpec{ + TypeMeta: v1.TypeMeta{ + APIVersion: SchemeGroupVersion.String(), + Kind: "OtherChannel", + }, + }, + }, + }, + }, + } + for n, tc := range testCases { + t.Run(n, func(t *testing.T) { + if !tc.nilChannelDefaulter { + eventingduckv1alpha1.ChannelDefaulterSingleton = &sequenceChannelDefaulter{ + channelTemplate: tc.channelTemplate, + } + defer func() { eventingduckv1alpha1.ChannelDefaulterSingleton = nil }() + } + tc.initial.SetDefaults(context.TODO()) + if diff := cmp.Diff(tc.expected, tc.initial); diff != "" { + t.Fatalf("Unexpected defaults (-want, +got): %s", diff) + } + }) + } +} + +type sequenceChannelDefaulter struct { + channelTemplate *eventingduckv1alpha1.ChannelTemplateSpec +} + +func (cd *sequenceChannelDefaulter) GetDefault(_ string) *eventingduckv1alpha1.ChannelTemplateSpec { + return cd.channelTemplate +} diff --git a/pkg/apis/flows/v1beta1/sequence_lifecycle.go b/pkg/apis/flows/v1beta1/sequence_lifecycle.go new file mode 100644 index 00000000000..0433319b1cd --- /dev/null +++ b/pkg/apis/flows/v1beta1/sequence_lifecycle.go @@ -0,0 +1,158 @@ +/* + * 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 ( + corev1 "k8s.io/api/core/v1" + duckv1alpha1 "knative.dev/eventing/pkg/apis/duck/v1alpha1" + messagingv1alpha1 "knative.dev/eventing/pkg/apis/messaging/v1alpha1" + "knative.dev/pkg/apis" + pkgduckv1 "knative.dev/pkg/apis/duck/v1" +) + +var pCondSet = apis.NewLivingConditionSet(SequenceConditionReady, SequenceConditionChannelsReady, SequenceConditionSubscriptionsReady, SequenceConditionAddressable) + +const ( + // SequenceConditionReady has status True when all subconditions below have been set to True. + SequenceConditionReady = apis.ConditionReady + + // SequenceChannelsReady has status True when all the channels created as part of + // this sequence are ready. + SequenceConditionChannelsReady apis.ConditionType = "ChannelsReady" + + // SequenceSubscriptionsReady has status True when all the subscriptions created as part of + // this sequence are ready. + SequenceConditionSubscriptionsReady apis.ConditionType = "SubscriptionsReady" + + // SequenceConditionAddressable has status true when this Sequence meets + // the Addressable contract and has a non-empty hostname. + SequenceConditionAddressable apis.ConditionType = "Addressable" +) + +// GetCondition returns the condition currently associated with the given type, or nil. +func (ss *SequenceStatus) GetCondition(t apis.ConditionType) *apis.Condition { + return pCondSet.Manage(ss).GetCondition(t) +} + +// IsReady returns true if the resource is ready overall. +func (ss *SequenceStatus) IsReady() bool { + return pCondSet.Manage(ss).IsHappy() +} + +// InitializeConditions sets relevant unset conditions to Unknown state. +func (ss *SequenceStatus) InitializeConditions() { + pCondSet.Manage(ss).InitializeConditions() +} + +// PropagateSubscriptionStatuses sets the SubscriptionStatuses and SequenceConditionSubscriptionsReady based on +// the status of the incoming subscriptions. +func (ss *SequenceStatus) PropagateSubscriptionStatuses(subscriptions []*messagingv1alpha1.Subscription) { + ss.SubscriptionStatuses = make([]SequenceSubscriptionStatus, len(subscriptions)) + allReady := true + // If there are no subscriptions, treat that as a False case. Could go either way, but this seems right. + if len(subscriptions) == 0 { + allReady = false + + } + for i, s := range subscriptions { + ss.SubscriptionStatuses[i] = SequenceSubscriptionStatus{ + Subscription: corev1.ObjectReference{ + APIVersion: s.APIVersion, + Kind: s.Kind, + Name: s.Name, + Namespace: s.Namespace, + }, + } + readyCondition := s.Status.GetCondition(messagingv1alpha1.SubscriptionConditionReady) + if readyCondition != nil { + ss.SubscriptionStatuses[i].ReadyCondition = *readyCondition + if readyCondition.Status != corev1.ConditionTrue { + allReady = false + } + } else { + allReady = false + } + + } + if allReady { + pCondSet.Manage(ss).MarkTrue(SequenceConditionSubscriptionsReady) + } else { + ss.MarkSubscriptionsNotReady("SubscriptionsNotReady", "Subscriptions are not ready yet, or there are none") + } +} + +// PropagateChannelStatuses sets the ChannelStatuses and SequenceConditionChannelsReady based on the +// status of the incoming channels. +func (ss *SequenceStatus) PropagateChannelStatuses(channels []*duckv1alpha1.Channelable) { + ss.ChannelStatuses = make([]SequenceChannelStatus, len(channels)) + allReady := true + // If there are no channels, treat that as a False case. Could go either way, but this seems right. + if len(channels) == 0 { + allReady = false + + } + for i, c := range channels { + ss.ChannelStatuses[i] = SequenceChannelStatus{ + Channel: corev1.ObjectReference{ + APIVersion: c.APIVersion, + Kind: c.Kind, + Name: c.Name, + Namespace: c.Namespace, + }, + } + // TODO: Once the addressable has a real status to dig through, use that here instead of + // addressable, because it might be addressable but not ready. + address := c.Status.AddressStatus.Address + if address != nil { + ss.ChannelStatuses[i].ReadyCondition = apis.Condition{Type: apis.ConditionReady, Status: corev1.ConditionTrue} + } else { + ss.ChannelStatuses[i].ReadyCondition = apis.Condition{Type: apis.ConditionReady, Status: corev1.ConditionFalse, Reason: "NotAddressable", Message: "Channel is not addressable"} + allReady = false + } + + // Mark the Sequence address as the Address of the first channel. + if i == 0 { + ss.setAddress(address) + } + } + if allReady { + pCondSet.Manage(ss).MarkTrue(SequenceConditionChannelsReady) + } else { + ss.MarkChannelsNotReady("ChannelsNotReady", "Channels are not ready yet, or there are none") + } +} + +func (ss *SequenceStatus) MarkChannelsNotReady(reason, messageFormat string, messageA ...interface{}) { + pCondSet.Manage(ss).MarkFalse(SequenceConditionChannelsReady, reason, messageFormat, messageA...) +} + +func (ss *SequenceStatus) MarkSubscriptionsNotReady(reason, messageFormat string, messageA ...interface{}) { + pCondSet.Manage(ss).MarkFalse(SequenceConditionSubscriptionsReady, reason, messageFormat, messageA...) +} + +func (ss *SequenceStatus) MarkAddressableNotReady(reason, messageFormat string, messageA ...interface{}) { + pCondSet.Manage(ss).MarkFalse(SequenceConditionAddressable, reason, messageFormat, messageA...) +} + +func (ss *SequenceStatus) setAddress(address *pkgduckv1.Addressable) { + ss.Address = address + if address == nil { + pCondSet.Manage(ss).MarkFalse(SequenceConditionAddressable, "emptyAddress", "addressable is nil") + } else { + pCondSet.Manage(ss).MarkTrue(SequenceConditionAddressable) + } +} diff --git a/pkg/apis/flows/v1beta1/sequence_types_test.go b/pkg/apis/flows/v1beta1/sequence_types_test.go new file mode 100644 index 00000000000..511facb4719 --- /dev/null +++ b/pkg/apis/flows/v1beta1/sequence_types_test.go @@ -0,0 +1,34 @@ +/* + * 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 "testing" + +func TestSequenceKind(t *testing.T) { + sequence := Sequence{} + if sequence.GetGroupVersionKind().String() != "flows.knative.dev/v1beta1, Kind=Sequence" { + t.Errorf("unexpected gvk: %v", sequence.GetGroupVersionKind()) + } +} + +func TestSequence_GetGroupVersionKind(t *testing.T) { + s := Sequence{} + gvk := s.GetGroupVersionKind() + if gvk.Kind != "Sequence" { + t.Errorf("Should be Sequence.") + } +} diff --git a/pkg/apis/flows/v1beta1/sequence_validation.go b/pkg/apis/flows/v1beta1/sequence_validation.go new file mode 100644 index 00000000000..ac91f63d1cd --- /dev/null +++ b/pkg/apis/flows/v1beta1/sequence_validation.go @@ -0,0 +1,60 @@ +/* + * 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" + + "knative.dev/pkg/apis" +) + +func (p *Sequence) Validate(ctx context.Context) *apis.FieldError { + return p.Spec.Validate(ctx).ViaField("spec") +} + +func (ps *SequenceSpec) Validate(ctx context.Context) *apis.FieldError { + var errs *apis.FieldError + + if len(ps.Steps) == 0 { + errs = errs.Also(apis.ErrMissingField("steps")) + } + + for i, s := range ps.Steps { + if e := s.Validate(ctx); e != nil { + errs = errs.Also(apis.ErrInvalidArrayValue(s, "steps", i)) + } + } + + if ps.ChannelTemplate == nil { + errs = errs.Also(apis.ErrMissingField("channelTemplate")) + return errs + } + + if len(ps.ChannelTemplate.APIVersion) == 0 { + errs = errs.Also(apis.ErrMissingField("channelTemplate.apiVersion")) + } + + if len(ps.ChannelTemplate.Kind) == 0 { + errs = errs.Also(apis.ErrMissingField("channelTemplate.kind")) + } + + if err := ps.Reply.Validate(ctx); err != nil { + errs = errs.Also(err.ViaField("reply")) + } + + return errs +} diff --git a/pkg/apis/flows/v1beta1/test_helpers.go b/pkg/apis/flows/v1beta1/test_helpers.go new file mode 100644 index 00000000000..fece9bf9960 --- /dev/null +++ b/pkg/apis/flows/v1beta1/test_helpers.go @@ -0,0 +1,39 @@ +/* + * 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 ( + "github.com/google/go-cmp/cmp/cmpopts" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + // DO NOT SUBMIT. Change to v1beta1 before merge + eventingduckv1alpha1 "knative.dev/eventing/pkg/apis/duck/v1alpha1" + "knative.dev/pkg/apis" +) + +var ( + defaultChannelTemplate = &eventingduckv1alpha1.ChannelTemplateSpec{ + TypeMeta: v1.TypeMeta{ + APIVersion: SchemeGroupVersion.String(), + Kind: "InMemoryChannel", + }, + } + + ignoreAllButTypeAndStatus = cmpopts.IgnoreFields( + apis.Condition{}, + "LastTransitionTime", "Message", "Reason", "Severity") +) From 1fdf410969007b28e54828ec86c3d761164cedc4 Mon Sep 17 00:00:00 2001 From: Ville Aikas Date: Fri, 17 Jan 2020 20:24:19 -0800 Subject: [PATCH 4/7] move methods to lifecycle where they belong --- pkg/apis/flows/v1beta1/parallel_lifecycle.go | 11 +++++++++++ pkg/apis/flows/v1beta1/parallel_types.go | 11 ----------- pkg/apis/flows/v1beta1/sequence_lifecycle.go | 11 +++++++++++ pkg/apis/flows/v1beta1/sequence_types.go | 11 ----------- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/pkg/apis/flows/v1beta1/parallel_lifecycle.go b/pkg/apis/flows/v1beta1/parallel_lifecycle.go index 5de64391e72..bc70d10f13e 100644 --- a/pkg/apis/flows/v1beta1/parallel_lifecycle.go +++ b/pkg/apis/flows/v1beta1/parallel_lifecycle.go @@ -21,6 +21,7 @@ import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime/schema" duckv1alpha1 "knative.dev/eventing/pkg/apis/duck/v1alpha1" messagingv1alpha1 "knative.dev/eventing/pkg/apis/messaging/v1alpha1" "knative.dev/pkg/apis" @@ -52,6 +53,16 @@ const ( ParallelConditionAddressable apis.ConditionType = "Addressable" ) +// GetGroupVersionKind returns GroupVersionKind for Parallel +func (p *Parallel) GetGroupVersionKind() schema.GroupVersionKind { + return SchemeGroupVersion.WithKind("Parallel") +} + +// GetUntypedSpec returns the spec of the Parallel. +func (p *Parallel) GetUntypedSpec() interface{} { + return p.Spec +} + // GetCondition returns the condition currently associated with the given type, or nil. func (ps *ParallelStatus) GetCondition(t apis.ConditionType) *apis.Condition { return pParallelCondSet.Manage(ps).GetCondition(t) diff --git a/pkg/apis/flows/v1beta1/parallel_types.go b/pkg/apis/flows/v1beta1/parallel_types.go index 5cb66da3732..4302b7a6fb8 100644 --- a/pkg/apis/flows/v1beta1/parallel_types.go +++ b/pkg/apis/flows/v1beta1/parallel_types.go @@ -20,7 +20,6 @@ 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" // DO NOT SUBMIT. Change to v1beta1 before merge eventingduckv1alpha1 "knative.dev/eventing/pkg/apis/duck/v1alpha1" @@ -150,13 +149,3 @@ type ParallelList struct { metav1.ListMeta `json:"metadata,omitempty"` Items []Parallel `json:"items"` } - -// GetGroupVersionKind returns GroupVersionKind for Parallel -func (p *Parallel) GetGroupVersionKind() schema.GroupVersionKind { - return SchemeGroupVersion.WithKind("Parallel") -} - -// GetUntypedSpec returns the spec of the Parallel. -func (p *Parallel) GetUntypedSpec() interface{} { - return p.Spec -} diff --git a/pkg/apis/flows/v1beta1/sequence_lifecycle.go b/pkg/apis/flows/v1beta1/sequence_lifecycle.go index 0433319b1cd..39c05224f12 100644 --- a/pkg/apis/flows/v1beta1/sequence_lifecycle.go +++ b/pkg/apis/flows/v1beta1/sequence_lifecycle.go @@ -18,6 +18,7 @@ package v1beta1 import ( corev1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/runtime/schema" duckv1alpha1 "knative.dev/eventing/pkg/apis/duck/v1alpha1" messagingv1alpha1 "knative.dev/eventing/pkg/apis/messaging/v1alpha1" "knative.dev/pkg/apis" @@ -43,6 +44,16 @@ const ( SequenceConditionAddressable apis.ConditionType = "Addressable" ) +// GetGroupVersionKind returns GroupVersionKind for InMemoryChannels +func (p *Sequence) GetGroupVersionKind() schema.GroupVersionKind { + return SchemeGroupVersion.WithKind("Sequence") +} + +// GetUntypedSpec returns the spec of the Sequence. +func (s *Sequence) GetUntypedSpec() interface{} { + return s.Spec +} + // GetCondition returns the condition currently associated with the given type, or nil. func (ss *SequenceStatus) GetCondition(t apis.ConditionType) *apis.Condition { return pCondSet.Manage(ss).GetCondition(t) diff --git a/pkg/apis/flows/v1beta1/sequence_types.go b/pkg/apis/flows/v1beta1/sequence_types.go index 8a3bf32f2f3..e872ffe024c 100644 --- a/pkg/apis/flows/v1beta1/sequence_types.go +++ b/pkg/apis/flows/v1beta1/sequence_types.go @@ -20,7 +20,6 @@ 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" // DO NOT SUBMIT. Change to v1beta1 before merge eventingduckv1alpha1 "knative.dev/eventing/pkg/apis/duck/v1alpha1" @@ -126,13 +125,3 @@ type SequenceList struct { metav1.ListMeta `json:"metadata,omitempty"` Items []Sequence `json:"items"` } - -// GetGroupVersionKind returns GroupVersionKind for InMemoryChannels -func (p *Sequence) GetGroupVersionKind() schema.GroupVersionKind { - return SchemeGroupVersion.WithKind("Sequence") -} - -// GetUntypedSpec returns the spec of the Sequence. -func (s *Sequence) GetUntypedSpec() interface{} { - return s.Spec -} From ba38e0e1a798de223a762c3df2255be1774d43b1 Mon Sep 17 00:00:00 2001 From: Ville Aikas Date: Tue, 21 Jan 2020 17:49:55 -0800 Subject: [PATCH 5/7] move to messaging v1beta1 now that it was merged --- pkg/apis/flows/v1beta1/parallel_defaults.go | 4 ++-- pkg/apis/flows/v1beta1/parallel_lifecycle.go | 12 ++++++------ pkg/apis/flows/v1beta1/parallel_types.go | 6 ++---- pkg/apis/flows/v1beta1/sequence_defaults.go | 5 ++--- .../flows/v1beta1/sequence_defaults_test.go | 19 +++++++++---------- pkg/apis/flows/v1beta1/sequence_lifecycle.go | 10 +++++----- pkg/apis/flows/v1beta1/sequence_types.go | 6 ++---- pkg/apis/flows/v1beta1/test_helpers.go | 5 ++--- .../flows/v1beta1/zz_generated.deepcopy.go | 6 +++--- .../informers/externalversions/generic.go | 8 ++++---- 10 files changed, 37 insertions(+), 44 deletions(-) diff --git a/pkg/apis/flows/v1beta1/parallel_defaults.go b/pkg/apis/flows/v1beta1/parallel_defaults.go index f98e025ef49..35d575f44c8 100644 --- a/pkg/apis/flows/v1beta1/parallel_defaults.go +++ b/pkg/apis/flows/v1beta1/parallel_defaults.go @@ -19,14 +19,14 @@ package v1beta1 import ( "context" - eventingduckv1alpha1 "knative.dev/eventing/pkg/apis/duck/v1alpha1" + messagingv1beta1 "knative.dev/eventing/pkg/apis/messaging/v1beta1" ) func (s *Parallel) SetDefaults(ctx context.Context) { if s != nil && s.Spec.ChannelTemplate == nil { // The singleton may not have been set, if so ignore it and validation will reject the // Channel. - if cd := eventingduckv1alpha1.ChannelDefaulterSingleton; cd != nil { + if cd := messagingv1beta1.ChannelDefaulterSingleton; cd != nil { channelTemplate := cd.GetDefault(s.Namespace) s.Spec.ChannelTemplate = channelTemplate } diff --git a/pkg/apis/flows/v1beta1/parallel_lifecycle.go b/pkg/apis/flows/v1beta1/parallel_lifecycle.go index bc70d10f13e..2afa304e22a 100644 --- a/pkg/apis/flows/v1beta1/parallel_lifecycle.go +++ b/pkg/apis/flows/v1beta1/parallel_lifecycle.go @@ -22,8 +22,8 @@ import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime/schema" - duckv1alpha1 "knative.dev/eventing/pkg/apis/duck/v1alpha1" - messagingv1alpha1 "knative.dev/eventing/pkg/apis/messaging/v1alpha1" + duckv1beta1 "knative.dev/eventing/pkg/apis/duck/v1beta1" + messagingv1beta1 "knative.dev/eventing/pkg/apis/messaging/v1beta1" "knative.dev/pkg/apis" pkgduckv1 "knative.dev/pkg/apis/duck/v1" ) @@ -80,7 +80,7 @@ func (ps *ParallelStatus) InitializeConditions() { // PropagateSubscriptionStatuses sets the ParallelConditionSubscriptionsReady based on // the status of the incoming subscriptions. -func (ps *ParallelStatus) PropagateSubscriptionStatuses(filterSubscriptions []*messagingv1alpha1.Subscription, subscriptions []*messagingv1alpha1.Subscription) { +func (ps *ParallelStatus) PropagateSubscriptionStatuses(filterSubscriptions []*messagingv1beta1.Subscription, subscriptions []*messagingv1beta1.Subscription) { if ps.BranchStatuses == nil { ps.BranchStatuses = make([]ParallelBranchStatus, len(subscriptions)) } @@ -100,7 +100,7 @@ func (ps *ParallelStatus) PropagateSubscriptionStatuses(filterSubscriptions []*m }, } - readyCondition := s.Status.GetCondition(messagingv1alpha1.SubscriptionConditionReady) + readyCondition := s.Status.GetCondition(messagingv1beta1.SubscriptionConditionReady) if readyCondition != nil { ps.BranchStatuses[i].SubscriptionStatus.ReadyCondition = *readyCondition if readyCondition.Status != corev1.ConditionTrue { @@ -119,7 +119,7 @@ func (ps *ParallelStatus) PropagateSubscriptionStatuses(filterSubscriptions []*m Namespace: fs.Namespace, }, } - readyCondition = fs.Status.GetCondition(messagingv1alpha1.SubscriptionConditionReady) + readyCondition = fs.Status.GetCondition(messagingv1beta1.SubscriptionConditionReady) if readyCondition != nil { ps.BranchStatuses[i].FilterSubscriptionStatus.ReadyCondition = *readyCondition if readyCondition.Status != corev1.ConditionTrue { @@ -139,7 +139,7 @@ func (ps *ParallelStatus) PropagateSubscriptionStatuses(filterSubscriptions []*m // PropagateChannelStatuses sets the ChannelStatuses and ParallelConditionChannelsReady based on the // status of the incoming channels. -func (ps *ParallelStatus) PropagateChannelStatuses(ingressChannel *duckv1alpha1.Channelable, channels []*duckv1alpha1.Channelable) { +func (ps *ParallelStatus) PropagateChannelStatuses(ingressChannel *duckv1beta1.Channelable, channels []*duckv1beta1.Channelable) { if ps.BranchStatuses == nil { ps.BranchStatuses = make([]ParallelBranchStatus, len(channels)) } diff --git a/pkg/apis/flows/v1beta1/parallel_types.go b/pkg/apis/flows/v1beta1/parallel_types.go index 4302b7a6fb8..0bd9ebb3593 100644 --- a/pkg/apis/flows/v1beta1/parallel_types.go +++ b/pkg/apis/flows/v1beta1/parallel_types.go @@ -21,8 +21,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" - // DO NOT SUBMIT. Change to v1beta1 before merge - eventingduckv1alpha1 "knative.dev/eventing/pkg/apis/duck/v1alpha1" + messagingv1beta1 "knative.dev/eventing/pkg/apis/messaging/v1beta1" "knative.dev/pkg/apis" duckv1 "knative.dev/pkg/apis/duck/v1" "knative.dev/pkg/kmeta" @@ -70,8 +69,7 @@ type ParallelSpec struct { // ChannelTemplate specifies which Channel CRD to use. If left unspecified, it is set to the default Channel CRD // for the namespace (or cluster, in case there are no defaults for the namespace). // +optional - // DO NOT SUBMIT. Change to v1beta1 before merge - ChannelTemplate *eventingduckv1alpha1.ChannelTemplateSpec `json:"channelTemplate"` + ChannelTemplate *messagingv1beta1.ChannelTemplateSpec `json:"channelTemplate"` // Reply is a Reference to where the result of a case Subscriber gets sent to // when the case does not have a Reply diff --git a/pkg/apis/flows/v1beta1/sequence_defaults.go b/pkg/apis/flows/v1beta1/sequence_defaults.go index aa15654c9dd..94fe07c5adc 100644 --- a/pkg/apis/flows/v1beta1/sequence_defaults.go +++ b/pkg/apis/flows/v1beta1/sequence_defaults.go @@ -19,15 +19,14 @@ package v1beta1 import ( "context" - // DO NOT SUBMIT. Change to v1beta1 before merge - eventingduckv1alpha1 "knative.dev/eventing/pkg/apis/duck/v1alpha1" + messagingv1beta1 "knative.dev/eventing/pkg/apis/messaging/v1beta1" ) func (s *Sequence) SetDefaults(ctx context.Context) { if s != nil && s.Spec.ChannelTemplate == nil { // The singleton may not have been set, if so ignore it and validation will reject the // Channel. - if cd := eventingduckv1alpha1.ChannelDefaulterSingleton; cd != nil { + if cd := messagingv1beta1.ChannelDefaulterSingleton; cd != nil { channelTemplate := cd.GetDefault(s.Namespace) s.Spec.ChannelTemplate = channelTemplate } diff --git a/pkg/apis/flows/v1beta1/sequence_defaults_test.go b/pkg/apis/flows/v1beta1/sequence_defaults_test.go index 835d7c3432e..6f4bedcb503 100644 --- a/pkg/apis/flows/v1beta1/sequence_defaults_test.go +++ b/pkg/apis/flows/v1beta1/sequence_defaults_test.go @@ -23,12 +23,11 @@ import ( v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "github.com/google/go-cmp/cmp" - // DO NOT SUBMIT. Change to v1beta1 before merge - eventingduckv1alpha1 "knative.dev/eventing/pkg/apis/duck/v1alpha1" + messagingv1beta1 "knative.dev/eventing/pkg/apis/messaging/v1beta1" ) var ( - defaultTemplate = &eventingduckv1alpha1.ChannelTemplateSpec{ + defaultTemplate = &messagingv1beta1.ChannelTemplateSpec{ TypeMeta: v1.TypeMeta{ APIVersion: SchemeGroupVersion.String(), Kind: "InMemoryChannel", @@ -39,7 +38,7 @@ var ( func TestSequenceSetDefaults(t *testing.T) { testCases := map[string]struct { nilChannelDefaulter bool - channelTemplate *eventingduckv1alpha1.ChannelTemplateSpec + channelTemplate *messagingv1beta1.ChannelTemplateSpec initial Sequence expected Sequence }{ @@ -62,7 +61,7 @@ func TestSequenceSetDefaults(t *testing.T) { channelTemplate: defaultChannelTemplate, initial: Sequence{ Spec: SequenceSpec{ - ChannelTemplate: &eventingduckv1alpha1.ChannelTemplateSpec{ + ChannelTemplate: &messagingv1beta1.ChannelTemplateSpec{ TypeMeta: v1.TypeMeta{ APIVersion: SchemeGroupVersion.String(), Kind: "OtherChannel", @@ -72,7 +71,7 @@ func TestSequenceSetDefaults(t *testing.T) { }, expected: Sequence{ Spec: SequenceSpec{ - ChannelTemplate: &eventingduckv1alpha1.ChannelTemplateSpec{ + ChannelTemplate: &messagingv1beta1.ChannelTemplateSpec{ TypeMeta: v1.TypeMeta{ APIVersion: SchemeGroupVersion.String(), Kind: "OtherChannel", @@ -85,10 +84,10 @@ func TestSequenceSetDefaults(t *testing.T) { for n, tc := range testCases { t.Run(n, func(t *testing.T) { if !tc.nilChannelDefaulter { - eventingduckv1alpha1.ChannelDefaulterSingleton = &sequenceChannelDefaulter{ + messagingv1beta1.ChannelDefaulterSingleton = &sequenceChannelDefaulter{ channelTemplate: tc.channelTemplate, } - defer func() { eventingduckv1alpha1.ChannelDefaulterSingleton = nil }() + defer func() { messagingv1beta1.ChannelDefaulterSingleton = nil }() } tc.initial.SetDefaults(context.TODO()) if diff := cmp.Diff(tc.expected, tc.initial); diff != "" { @@ -99,9 +98,9 @@ func TestSequenceSetDefaults(t *testing.T) { } type sequenceChannelDefaulter struct { - channelTemplate *eventingduckv1alpha1.ChannelTemplateSpec + channelTemplate *messagingv1beta1.ChannelTemplateSpec } -func (cd *sequenceChannelDefaulter) GetDefault(_ string) *eventingduckv1alpha1.ChannelTemplateSpec { +func (cd *sequenceChannelDefaulter) GetDefault(_ string) *messagingv1beta1.ChannelTemplateSpec { return cd.channelTemplate } diff --git a/pkg/apis/flows/v1beta1/sequence_lifecycle.go b/pkg/apis/flows/v1beta1/sequence_lifecycle.go index 39c05224f12..9c0a9010614 100644 --- a/pkg/apis/flows/v1beta1/sequence_lifecycle.go +++ b/pkg/apis/flows/v1beta1/sequence_lifecycle.go @@ -19,8 +19,8 @@ package v1beta1 import ( corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/runtime/schema" - duckv1alpha1 "knative.dev/eventing/pkg/apis/duck/v1alpha1" - messagingv1alpha1 "knative.dev/eventing/pkg/apis/messaging/v1alpha1" + duckv1beta1 "knative.dev/eventing/pkg/apis/duck/v1beta1" + messagingv1beta1 "knative.dev/eventing/pkg/apis/messaging/v1beta1" "knative.dev/pkg/apis" pkgduckv1 "knative.dev/pkg/apis/duck/v1" ) @@ -71,7 +71,7 @@ func (ss *SequenceStatus) InitializeConditions() { // PropagateSubscriptionStatuses sets the SubscriptionStatuses and SequenceConditionSubscriptionsReady based on // the status of the incoming subscriptions. -func (ss *SequenceStatus) PropagateSubscriptionStatuses(subscriptions []*messagingv1alpha1.Subscription) { +func (ss *SequenceStatus) PropagateSubscriptionStatuses(subscriptions []*messagingv1beta1.Subscription) { ss.SubscriptionStatuses = make([]SequenceSubscriptionStatus, len(subscriptions)) allReady := true // If there are no subscriptions, treat that as a False case. Could go either way, but this seems right. @@ -88,7 +88,7 @@ func (ss *SequenceStatus) PropagateSubscriptionStatuses(subscriptions []*messagi Namespace: s.Namespace, }, } - readyCondition := s.Status.GetCondition(messagingv1alpha1.SubscriptionConditionReady) + readyCondition := s.Status.GetCondition(messagingv1beta1.SubscriptionConditionReady) if readyCondition != nil { ss.SubscriptionStatuses[i].ReadyCondition = *readyCondition if readyCondition.Status != corev1.ConditionTrue { @@ -108,7 +108,7 @@ func (ss *SequenceStatus) PropagateSubscriptionStatuses(subscriptions []*messagi // PropagateChannelStatuses sets the ChannelStatuses and SequenceConditionChannelsReady based on the // status of the incoming channels. -func (ss *SequenceStatus) PropagateChannelStatuses(channels []*duckv1alpha1.Channelable) { +func (ss *SequenceStatus) PropagateChannelStatuses(channels []*duckv1beta1.Channelable) { ss.ChannelStatuses = make([]SequenceChannelStatus, len(channels)) allReady := true // If there are no channels, treat that as a False case. Could go either way, but this seems right. diff --git a/pkg/apis/flows/v1beta1/sequence_types.go b/pkg/apis/flows/v1beta1/sequence_types.go index e872ffe024c..60a637f9ae9 100644 --- a/pkg/apis/flows/v1beta1/sequence_types.go +++ b/pkg/apis/flows/v1beta1/sequence_types.go @@ -21,8 +21,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" - // DO NOT SUBMIT. Change to v1beta1 before merge - eventingduckv1alpha1 "knative.dev/eventing/pkg/apis/duck/v1alpha1" + messagingv1beta1 "knative.dev/eventing/pkg/apis/messaging/v1beta1" "knative.dev/pkg/apis" duckv1 "knative.dev/pkg/apis/duck/v1" "knative.dev/pkg/kmeta" @@ -71,8 +70,7 @@ type SequenceSpec struct { // ChannelTemplate specifies which Channel CRD to use. If left unspecified, it is set to the default Channel CRD // for the namespace (or cluster, in case there are no defaults for the namespace). // +optional - // DO NOT SUBMIT. Change to v1beta1 before merge - ChannelTemplate *eventingduckv1alpha1.ChannelTemplateSpec `json:"channelTemplate,omitempty"` + ChannelTemplate *messagingv1beta1.ChannelTemplateSpec `json:"channelTemplate,omitempty"` // Reply is a Reference to where the result of the last Subscriber gets sent to. // +optional diff --git a/pkg/apis/flows/v1beta1/test_helpers.go b/pkg/apis/flows/v1beta1/test_helpers.go index fece9bf9960..e49a52ad39f 100644 --- a/pkg/apis/flows/v1beta1/test_helpers.go +++ b/pkg/apis/flows/v1beta1/test_helpers.go @@ -20,13 +20,12 @@ import ( "github.com/google/go-cmp/cmp/cmpopts" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - // DO NOT SUBMIT. Change to v1beta1 before merge - eventingduckv1alpha1 "knative.dev/eventing/pkg/apis/duck/v1alpha1" + messagingv1beta1 "knative.dev/eventing/pkg/apis/messaging/v1beta1" "knative.dev/pkg/apis" ) var ( - defaultChannelTemplate = &eventingduckv1alpha1.ChannelTemplateSpec{ + defaultChannelTemplate = &messagingv1beta1.ChannelTemplateSpec{ TypeMeta: v1.TypeMeta{ APIVersion: SchemeGroupVersion.String(), Kind: "InMemoryChannel", diff --git a/pkg/apis/flows/v1beta1/zz_generated.deepcopy.go b/pkg/apis/flows/v1beta1/zz_generated.deepcopy.go index 8b958cb7b36..935f90a4787 100644 --- a/pkg/apis/flows/v1beta1/zz_generated.deepcopy.go +++ b/pkg/apis/flows/v1beta1/zz_generated.deepcopy.go @@ -22,7 +22,7 @@ package v1beta1 import ( runtime "k8s.io/apimachinery/pkg/runtime" - v1alpha1 "knative.dev/eventing/pkg/apis/duck/v1alpha1" + messagingv1beta1 "knative.dev/eventing/pkg/apis/messaging/v1beta1" v1 "knative.dev/pkg/apis/duck/v1" ) @@ -163,7 +163,7 @@ func (in *ParallelSpec) DeepCopyInto(out *ParallelSpec) { } if in.ChannelTemplate != nil { in, out := &in.ChannelTemplate, &out.ChannelTemplate - *out = new(v1alpha1.ChannelTemplateSpec) + *out = new(messagingv1beta1.ChannelTemplateSpec) (*in).DeepCopyInto(*out) } if in.Reply != nil { @@ -319,7 +319,7 @@ func (in *SequenceSpec) DeepCopyInto(out *SequenceSpec) { } if in.ChannelTemplate != nil { in, out := &in.ChannelTemplate, &out.ChannelTemplate - *out = new(v1alpha1.ChannelTemplateSpec) + *out = new(messagingv1beta1.ChannelTemplateSpec) (*in).DeepCopyInto(*out) } if in.Reply != nil { diff --git a/pkg/client/informers/externalversions/generic.go b/pkg/client/informers/externalversions/generic.go index cc86623fe48..190ef48cf92 100644 --- a/pkg/client/informers/externalversions/generic.go +++ b/pkg/client/informers/externalversions/generic.go @@ -27,7 +27,7 @@ import ( flowsv1alpha1 "knative.dev/eventing/pkg/apis/flows/v1alpha1" v1beta1 "knative.dev/eventing/pkg/apis/flows/v1beta1" messagingv1alpha1 "knative.dev/eventing/pkg/apis/messaging/v1alpha1" - v1beta1 "knative.dev/eventing/pkg/apis/messaging/v1beta1" + messagingv1beta1 "knative.dev/eventing/pkg/apis/messaging/v1beta1" sourcesv1alpha1 "knative.dev/eventing/pkg/apis/sources/v1alpha1" ) @@ -90,11 +90,11 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource return &genericInformer{resource: resource.GroupResource(), informer: f.Messaging().V1alpha1().Subscriptions().Informer()}, nil // Group=messaging.knative.dev, Version=v1beta1 - case v1beta1.SchemeGroupVersion.WithResource("channels"): + case messagingv1beta1.SchemeGroupVersion.WithResource("channels"): return &genericInformer{resource: resource.GroupResource(), informer: f.Messaging().V1beta1().Channels().Informer()}, nil - case v1beta1.SchemeGroupVersion.WithResource("inmemorychannels"): + case messagingv1beta1.SchemeGroupVersion.WithResource("inmemorychannels"): return &genericInformer{resource: resource.GroupResource(), informer: f.Messaging().V1beta1().InMemoryChannels().Informer()}, nil - case v1beta1.SchemeGroupVersion.WithResource("subscriptions"): + case messagingv1beta1.SchemeGroupVersion.WithResource("subscriptions"): return &genericInformer{resource: resource.GroupResource(), informer: f.Messaging().V1beta1().Subscriptions().Informer()}, nil // Group=sources.knative.dev, Version=v1alpha1 From 2e764456647d0a23f4f0122272569904d420198c Mon Sep 17 00:00:00 2001 From: Ville Aikas Date: Tue, 21 Jan 2020 18:10:31 -0800 Subject: [PATCH 6/7] address pr feedback --- pkg/apis/flows/v1beta1/parallel_lifecycle.go | 43 +------------------ .../v1beta1/subscription_lifecycle.go | 5 +++ 2 files changed, 6 insertions(+), 42 deletions(-) diff --git a/pkg/apis/flows/v1beta1/parallel_lifecycle.go b/pkg/apis/flows/v1beta1/parallel_lifecycle.go index 2afa304e22a..b6be730ec7d 100644 --- a/pkg/apis/flows/v1beta1/parallel_lifecycle.go +++ b/pkg/apis/flows/v1beta1/parallel_lifecycle.go @@ -17,10 +17,7 @@ package v1beta1 import ( - "time" - corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime/schema" duckv1beta1 "knative.dev/eventing/pkg/apis/duck/v1beta1" messagingv1beta1 "knative.dev/eventing/pkg/apis/messaging/v1beta1" @@ -30,12 +27,6 @@ import ( var pParallelCondSet = apis.NewLivingConditionSet(ParallelConditionReady, ParallelConditionChannelsReady, ParallelConditionSubscriptionsReady, ParallelConditionAddressable) -const ( - // StatusConditionTypeDeprecated is the status.conditions.type used to provide deprecation - // warnings. - StatusConditionTypeDeprecated = "Deprecated" -) - const ( // ParallelConditionReady has status True when all subconditions below have been set to True. ParallelConditionReady = apis.ConditionReady @@ -100,7 +91,7 @@ func (ps *ParallelStatus) PropagateSubscriptionStatuses(filterSubscriptions []*m }, } - readyCondition := s.Status.GetCondition(messagingv1beta1.SubscriptionConditionReady) + readyCondition := s.Status.GetTopLevelCondition() if readyCondition != nil { ps.BranchStatuses[i].SubscriptionStatus.ReadyCondition = *readyCondition if readyCondition.Status != corev1.ConditionTrue { @@ -207,35 +198,3 @@ func (ps *ParallelStatus) setAddress(address *pkgduckv1.Addressable) { pParallelCondSet.Manage(ps).MarkTrue(ParallelConditionAddressable) } } - -// MarkDeprecated adds a warning condition that this object's spec is using deprecated fields -// and will stop working in the future. Note that this does not affect the Ready condition. -func (ps *ParallelStatus) MarkDestinationDeprecatedRef(reason, msg string) { - dc := apis.Condition{ - Type: StatusConditionTypeDeprecated, - Reason: reason, - Status: corev1.ConditionTrue, - Severity: apis.ConditionSeverityWarning, - Message: msg, - LastTransitionTime: apis.VolatileTime{Inner: metav1.NewTime(time.Now())}, - } - for i, c := range ps.Conditions { - if c.Type == dc.Type { - ps.Conditions[i] = dc - return - } - } - ps.Conditions = append(ps.Conditions, dc) -} - -// ClearDeprecated removes the StatusConditionTypeDeprecated warning condition. Note that this does not -// affect the Ready condition. -func (ps *ParallelStatus) ClearDeprecated() { - conds := make([]apis.Condition, 0, len(ps.Conditions)) - for _, c := range ps.Conditions { - if c.Type != StatusConditionTypeDeprecated { - conds = append(conds, c) - } - } - ps.Conditions = conds -} diff --git a/pkg/apis/messaging/v1beta1/subscription_lifecycle.go b/pkg/apis/messaging/v1beta1/subscription_lifecycle.go index 2b8c43e8bd8..0637356d21f 100644 --- a/pkg/apis/messaging/v1beta1/subscription_lifecycle.go +++ b/pkg/apis/messaging/v1beta1/subscription_lifecycle.go @@ -44,6 +44,11 @@ func (ss *SubscriptionStatus) GetCondition(t apis.ConditionType) *apis.Condition return SubCondSet.Manage(ss).GetCondition(t) } +// GetTopLevelCondition returns the top level Condition. +func (ss *SubscriptionStatus) GetTopLevelCondition() *apis.Condition { + return SubCondSet.Manage(ss).GetTopLevelCondition() +} + // IsReady returns true if the resource is ready overall. func (ss *SubscriptionStatus) IsReady() bool { return SubCondSet.Manage(ss).IsHappy() From 83ffba1e79eb6410e1a871a3421b0d5e610575fb Mon Sep 17 00:00:00 2001 From: Ville Aikas Date: Thu, 23 Jan 2020 11:46:49 -0800 Subject: [PATCH 7/7] mark ParallelBranch.Filter as optional --- pkg/apis/flows/v1beta1/parallel_types.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/apis/flows/v1beta1/parallel_types.go b/pkg/apis/flows/v1beta1/parallel_types.go index 0bd9ebb3593..510a2397d37 100644 --- a/pkg/apis/flows/v1beta1/parallel_types.go +++ b/pkg/apis/flows/v1beta1/parallel_types.go @@ -79,6 +79,7 @@ type ParallelSpec struct { type ParallelBranch struct { // Filter is the expression guarding the branch + // +optional Filter *duckv1.Destination `json:"filter,omitempty"` // Subscriber receiving the event when the filter passes