From 8dbd3eafe8a8cd4fb797295831de4c15d27f0511 Mon Sep 17 00:00:00 2001 From: Ville Aikas Date: Wed, 6 Nov 2019 18:59:49 -0800 Subject: [PATCH 1/4] move parallel/sequence to flows.knative.dev api group --- hack/update-codegen.sh | 4 +- pkg/apis/flows/register.go | 21 + pkg/apis/flows/v1beta1/doc.go | 20 + pkg/apis/flows/v1beta1/parallel_defaults.go | 37 ++ .../flows/v1beta1/parallel_defaults_test.go | 97 ++++ pkg/apis/flows/v1beta1/parallel_lifecycle.go | 238 ++++++++++ .../flows/v1beta1/parallel_lifecycle_test.go | 442 ++++++++++++++++++ pkg/apis/flows/v1beta1/parallel_types.go | 161 +++++++ pkg/apis/flows/v1beta1/parallel_types_test.go | 26 ++ pkg/apis/flows/v1beta1/parallel_validation.go | 68 +++ .../flows/v1beta1/parallel_validation_test.go | 177 +++++++ pkg/apis/flows/v1beta1/register.go | 55 +++ pkg/apis/flows/v1beta1/register_test.go | 68 +++ pkg/apis/flows/v1beta1/sequence_defaults.go | 37 ++ .../flows/v1beta1/sequence_defaults_test.go | 106 +++++ pkg/apis/flows/v1beta1/sequence_lifecycle.go | 200 ++++++++ .../flows/v1beta1/sequence_lifecycle_test.go | 412 ++++++++++++++++ pkg/apis/flows/v1beta1/sequence_types.go | 137 ++++++ pkg/apis/flows/v1beta1/sequence_types_test.go | 34 ++ pkg/apis/flows/v1beta1/sequence_validation.go | 60 +++ .../flows/v1beta1/sequence_validation_test.go | 175 +++++++ pkg/apis/flows/v1beta1/test_helpers.go | 37 ++ .../flows/v1beta1/zz_generated.deepcopy.go | 391 ++++++++++++++++ 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 ++++++++ .../informers/externalversions/factory.go | 6 + .../externalversions/flows/interface.go | 46 ++ .../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 ++++ 49 files changed, 4585 insertions(+), 2 deletions(-) create mode 100644 pkg/apis/flows/register.go create mode 100644 pkg/apis/flows/v1beta1/doc.go create mode 100644 pkg/apis/flows/v1beta1/parallel_defaults.go create mode 100644 pkg/apis/flows/v1beta1/parallel_defaults_test.go create mode 100644 pkg/apis/flows/v1beta1/parallel_lifecycle.go create mode 100644 pkg/apis/flows/v1beta1/parallel_lifecycle_test.go create mode 100644 pkg/apis/flows/v1beta1/parallel_types.go create mode 100644 pkg/apis/flows/v1beta1/parallel_types_test.go create mode 100644 pkg/apis/flows/v1beta1/parallel_validation.go create mode 100644 pkg/apis/flows/v1beta1/parallel_validation_test.go create mode 100644 pkg/apis/flows/v1beta1/register.go create mode 100644 pkg/apis/flows/v1beta1/register_test.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_lifecycle_test.go create mode 100644 pkg/apis/flows/v1beta1/sequence_types.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/sequence_validation_test.go create mode 100644 pkg/apis/flows/v1beta1/test_helpers.go create mode 100644 pkg/apis/flows/v1beta1/zz_generated.deepcopy.go 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/interface.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/hack/update-codegen.sh b/hack/update-codegen.sh index faaf870c1d0..fcd93d43559 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 ./ven # 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 sources:v1alpha1 messaging:v1alpha1" \ + "eventing:v1alpha1 sources:v1alpha1 messaging:v1alpha1 flows:v1beta1" \ --go-header-file ${REPO_ROOT_DIR}/hack/boilerplate/boilerplate.go.txt # Only deepcopy the Duck types, as they are not real resources. @@ -42,7 +42,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 sources:v1alpha1 messaging:v1alpha1" \ + "eventing:v1alpha1 sources:v1alpha1 messaging:v1alpha1 flows:v1beta1" \ --go-header-file ${REPO_ROOT_DIR}/hack/boilerplate/boilerplate.go.txt # Make sure our dependencies are up-to-date diff --git a/pkg/apis/flows/register.go b/pkg/apis/flows/register.go new file mode 100644 index 00000000000..bf9e7baf01c --- /dev/null +++ b/pkg/apis/flows/register.go @@ -0,0 +1,21 @@ +/* +Copyright 2018 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 flows + +const ( + GroupName = "flows.knative.dev" +) diff --git a/pkg/apis/flows/v1beta1/doc.go b/pkg/apis/flows/v1beta1/doc.go new file mode 100644 index 00000000000..f194c62c1eb --- /dev/null +++ b/pkg/apis/flows/v1beta1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2019 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Package v1alpha1 is the v1alpha1 version of the API. +// +k8s:deepcopy-gen=package +// +groupName=flows.knative.dev +package v1beta1 diff --git a/pkg/apis/flows/v1beta1/parallel_defaults.go b/pkg/apis/flows/v1beta1/parallel_defaults.go new file mode 100644 index 00000000000..20f90179854 --- /dev/null +++ b/pkg/apis/flows/v1beta1/parallel_defaults.go @@ -0,0 +1,37 @@ +/* +Copyright 2019 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package 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_defaults_test.go b/pkg/apis/flows/v1beta1/parallel_defaults_test.go new file mode 100644 index 00000000000..893a6f6b41b --- /dev/null +++ b/pkg/apis/flows/v1beta1/parallel_defaults_test.go @@ -0,0 +1,97 @@ +/* +Copyright 2019 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1beta1 + +import ( + "context" + "testing" + + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + "github.com/google/go-cmp/cmp" + eventingduckv1alpha1 "knative.dev/eventing/pkg/apis/duck/v1alpha1" +) + +func TestParallelSetDefaults(t *testing.T) { + testCases := map[string]struct { + nilChannelDefaulter bool + channelTemplate *eventingduckv1alpha1.ChannelTemplateSpec + initial Parallel + expected Parallel + }{ + "nil ChannelDefaulter": { + nilChannelDefaulter: true, + expected: Parallel{}, + }, + "unset ChannelDefaulter": { + expected: Parallel{}, + }, + "set ChannelDefaulter": { + channelTemplate: defaultChannelTemplate, + expected: Parallel{ + Spec: ParallelSpec{ + ChannelTemplate: defaultChannelTemplate, + }, + }, + }, + "template already specified": { + channelTemplate: defaultChannelTemplate, + initial: Parallel{ + Spec: ParallelSpec{ + ChannelTemplate: &eventingduckv1alpha1.ChannelTemplateSpec{ + TypeMeta: v1.TypeMeta{ + APIVersion: SchemeGroupVersion.String(), + Kind: "OtherChannel", + }, + }, + }, + }, + expected: Parallel{ + Spec: ParallelSpec{ + 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 = ¶llelChannelDefaulter{ + 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 parallelChannelDefaulter struct { + channelTemplate *eventingduckv1alpha1.ChannelTemplateSpec +} + +func (cd *parallelChannelDefaulter) GetDefault(_ string) *eventingduckv1alpha1.ChannelTemplateSpec { + return cd.channelTemplate +} diff --git a/pkg/apis/flows/v1beta1/parallel_lifecycle.go b/pkg/apis/flows/v1beta1/parallel_lifecycle.go new file mode 100644 index 00000000000..b3e1af1f5a5 --- /dev/null +++ b/pkg/apis/flows/v1beta1/parallel_lifecycle.go @@ -0,0 +1,238 @@ +/* + * Copyright 2019 The Knative Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package 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" + pkgduckv1alpha1 "knative.dev/pkg/apis/duck/v1alpha1" +) + +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 + } + // Propagate ingress channel address to Parallel + 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 *pkgduckv1alpha1.Addressable) { + ps.Address = address + + if address == nil { + pParallelCondSet.Manage(ps).MarkFalse(ParallelConditionAddressable, "emptyHostname", "hostname is the empty string") + return + } + if address.URL != nil || address.Hostname != "" { + pParallelCondSet.Manage(ps).MarkTrue(ParallelConditionAddressable) + } else { + ps.Address.Hostname = "" + ps.Address.URL = nil + pParallelCondSet.Manage(ps).MarkFalse(ParallelConditionAddressable, "emptyHostname", "hostname is the empty string") + } +} + +// 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_lifecycle_test.go b/pkg/apis/flows/v1beta1/parallel_lifecycle_test.go new file mode 100644 index 00000000000..546bcd10e9a --- /dev/null +++ b/pkg/apis/flows/v1beta1/parallel_lifecycle_test.go @@ -0,0 +1,442 @@ +/* +Copyright 2019 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1beta1 + +import ( + "testing" + + "knative.dev/pkg/apis" + + "github.com/google/go-cmp/cmp" + 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" + duckv1 "knative.dev/pkg/apis/duck/v1" + pkgduckv1alpha1 "knative.dev/pkg/apis/duck/v1alpha1" + duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" +) + +var parallelConditionReady = apis.Condition{ + Type: ParallelConditionReady, + Status: corev1.ConditionTrue, +} + +var parallelConditionChannelsReady = apis.Condition{ + Type: ParallelConditionChannelsReady, + Status: corev1.ConditionTrue, +} + +var parallelConditionSubscriptionsReady = apis.Condition{ + Type: ParallelConditionSubscriptionsReady, + Status: corev1.ConditionTrue, +} + +func TestParallelGetCondition(t *testing.T) { + tests := []struct { + name string + ss *ParallelStatus + condQuery apis.ConditionType + want *apis.Condition + }{{ + name: "single condition", + ss: &ParallelStatus{ + Status: duckv1.Status{ + Conditions: []apis.Condition{ + parallelConditionReady, + }, + }, + }, + condQuery: apis.ConditionReady, + want: ¶llelConditionReady, + }} + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + got := test.ss.GetCondition(test.condQuery) + if diff := cmp.Diff(test.want, got); diff != "" { + t.Errorf("unexpected condition (-want, +got) = %v", diff) + } + }) + } +} + +func TestParallelInitializeConditions(t *testing.T) { + tests := []struct { + name string + ts *ParallelStatus + want *ParallelStatus + }{{ + name: "empty", + ts: &ParallelStatus{}, + want: &ParallelStatus{ + Status: duckv1.Status{ + Conditions: []apis.Condition{{ + Type: ParallelConditionAddressable, + Status: corev1.ConditionUnknown, + }, { + Type: ParallelConditionChannelsReady, + Status: corev1.ConditionUnknown, + }, { + Type: ParallelConditionReady, + Status: corev1.ConditionUnknown, + }, { + Type: ParallelConditionSubscriptionsReady, + Status: corev1.ConditionUnknown, + }}, + }, + }, + }, { + name: "one false", + ts: &ParallelStatus{ + Status: duckv1.Status{ + Conditions: []apis.Condition{{ + Type: ParallelConditionChannelsReady, + Status: corev1.ConditionFalse, + }}, + }, + }, + want: &ParallelStatus{ + Status: duckv1.Status{ + Conditions: []apis.Condition{{ + Type: ParallelConditionAddressable, + Status: corev1.ConditionUnknown, + }, { + Type: ParallelConditionChannelsReady, + Status: corev1.ConditionFalse, + }, { + Type: ParallelConditionReady, + Status: corev1.ConditionUnknown, + }, { + Type: ParallelConditionSubscriptionsReady, + Status: corev1.ConditionUnknown, + }}, + }, + }, + }, { + name: "one true", + ts: &ParallelStatus{ + Status: duckv1.Status{ + Conditions: []apis.Condition{{ + Type: ParallelConditionSubscriptionsReady, + Status: corev1.ConditionTrue, + }}, + }, + }, + want: &ParallelStatus{ + Status: duckv1.Status{ + Conditions: []apis.Condition{{ + Type: ParallelConditionAddressable, + Status: corev1.ConditionUnknown, + }, { + Type: ParallelConditionChannelsReady, + Status: corev1.ConditionUnknown, + }, { + Type: ParallelConditionReady, + Status: corev1.ConditionUnknown, + }, { + Type: ParallelConditionSubscriptionsReady, + Status: corev1.ConditionTrue, + }}, + }, + }, + }} + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + test.ts.InitializeConditions() + if diff := cmp.Diff(test.want, test.ts, ignoreAllButTypeAndStatus); diff != "" { + t.Errorf("unexpected conditions (-want, +got) = %v", diff) + } + }) + } +} + +func TestParallelPropagateSubscriptionStatuses(t *testing.T) { + tests := []struct { + name string + fsubs []*messagingv1alpha1.Subscription + subs []*messagingv1alpha1.Subscription + want corev1.ConditionStatus + }{{ + name: "empty", + fsubs: []*messagingv1alpha1.Subscription{}, + subs: []*messagingv1alpha1.Subscription{}, + want: corev1.ConditionFalse, + }, { + name: "empty status", + fsubs: []*messagingv1alpha1.Subscription{{ + TypeMeta: metav1.TypeMeta{ + APIVersion: "messaging.knative.dev/v1alpha1", + Kind: "Subscription", + }, + ObjectMeta: metav1.ObjectMeta{ + Name: "sub", + Namespace: "testns", + }, + Status: messagingv1alpha1.SubscriptionStatus{}, + }}, subs: []*messagingv1alpha1.Subscription{{ + TypeMeta: metav1.TypeMeta{ + APIVersion: "messaging.knative.dev/v1alpha1", + Kind: "Subscription", + }, + ObjectMeta: metav1.ObjectMeta{ + Name: "sub", + Namespace: "testns", + }, + Status: messagingv1alpha1.SubscriptionStatus{}, + }}, + want: corev1.ConditionFalse, + }, { + name: "one filter and subscriber subscription not ready", + fsubs: []*messagingv1alpha1.Subscription{getSubscription("fsub0", false)}, + subs: []*messagingv1alpha1.Subscription{getSubscription("sub0", false)}, + want: corev1.ConditionFalse, + }, { + name: "one filter and one subscription ready", + fsubs: []*messagingv1alpha1.Subscription{getSubscription("fsub0", true)}, + subs: []*messagingv1alpha1.Subscription{getSubscription("sub0", true)}, + want: corev1.ConditionTrue, + }, { + name: "one filter subscription not ready and one subscription ready", + fsubs: []*messagingv1alpha1.Subscription{getSubscription("fsub0", false)}, + subs: []*messagingv1alpha1.Subscription{getSubscription("sub0", true)}, + want: corev1.ConditionFalse, + }, { + name: "one subscription ready, one not", + fsubs: []*messagingv1alpha1.Subscription{getSubscription("fsub0", true), getSubscription("fsub1", false)}, + subs: []*messagingv1alpha1.Subscription{getSubscription("sub0", true), getSubscription("sub1", false)}, + want: corev1.ConditionFalse, + }, { + name: "two subscriptions ready", + fsubs: []*messagingv1alpha1.Subscription{getSubscription("fsub0", true), getSubscription("fsub1", true)}, + subs: []*messagingv1alpha1.Subscription{getSubscription("sub0", true), getSubscription("sub1", true)}, + want: corev1.ConditionTrue, + }} + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + ps := ParallelStatus{} + ps.PropagateSubscriptionStatuses(test.fsubs, test.subs) + got := ps.GetCondition(ParallelConditionSubscriptionsReady).Status + want := test.want + if want != got { + t.Errorf("unexpected conditions (-want, +got) = %v %v", want, got) + } + }) + } +} + +func TestParallelPropagateChannelStatuses(t *testing.T) { + tests := []struct { + name string + ichannel *duckv1alpha1.Channelable + channels []*duckv1alpha1.Channelable + want corev1.ConditionStatus + }{{ + name: "ingress false, empty", + ichannel: getChannelable(false), + channels: []*duckv1alpha1.Channelable{}, + want: corev1.ConditionFalse, + }, { + name: "ingress false, one channelable not ready", + ichannel: getChannelable(false), + channels: []*duckv1alpha1.Channelable{getChannelable(false)}, + want: corev1.ConditionFalse, + }, { + name: "ingress true, one channelable not ready", + ichannel: getChannelable(true), + channels: []*duckv1alpha1.Channelable{getChannelable(false)}, + want: corev1.ConditionFalse, + }, { + name: "ingress false, one channelable ready", + ichannel: getChannelable(false), + channels: []*duckv1alpha1.Channelable{getChannelable(true)}, + want: corev1.ConditionFalse, + }, { + name: "ingress true, one channelable ready", + ichannel: getChannelable(true), + channels: []*duckv1alpha1.Channelable{getChannelable(true)}, + want: corev1.ConditionTrue, + }, { + name: "ingress true, one channelable ready, one not", + ichannel: getChannelable(true), + channels: []*duckv1alpha1.Channelable{getChannelable(true), getChannelable(false)}, + want: corev1.ConditionFalse, + }, { + name: "ingress true, two channelables ready", + ichannel: getChannelable(true), + channels: []*duckv1alpha1.Channelable{getChannelable(true), getChannelable(true)}, + want: corev1.ConditionTrue, + }} + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + ps := ParallelStatus{} + ps.PropagateChannelStatuses(test.ichannel, test.channels) + got := ps.GetCondition(ParallelConditionChannelsReady).Status + want := test.want + if want != got { + t.Errorf("unexpected conditions (-want, +got) = %v %v", want, got) + } + }) + } +} + +func TestParallelReady(t *testing.T) { + tests := []struct { + name string + fsubs []*messagingv1alpha1.Subscription + subs []*messagingv1alpha1.Subscription + ichannel *duckv1alpha1.Channelable + channels []*duckv1alpha1.Channelable + want bool + }{{ + name: "ingress false, empty", + fsubs: []*messagingv1alpha1.Subscription{}, + subs: []*messagingv1alpha1.Subscription{}, + ichannel: getChannelable(false), + channels: []*duckv1alpha1.Channelable{}, + want: false, + }, { + name: "ingress true, empty", + fsubs: []*messagingv1alpha1.Subscription{}, + subs: []*messagingv1alpha1.Subscription{}, + ichannel: getChannelable(true), + channels: []*duckv1alpha1.Channelable{}, + want: false, + }, { + name: "ingress true, one channelable not ready, one subscription ready", + ichannel: getChannelable(true), + channels: []*duckv1alpha1.Channelable{getChannelable(false)}, + fsubs: []*messagingv1alpha1.Subscription{getSubscription("fsub0", true)}, + subs: []*messagingv1alpha1.Subscription{getSubscription("sub0", true)}, + want: false, + }, { + name: "ingress true, one channelable ready, one subscription not ready", + ichannel: getChannelable(true), + channels: []*duckv1alpha1.Channelable{getChannelable(true)}, + fsubs: []*messagingv1alpha1.Subscription{getSubscription("fsub0", false)}, + subs: []*messagingv1alpha1.Subscription{getSubscription("sub0", false)}, + want: false, + }, { + name: "ingress false, one channelable ready, one subscription ready", + ichannel: getChannelable(false), + channels: []*duckv1alpha1.Channelable{getChannelable(true)}, + fsubs: []*messagingv1alpha1.Subscription{getSubscription("fsub0", true)}, + subs: []*messagingv1alpha1.Subscription{getSubscription("sub0", true)}, + want: false, + }, { + name: "ingress true, one channelable ready, one subscription ready", + ichannel: getChannelable(true), + channels: []*duckv1alpha1.Channelable{getChannelable(true)}, + fsubs: []*messagingv1alpha1.Subscription{getSubscription("fsub0", true)}, + subs: []*messagingv1alpha1.Subscription{getSubscription("sub0", true)}, + want: true, + }, { + name: "ingress true, one channelable ready, one not, two subsriptions ready", + ichannel: getChannelable(true), + channels: []*duckv1alpha1.Channelable{getChannelable(true), getChannelable(false)}, + fsubs: []*messagingv1alpha1.Subscription{getSubscription("fsub0", true), getSubscription("fsub1", true)}, + subs: []*messagingv1alpha1.Subscription{getSubscription("sub0", true), getSubscription("sub1", true)}, + want: false, + }, { + name: "ingress true, two channelables ready, one subscription ready, one not", + ichannel: getChannelable(true), + channels: []*duckv1alpha1.Channelable{getChannelable(true), getChannelable(true)}, + fsubs: []*messagingv1alpha1.Subscription{getSubscription("fsub0", true), getSubscription("fsub1", false)}, + subs: []*messagingv1alpha1.Subscription{getSubscription("sub0", true), getSubscription("sub1", false)}, + want: false, + }, { + name: "ingress false, two channelables ready, two subscriptions ready", + ichannel: getChannelable(false), + channels: []*duckv1alpha1.Channelable{getChannelable(true), getChannelable(true)}, + fsubs: []*messagingv1alpha1.Subscription{getSubscription("fsub0", true), getSubscription("fsub1", true)}, + subs: []*messagingv1alpha1.Subscription{getSubscription("sub0", true), getSubscription("sub1", true)}, + want: false, + }, { + name: "ingress true, two channelables ready, two subscriptions ready", + ichannel: getChannelable(true), + channels: []*duckv1alpha1.Channelable{getChannelable(true), getChannelable(true)}, + fsubs: []*messagingv1alpha1.Subscription{getSubscription("fsub0", true), getSubscription("fsub1", true)}, + subs: []*messagingv1alpha1.Subscription{getSubscription("sub0", true), getSubscription("sub1", true)}, + want: true, + }} + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + ps := ParallelStatus{} + ps.PropagateChannelStatuses(test.ichannel, test.channels) + ps.PropagateSubscriptionStatuses(test.fsubs, test.subs) + got := ps.IsReady() + want := test.want + if want != got { + t.Errorf("unexpected conditions (-want, +got) = %v %v", want, got) + } + }) + } +} + +func TestParallelPropagateSetAddress(t *testing.T) { + URL, _ := apis.ParseURL("http://example.com") + tests := []struct { + name string + address *pkgduckv1alpha1.Addressable + want *pkgduckv1alpha1.Addressable + wantStatus corev1.ConditionStatus + }{{ + name: "nil", + address: nil, + want: nil, + wantStatus: corev1.ConditionFalse, + }, { + name: "empty", + address: &pkgduckv1alpha1.Addressable{}, + want: &pkgduckv1alpha1.Addressable{}, + wantStatus: corev1.ConditionFalse, + }, { + name: "URL", + address: &pkgduckv1alpha1.Addressable{duckv1beta1.Addressable{URL}, ""}, + want: &pkgduckv1alpha1.Addressable{duckv1beta1.Addressable{URL}, ""}, + wantStatus: corev1.ConditionTrue, + }, { + name: "hostname", + address: &pkgduckv1alpha1.Addressable{duckv1beta1.Addressable{}, "myhostname"}, + want: &pkgduckv1alpha1.Addressable{duckv1beta1.Addressable{}, "myhostname"}, + wantStatus: corev1.ConditionTrue, + }, { + name: "nil", + address: &pkgduckv1alpha1.Addressable{duckv1beta1.Addressable{nil}, ""}, + want: &pkgduckv1alpha1.Addressable{duckv1beta1.Addressable{}, ""}, + wantStatus: corev1.ConditionFalse, + }} + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + ps := ParallelStatus{} + ps.setAddress(test.address) + got := ps.Address + if diff := cmp.Diff(test.want, got, ignoreAllButTypeAndStatus); diff != "" { + t.Errorf("unexpected address (-want, +got) = %v", diff) + } + gotStatus := ps.GetCondition(ParallelConditionAddressable).Status + if test.wantStatus != gotStatus { + t.Errorf("unexpected conditions (-want, +got) = %v %v", test.wantStatus, gotStatus) + } + }) + } +} diff --git a/pkg/apis/flows/v1beta1/parallel_types.go b/pkg/apis/flows/v1beta1/parallel_types.go new file mode 100644 index 00000000000..4ab4f3ba90a --- /dev/null +++ b/pkg/apis/flows/v1beta1/parallel_types.go @@ -0,0 +1,161 @@ +/* + * Copyright 2019 The Knative Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package 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" + eventingduckv1alpha1 "knative.dev/eventing/pkg/apis/duck/v1alpha1" + "knative.dev/pkg/apis" + duckv1 "knative.dev/pkg/apis/duck/v1" + duckv1alpha1 "knative.dev/pkg/apis/duck/v1alpha1" + "knative.dev/pkg/apis/v1alpha1" + "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 + 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 *v1alpha1.Destination `json:"reply,omitempty"` +} + +type ParallelBranch struct { + // Filter is the expression guarding the branch + Filter *v1alpha1.Destination `json:"filter,omitempty"` + + // Subscriber receiving the event when the filter passes + Subscriber v1alpha1.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 *v1alpha1.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} + duckv1alpha1.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/parallel_types_test.go b/pkg/apis/flows/v1beta1/parallel_types_test.go new file mode 100644 index 00000000000..8f7ccc1281d --- /dev/null +++ b/pkg/apis/flows/v1beta1/parallel_types_test.go @@ -0,0 +1,26 @@ +/* + * Copyright 2019 The Knative Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package v1beta1 + +import "testing" + +func TestParallelKind(t *testing.T) { + parallel := Parallel{} + if parallel.GetGroupVersionKind().String() != "flows.knative.dev/v1beta1, Kind=Parallel" { + t.Errorf("unexpected gvk: %v", parallel.GetGroupVersionKind()) + } +} diff --git a/pkg/apis/flows/v1beta1/parallel_validation.go b/pkg/apis/flows/v1beta1/parallel_validation.go new file mode 100644 index 00000000000..02a57aa8706 --- /dev/null +++ b/pkg/apis/flows/v1beta1/parallel_validation.go @@ -0,0 +1,68 @@ +/* +Copyright 2019 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package 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.ValidateDisallowDeprecated(ctx); err != nil { + errs = errs.Also(apis.ErrInvalidArrayValue(s, "branches.filter", i)) + } + + if e := s.Subscriber.ValidateDisallowDeprecated(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/parallel_validation_test.go b/pkg/apis/flows/v1beta1/parallel_validation_test.go new file mode 100644 index 00000000000..5fa518c5ad2 --- /dev/null +++ b/pkg/apis/flows/v1beta1/parallel_validation_test.go @@ -0,0 +1,177 @@ +/* +Copyright 2019 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1beta1 + +import ( + "context" + "testing" + + "github.com/google/go-cmp/cmp" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + eventingduck "knative.dev/eventing/pkg/apis/duck/v1alpha1" + "knative.dev/pkg/apis" + "knative.dev/pkg/apis/v1alpha1" +) + +func TestParallelValidation(t *testing.T) { + name := "invalid parallel spec" + parallel := &Parallel{Spec: ParallelSpec{}} + + want := &apis.FieldError{ + Paths: []string{"spec.channelTemplate", "spec.branches"}, + Message: "missing field(s)", + } + + t.Run(name, func(t *testing.T) { + got := parallel.Validate(context.TODO()) + if diff := cmp.Diff(want.Error(), got.Error()); diff != "" { + t.Errorf("Parallel.Validate (-want, +got) = %v", diff) + } + }) +} + +func TestParallelSpecValidation(t *testing.T) { + subscriberURI := apis.HTTP("example.com") + validChannelTemplate := &eventingduck.ChannelTemplateSpec{ + TypeMeta: metav1.TypeMeta{ + Kind: "mykind", + APIVersion: "myapiversion", + }, + Spec: &runtime.RawExtension{}, + } + invalidReplyInParallel := ParallelBranch{Subscriber: v1alpha1.Destination{URI: subscriberURI}, + Reply: makeInvalidReply("reply-channel")} + + tests := []struct { + name string + ts *ParallelSpec + want *apis.FieldError + }{{ + name: "invalid parallel spec - empty", + ts: &ParallelSpec{}, + want: func() *apis.FieldError { + fe := apis.ErrMissingField("channelTemplate", "branches") + return fe + }(), + }, { + name: "invalid parallel spec - empty branches", + ts: &ParallelSpec{ + ChannelTemplate: validChannelTemplate, + }, + want: func() *apis.FieldError { + fe := apis.ErrMissingField("branches") + return fe + }(), + }, { + name: "missing channeltemplatespec", + ts: &ParallelSpec{ + Branches: []ParallelBranch{{Subscriber: v1alpha1.Destination{URI: subscriberURI}}}, + }, + want: func() *apis.FieldError { + fe := apis.ErrMissingField("channelTemplate") + return fe + }(), + }, { + name: "invalid channeltemplatespec missing APIVersion", + ts: &ParallelSpec{ + ChannelTemplate: &eventingduck.ChannelTemplateSpec{ + TypeMeta: metav1.TypeMeta{Kind: "mykind"}, + Spec: &runtime.RawExtension{}}, + Branches: []ParallelBranch{{Subscriber: v1alpha1.Destination{URI: subscriberURI}}}, + }, + want: func() *apis.FieldError { + fe := apis.ErrMissingField("channelTemplate.apiVersion") + return fe + }(), + }, { + name: "invalid channeltemplatespec missing Kind", + ts: &ParallelSpec{ + ChannelTemplate: &eventingduck.ChannelTemplateSpec{ + TypeMeta: metav1.TypeMeta{APIVersion: "myapiversion"}, + Spec: &runtime.RawExtension{}}, + Branches: []ParallelBranch{{Subscriber: v1alpha1.Destination{URI: subscriberURI}}}, + }, + want: func() *apis.FieldError { + fe := apis.ErrMissingField("channelTemplate.kind") + return fe + }(), + }, { + name: "valid parallel", + ts: &ParallelSpec{ + ChannelTemplate: validChannelTemplate, + Branches: []ParallelBranch{{Subscriber: v1alpha1.Destination{URI: subscriberURI}}}, + }, + want: func() *apis.FieldError { + return nil + }(), + }, { + name: "valid parallel with valid reply", + ts: &ParallelSpec{ + ChannelTemplate: validChannelTemplate, + Branches: []ParallelBranch{{Subscriber: v1alpha1.Destination{URI: subscriberURI}}}, + Reply: makeValidReply("reply-channel"), + }, + want: func() *apis.FieldError { + return nil + }(), + }, { + name: "parallel with invalid missing name", + ts: &ParallelSpec{ + ChannelTemplate: validChannelTemplate, + Branches: []ParallelBranch{{Subscriber: v1alpha1.Destination{URI: subscriberURI}}}, + Reply: &v1alpha1.Destination{ + DeprecatedAPIVersion: "messaging.knative.dev/v1alpha1", + DeprecatedKind: "inmemorychannel", + }, + }, + want: func() *apis.FieldError { + fe := apis.ErrMissingField("reply.name") + return fe + }(), + }, { + name: "parallel with invalid reply", + ts: &ParallelSpec{ + ChannelTemplate: validChannelTemplate, + Branches: []ParallelBranch{{Subscriber: v1alpha1.Destination{URI: subscriberURI}}}, + Reply: makeInvalidReply("reply-channel"), + }, + want: func() *apis.FieldError { + fe := apis.ErrMissingField("reply.apiVersion") + return fe + }(), + }, { + name: "parallel with invalid branch reply", + ts: &ParallelSpec{ + ChannelTemplate: validChannelTemplate, + Branches: []ParallelBranch{invalidReplyInParallel}, + }, + want: func() *apis.FieldError { + fe := apis.ErrInvalidArrayValue(invalidReplyInParallel, "branches.reply", 0) + return fe + }(), + }} + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + got := test.ts.Validate(context.TODO()) + if diff := cmp.Diff(test.want.Error(), got.Error()); diff != "" { + t.Errorf("%s: Validate ParallelSpec (-want, +got) = %v", test.name, diff) + } + }) + } +} diff --git a/pkg/apis/flows/v1beta1/register.go b/pkg/apis/flows/v1beta1/register.go new file mode 100644 index 00000000000..05ddddbbf9c --- /dev/null +++ b/pkg/apis/flows/v1beta1/register.go @@ -0,0 +1,55 @@ +/* +Copyright 2018 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/register_test.go b/pkg/apis/flows/v1beta1/register_test.go new file mode 100644 index 00000000000..c373ae27cdb --- /dev/null +++ b/pkg/apis/flows/v1beta1/register_test.go @@ -0,0 +1,68 @@ +/* +Copyright 2018 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" + + "github.com/google/go-cmp/cmp" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +// Resource takes an unqualified resource and returns a Group qualified GroupResource +func TestResource(t *testing.T) { + want := schema.GroupResource{ + Group: "flows.knative.dev", + Resource: "foo", + } + + got := Resource("foo") + + if diff := cmp.Diff(want, got); diff != "" { + t.Errorf("unexpected resource (-want, +got) = %v", diff) + } +} + +// Kind takes an unqualified resource and returns a Group qualified GroupKind +func TestKind(t *testing.T) { + want := schema.GroupKind{ + Group: "flows.knative.dev", + Kind: "kind", + } + + got := Kind("kind") + + if diff := cmp.Diff(want, got); diff != "" { + t.Errorf("unexpected resource (-want, +got) = %v", diff) + } +} + +// TestKnownTypes makes sure that expected types get added. +func TestKnownTypes(t *testing.T) { + scheme := runtime.NewScheme() + addKnownTypes(scheme) + types := scheme.KnownTypes(SchemeGroupVersion) + + for _, name := range []string{ + "Sequence", + "SequenceList", + "Parallel", + "ParallelList", + } { + if _, ok := types[name]; !ok { + t.Errorf("Did not find %q as registered type", name) + } + } + +} diff --git a/pkg/apis/flows/v1beta1/sequence_defaults.go b/pkg/apis/flows/v1beta1/sequence_defaults.go new file mode 100644 index 00000000000..7ab18167d05 --- /dev/null +++ b/pkg/apis/flows/v1beta1/sequence_defaults.go @@ -0,0 +1,37 @@ +/* +Copyright 2019 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1beta1 + +import ( + "context" + + 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..ad9e3e2bc49 --- /dev/null +++ b/pkg/apis/flows/v1beta1/sequence_defaults_test.go @@ -0,0 +1,106 @@ +/* +Copyright 2019 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1beta1 + +import ( + "context" + "testing" + + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + "github.com/google/go-cmp/cmp" + 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..4293076387b --- /dev/null +++ b/pkg/apis/flows/v1beta1/sequence_lifecycle.go @@ -0,0 +1,200 @@ +/* + * Copyright 2019 The Knative Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package 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" + pkgduckv1alpha1 "knative.dev/pkg/apis/duck/v1alpha1" +) + +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 *pkgduckv1alpha1.Addressable) { + ss.Address = address + + if address == nil { + pCondSet.Manage(ss).MarkFalse(SequenceConditionAddressable, "emptyHostname", "hostname is the empty string") + return + } + if address.URL != nil || address.Hostname != "" { + pCondSet.Manage(ss).MarkTrue(SequenceConditionAddressable) + } else { + ss.Address.Hostname = "" + ss.Address.URL = nil + pCondSet.Manage(ss).MarkFalse(SequenceConditionAddressable, "emptyHostname", "hostname is the empty string") + } +} + +// 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 (ss *SequenceStatus) 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 ss.Conditions { + if c.Type == dc.Type { + ss.Conditions[i] = dc + return + } + } + ss.Conditions = append(ss.Conditions, dc) +} + +// ClearDeprecated removes the StatusConditionTypeDeprecated warning condition. Note that this does not +// affect the Ready condition. +func (ss *SequenceStatus) ClearDeprecated() { + conds := make([]apis.Condition, 0, len(ss.Conditions)) + for _, c := range ss.Conditions { + if c.Type != StatusConditionTypeDeprecated { + conds = append(conds, c) + } + } + ss.Conditions = conds +} diff --git a/pkg/apis/flows/v1beta1/sequence_lifecycle_test.go b/pkg/apis/flows/v1beta1/sequence_lifecycle_test.go new file mode 100644 index 00000000000..f466591259d --- /dev/null +++ b/pkg/apis/flows/v1beta1/sequence_lifecycle_test.go @@ -0,0 +1,412 @@ +/* +Copyright 2019 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1beta1 + +import ( + "testing" + + "knative.dev/pkg/apis" + + "github.com/google/go-cmp/cmp" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + messagingv1alpha1 "knative.dev/eventing/pkg/apis/messaging/v1alpha1" + duckv1 "knative.dev/pkg/apis/duck/v1" + pkgduckv1alpha1 "knative.dev/pkg/apis/duck/v1alpha1" + duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" + + duckv1alpha1 "knative.dev/eventing/pkg/apis/duck/v1alpha1" +) + +var sequenceConditionReady = apis.Condition{ + Type: SequenceConditionReady, + Status: corev1.ConditionTrue, +} + +var sequenceConditionChannelsReady = apis.Condition{ + Type: SequenceConditionChannelsReady, + Status: corev1.ConditionTrue, +} + +var sequenceConditionSubscriptionsReady = apis.Condition{ + Type: SequenceConditionSubscriptionsReady, + Status: corev1.ConditionTrue, +} + +func getSubscription(name string, ready bool) *messagingv1alpha1.Subscription { + s := messagingv1alpha1.Subscription{ + TypeMeta: metav1.TypeMeta{ + APIVersion: "eventing.knative.dev/v1alpha1", + Kind: "Subscription", + }, + ObjectMeta: metav1.ObjectMeta{ + Name: name, + Namespace: "testns", + }, + Status: messagingv1alpha1.SubscriptionStatus{}, + } + if ready { + s.Status.MarkChannelReady() + s.Status.MarkReferencesResolved() + s.Status.MarkAddedToChannel() + } else { + s.Status.MarkChannelNotReady("testInducedFailure", "Test Induced failure") + s.Status.MarkReferencesNotResolved("testInducedFailure", "Test Induced failure") + s.Status.MarkNotAddedToChannel("testInducedfailure", "Test Induced failure") + } + return &s +} + +func getChannelable(ready bool) *duckv1alpha1.Channelable { + URL, _ := apis.ParseURL("http://example.com") + s := duckv1alpha1.Channelable{ + TypeMeta: metav1.TypeMeta{ + APIVersion: "messaging.knative.dev/v1alpha1", + Kind: "InMemoryChannel", + }, + ObjectMeta: metav1.ObjectMeta{}, + Status: duckv1alpha1.ChannelableStatus{}, + } + + if ready { + s.Status.Address = &pkgduckv1alpha1.Addressable{duckv1beta1.Addressable{URL}, ""} + } + + return &s +} + +func TestSequenceGetCondition(t *testing.T) { + tests := []struct { + name string + ss *SequenceStatus + condQuery apis.ConditionType + want *apis.Condition + }{{ + name: "single condition", + ss: &SequenceStatus{ + Status: duckv1.Status{ + Conditions: []apis.Condition{ + sequenceConditionReady, + }, + }, + }, + condQuery: apis.ConditionReady, + want: &sequenceConditionReady, + }} + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + got := test.ss.GetCondition(test.condQuery) + if diff := cmp.Diff(test.want, got); diff != "" { + t.Errorf("unexpected condition (-want, +got) = %v", diff) + } + }) + } +} + +func TestSequenceInitializeConditions(t *testing.T) { + tests := []struct { + name string + ts *SequenceStatus + want *SequenceStatus + }{{ + name: "empty", + ts: &SequenceStatus{}, + want: &SequenceStatus{ + Status: duckv1.Status{ + Conditions: []apis.Condition{{ + Type: SequenceConditionAddressable, + Status: corev1.ConditionUnknown, + }, { + Type: SequenceConditionChannelsReady, + Status: corev1.ConditionUnknown, + }, { + Type: SequenceConditionReady, + Status: corev1.ConditionUnknown, + }, { + Type: SequenceConditionSubscriptionsReady, + Status: corev1.ConditionUnknown, + }}, + }, + }, + }, { + name: "one false", + ts: &SequenceStatus{ + Status: duckv1.Status{ + Conditions: []apis.Condition{{ + Type: SequenceConditionChannelsReady, + Status: corev1.ConditionFalse, + }}, + }, + }, + want: &SequenceStatus{ + Status: duckv1.Status{ + Conditions: []apis.Condition{{ + Type: SequenceConditionAddressable, + Status: corev1.ConditionUnknown, + }, { + Type: SequenceConditionChannelsReady, + Status: corev1.ConditionFalse, + }, { + Type: SequenceConditionReady, + Status: corev1.ConditionUnknown, + }, { + Type: SequenceConditionSubscriptionsReady, + Status: corev1.ConditionUnknown, + }}, + }, + }, + }, { + name: "one true", + ts: &SequenceStatus{ + Status: duckv1.Status{ + Conditions: []apis.Condition{{ + Type: SequenceConditionSubscriptionsReady, + Status: corev1.ConditionTrue, + }}, + }, + }, + want: &SequenceStatus{ + Status: duckv1.Status{ + Conditions: []apis.Condition{{ + Type: SequenceConditionAddressable, + Status: corev1.ConditionUnknown, + }, { + Type: SequenceConditionChannelsReady, + Status: corev1.ConditionUnknown, + }, { + Type: SequenceConditionReady, + Status: corev1.ConditionUnknown, + }, { + Type: SequenceConditionSubscriptionsReady, + Status: corev1.ConditionTrue, + }}, + }, + }, + }} + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + test.ts.InitializeConditions() + if diff := cmp.Diff(test.want, test.ts, ignoreAllButTypeAndStatus); diff != "" { + t.Errorf("unexpected conditions (-want, +got) = %v", diff) + } + }) + } +} + +func TestSequencePropagateSubscriptionStatuses(t *testing.T) { + tests := []struct { + name string + subs []*messagingv1alpha1.Subscription + want corev1.ConditionStatus + }{{ + name: "empty", + subs: []*messagingv1alpha1.Subscription{}, + want: corev1.ConditionFalse, + }, { + name: "empty status", + subs: []*messagingv1alpha1.Subscription{{ + TypeMeta: metav1.TypeMeta{ + APIVersion: "eventing.knative.dev/v1alpha1", + Kind: "Subscription", + }, + ObjectMeta: metav1.ObjectMeta{ + Name: "sub", + Namespace: "testns", + }, + Status: messagingv1alpha1.SubscriptionStatus{}, + }, + }, + want: corev1.ConditionFalse, + }, { + name: "one subscription not ready", + subs: []*messagingv1alpha1.Subscription{getSubscription("sub0", false)}, + want: corev1.ConditionFalse, + }, { + name: "one subscription ready", + subs: []*messagingv1alpha1.Subscription{getSubscription("sub0", true)}, + want: corev1.ConditionTrue, + }, { + name: "one subscription ready, one not", + subs: []*messagingv1alpha1.Subscription{getSubscription("sub0", true), getSubscription("sub1", false)}, + want: corev1.ConditionFalse, + }, { + name: "two subscriptions ready", + subs: []*messagingv1alpha1.Subscription{getSubscription("sub0", true), getSubscription("sub1", true)}, + want: corev1.ConditionTrue, + }} + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + ps := SequenceStatus{} + ps.PropagateSubscriptionStatuses(test.subs) + got := ps.GetCondition(SequenceConditionSubscriptionsReady).Status + want := test.want + if want != got { + t.Errorf("unexpected conditions (-want, +got) = %v %v", want, got) + } + }) + } +} + +func TestSequencePropagateChannelStatuses(t *testing.T) { + tests := []struct { + name string + channels []*duckv1alpha1.Channelable + want corev1.ConditionStatus + }{{ + name: "empty", + channels: []*duckv1alpha1.Channelable{}, + want: corev1.ConditionFalse, + }, { + name: "one channelable not ready", + channels: []*duckv1alpha1.Channelable{getChannelable(false)}, + want: corev1.ConditionFalse, + }, { + name: "one channelable ready", + channels: []*duckv1alpha1.Channelable{getChannelable(true)}, + want: corev1.ConditionTrue, + }, { + name: "one channelable ready, one not", + channels: []*duckv1alpha1.Channelable{getChannelable(true), getChannelable(false)}, + want: corev1.ConditionFalse, + }, { + name: "two channelables ready", + channels: []*duckv1alpha1.Channelable{getChannelable(true), getChannelable(true)}, + want: corev1.ConditionTrue, + }} + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + ps := SequenceStatus{} + ps.PropagateChannelStatuses(test.channels) + got := ps.GetCondition(SequenceConditionChannelsReady).Status + want := test.want + if want != got { + t.Errorf("unexpected conditions (-want, +got) = %v %v", want, got) + } + }) + } +} + +func TestSequenceReady(t *testing.T) { + tests := []struct { + name string + subs []*messagingv1alpha1.Subscription + channels []*duckv1alpha1.Channelable + want bool + }{{ + name: "empty", + subs: []*messagingv1alpha1.Subscription{}, + channels: []*duckv1alpha1.Channelable{}, + want: false, + }, { + name: "one channelable not ready, one subscription ready", + channels: []*duckv1alpha1.Channelable{getChannelable(false)}, + subs: []*messagingv1alpha1.Subscription{getSubscription("sub0", true)}, + want: false, + }, { + name: "one channelable ready, one subscription not ready", + channels: []*duckv1alpha1.Channelable{getChannelable(true)}, + subs: []*messagingv1alpha1.Subscription{getSubscription("sub0", false)}, + want: false, + }, { + name: "one channelable ready, one subscription ready", + channels: []*duckv1alpha1.Channelable{getChannelable(true)}, + subs: []*messagingv1alpha1.Subscription{getSubscription("sub0", true)}, + want: true, + }, { + name: "one channelable ready, one not, two subsriptions ready", + channels: []*duckv1alpha1.Channelable{getChannelable(true), getChannelable(false)}, + subs: []*messagingv1alpha1.Subscription{getSubscription("sub0", true), getSubscription("sub1", true)}, + want: false, + }, { + name: "two channelables ready, one subscription ready, one not", + channels: []*duckv1alpha1.Channelable{getChannelable(true), getChannelable(true)}, + subs: []*messagingv1alpha1.Subscription{getSubscription("sub0", true), getSubscription("sub1", false)}, + want: false, + }, { + name: "two channelables ready, two subscriptions ready", + channels: []*duckv1alpha1.Channelable{getChannelable(true), getChannelable(true)}, + subs: []*messagingv1alpha1.Subscription{getSubscription("sub0", true), getSubscription("sub1", true)}, + want: true, + }} + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + ps := SequenceStatus{} + ps.PropagateChannelStatuses(test.channels) + ps.PropagateSubscriptionStatuses(test.subs) + got := ps.IsReady() + want := test.want + if want != got { + t.Errorf("unexpected conditions (-want, +got) = %v %v", want, got) + } + }) + } +} + +func TestSequencePropagateSetAddress(t *testing.T) { + URL, _ := apis.ParseURL("http://example.com") + tests := []struct { + name string + address *pkgduckv1alpha1.Addressable + want *pkgduckv1alpha1.Addressable + wantStatus corev1.ConditionStatus + }{{ + name: "nil", + address: nil, + want: nil, + wantStatus: corev1.ConditionFalse, + }, { + name: "empty", + address: &pkgduckv1alpha1.Addressable{}, + want: &pkgduckv1alpha1.Addressable{}, + wantStatus: corev1.ConditionFalse, + }, { + name: "URL", + address: &pkgduckv1alpha1.Addressable{duckv1beta1.Addressable{URL}, ""}, + want: &pkgduckv1alpha1.Addressable{duckv1beta1.Addressable{URL}, ""}, + wantStatus: corev1.ConditionTrue, + }, { + name: "hostname", + address: &pkgduckv1alpha1.Addressable{duckv1beta1.Addressable{}, "myhostname"}, + want: &pkgduckv1alpha1.Addressable{duckv1beta1.Addressable{}, "myhostname"}, + wantStatus: corev1.ConditionTrue, + }, { + name: "nil", + address: &pkgduckv1alpha1.Addressable{duckv1beta1.Addressable{nil}, ""}, + want: &pkgduckv1alpha1.Addressable{duckv1beta1.Addressable{}, ""}, + wantStatus: corev1.ConditionFalse, + }} + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + ps := SequenceStatus{} + ps.setAddress(test.address) + got := ps.Address + if diff := cmp.Diff(test.want, got, ignoreAllButTypeAndStatus); diff != "" { + t.Errorf("unexpected address (-want, +got) = %v", diff) + } + gotStatus := ps.GetCondition(SequenceConditionAddressable).Status + if test.wantStatus != gotStatus { + t.Errorf("unexpected conditions (-want, +got) = %v %v", test.wantStatus, gotStatus) + } + }) + } +} diff --git a/pkg/apis/flows/v1beta1/sequence_types.go b/pkg/apis/flows/v1beta1/sequence_types.go new file mode 100644 index 00000000000..0d2fe288bc3 --- /dev/null +++ b/pkg/apis/flows/v1beta1/sequence_types.go @@ -0,0 +1,137 @@ +/* + * Copyright 2019 The Knative Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package 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" + eventingduckv1alpha1 "knative.dev/eventing/pkg/apis/duck/v1alpha1" + "knative.dev/pkg/apis" + duckv1 "knative.dev/pkg/apis/duck/v1" + duckv1alpha1 "knative.dev/pkg/apis/duck/v1alpha1" + "knative.dev/pkg/apis/v1alpha1" + "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 []v1alpha1.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 + ChannelTemplate *eventingduckv1alpha1.ChannelTemplateSpec `json:"channelTemplate,omitempty"` + + // Reply is a Reference to where the result of the last Subscriber gets sent to. + // +optional + Reply *v1alpha1.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} + duckv1alpha1.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/sequence_types_test.go b/pkg/apis/flows/v1beta1/sequence_types_test.go new file mode 100644 index 00000000000..87476fbf61d --- /dev/null +++ b/pkg/apis/flows/v1beta1/sequence_types_test.go @@ -0,0 +1,34 @@ +/* + * Copyright 2019 The Knative Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package 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..850ed7c1a5b --- /dev/null +++ b/pkg/apis/flows/v1beta1/sequence_validation.go @@ -0,0 +1,60 @@ +/* +Copyright 2019 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package 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.ValidateDisallowDeprecated(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/sequence_validation_test.go b/pkg/apis/flows/v1beta1/sequence_validation_test.go new file mode 100644 index 00000000000..52aec74825f --- /dev/null +++ b/pkg/apis/flows/v1beta1/sequence_validation_test.go @@ -0,0 +1,175 @@ +/* +Copyright 2019 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1beta1 + +import ( + "context" + "testing" + + "github.com/google/go-cmp/cmp" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + eventingduck "knative.dev/eventing/pkg/apis/duck/v1alpha1" + "knative.dev/pkg/apis" + "knative.dev/pkg/apis/v1alpha1" +) + +func TestSequenceValidation(t *testing.T) { + name := "invalid sequence spec" + sequence := &Sequence{Spec: SequenceSpec{}} + + want := &apis.FieldError{ + Paths: []string{"spec.channelTemplate", "spec.steps"}, + Message: "missing field(s)", + } + + t.Run(name, func(t *testing.T) { + got := sequence.Validate(context.TODO()) + if diff := cmp.Diff(want.Error(), got.Error()); diff != "" { + t.Errorf("Sequence.Validate (-want, +got) = %v", diff) + } + }) +} + +func makeValidReply(channelName string) *v1alpha1.Destination { + return &v1alpha1.Destination{ + DeprecatedAPIVersion: "messaging.knative.dev/v1alpha1", + DeprecatedKind: "inmemorychannel", + DeprecatedName: channelName, + } +} + +func makeInvalidReply(channelName string) *v1alpha1.Destination { + return &v1alpha1.Destination{ + DeprecatedKind: "inmemorychannel", + DeprecatedName: channelName, + } +} + +func TestSequenceSpecValidation(t *testing.T) { + subscriberURI := apis.HTTP("example.com") + validChannelTemplate := &eventingduck.ChannelTemplateSpec{ + TypeMeta: metav1.TypeMeta{ + Kind: "mykind", + APIVersion: "myapiversion", + }, + Spec: &runtime.RawExtension{}, + } + tests := []struct { + name string + ts *SequenceSpec + want *apis.FieldError + }{{ + name: "invalid sequence spec - empty", + ts: &SequenceSpec{}, + want: func() *apis.FieldError { + fe := apis.ErrMissingField("channelTemplate", "steps") + return fe + }(), + }, { + name: "invalid sequence spec - empty steps", + ts: &SequenceSpec{ + ChannelTemplate: validChannelTemplate, + }, + want: func() *apis.FieldError { + fe := apis.ErrMissingField("steps") + return fe + }(), + }, { + name: "missing channeltemplatespec", + ts: &SequenceSpec{ + Steps: []v1alpha1.Destination{{URI: subscriberURI}}, + }, + want: func() *apis.FieldError { + fe := apis.ErrMissingField("channelTemplate") + return fe + }(), + }, { + name: "invalid channeltemplatespec missing APIVersion", + ts: &SequenceSpec{ + ChannelTemplate: &eventingduck.ChannelTemplateSpec{TypeMeta: metav1.TypeMeta{Kind: "mykind"}, Spec: &runtime.RawExtension{}}, + Steps: []v1alpha1.Destination{{URI: subscriberURI}}, + }, + want: func() *apis.FieldError { + fe := apis.ErrMissingField("channelTemplate.apiVersion") + return fe + }(), + }, { + name: "invalid channeltemplatespec missing Kind", + ts: &SequenceSpec{ + ChannelTemplate: &eventingduck.ChannelTemplateSpec{TypeMeta: metav1.TypeMeta{APIVersion: "myapiversion"}, Spec: &runtime.RawExtension{}}, + Steps: []v1alpha1.Destination{{URI: subscriberURI}}, + }, + want: func() *apis.FieldError { + fe := apis.ErrMissingField("channelTemplate.kind") + return fe + }(), + }, { + name: "valid sequence", + ts: &SequenceSpec{ + ChannelTemplate: validChannelTemplate, + Steps: []v1alpha1.Destination{{URI: subscriberURI}}, + }, + want: func() *apis.FieldError { + return nil + }(), + }, { + name: "valid sequence with valid reply", + ts: &SequenceSpec{ + ChannelTemplate: validChannelTemplate, + Steps: []v1alpha1.Destination{{URI: subscriberURI}}, + Reply: makeValidReply("reply-channel"), + }, + want: func() *apis.FieldError { + return nil + }(), + }, { + name: "valid sequence with invalid missing name", + ts: &SequenceSpec{ + ChannelTemplate: validChannelTemplate, + Steps: []v1alpha1.Destination{{URI: subscriberURI}}, + Reply: &v1alpha1.Destination{ + DeprecatedAPIVersion: "messaging.knative.dev/v1alpha1", + DeprecatedKind: "inmemorychannel", + }, + }, + want: func() *apis.FieldError { + fe := apis.ErrMissingField("reply.name") + return fe + }(), + }, { + name: "valid sequence with invalid reply", + ts: &SequenceSpec{ + ChannelTemplate: validChannelTemplate, + Steps: []v1alpha1.Destination{{URI: subscriberURI}}, + Reply: makeInvalidReply("reply-channel"), + }, + want: func() *apis.FieldError { + fe := apis.ErrMissingField("reply.apiVersion") + return fe + }(), + }} + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + got := test.ts.Validate(context.TODO()) + if diff := cmp.Diff(test.want.Error(), got.Error()); diff != "" { + t.Errorf("%s: Validate SequenceSpec (-want, +got) = %v", test.name, diff) + } + }) + } +} diff --git a/pkg/apis/flows/v1beta1/test_helpers.go b/pkg/apis/flows/v1beta1/test_helpers.go new file mode 100644 index 00000000000..36ab11de4f6 --- /dev/null +++ b/pkg/apis/flows/v1beta1/test_helpers.go @@ -0,0 +1,37 @@ +/* +Copyright 2019 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1beta1 + +import ( + "github.com/google/go-cmp/cmp/cmpopts" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + 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") +) 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..92f8b3c2309 --- /dev/null +++ b/pkg/apis/flows/v1beta1/zz_generated.deepcopy.go @@ -0,0 +1,391 @@ +// +build !ignore_autogenerated + +/* +Copyright 2019 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by deepcopy-gen. DO NOT EDIT. + +package v1beta1 + +import ( + runtime "k8s.io/apimachinery/pkg/runtime" + duckv1alpha1 "knative.dev/eventing/pkg/apis/duck/v1alpha1" + v1alpha1 "knative.dev/pkg/apis/v1alpha1" +) + +// 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(v1alpha1.Destination) + (*in).DeepCopyInto(*out) + } + in.Subscriber.DeepCopyInto(&out.Subscriber) + if in.Reply != nil { + in, out := &in.Reply, &out.Reply + *out = new(v1alpha1.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(duckv1alpha1.ChannelTemplateSpec) + (*in).DeepCopyInto(*out) + } + if in.Reply != nil { + in, out := &in.Reply, &out.Reply + *out = new(v1alpha1.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([]v1alpha1.Destination, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.ChannelTemplate != nil { + in, out := &in.ChannelTemplate, &out.ChannelTemplate + *out = new(duckv1alpha1.ChannelTemplateSpec) + (*in).DeepCopyInto(*out) + } + if in.Reply != nil { + in, out := &in.Reply, &out.Reply + *out = new(v1alpha1.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 +} diff --git a/pkg/client/clientset/versioned/clientset.go b/pkg/client/clientset/versioned/clientset.go index f2c536c00cc..caedff8a041 100644 --- a/pkg/client/clientset/versioned/clientset.go +++ b/pkg/client/clientset/versioned/clientset.go @@ -23,6 +23,7 @@ import ( rest "k8s.io/client-go/rest" flowcontrol "k8s.io/client-go/util/flowcontrol" eventingv1alpha1 "knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1alpha1" + flowsv1beta1 "knative.dev/eventing/pkg/client/clientset/versioned/typed/flows/v1beta1" messagingv1alpha1 "knative.dev/eventing/pkg/client/clientset/versioned/typed/messaging/v1alpha1" sourcesv1alpha1 "knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1" ) @@ -30,6 +31,7 @@ import ( type Interface interface { Discovery() discovery.DiscoveryInterface EventingV1alpha1() eventingv1alpha1.EventingV1alpha1Interface + FlowsV1beta1() flowsv1beta1.FlowsV1beta1Interface MessagingV1alpha1() messagingv1alpha1.MessagingV1alpha1Interface SourcesV1alpha1() sourcesv1alpha1.SourcesV1alpha1Interface } @@ -39,6 +41,7 @@ type Interface interface { type Clientset struct { *discovery.DiscoveryClient eventingV1alpha1 *eventingv1alpha1.EventingV1alpha1Client + flowsV1beta1 *flowsv1beta1.FlowsV1beta1Client messagingV1alpha1 *messagingv1alpha1.MessagingV1alpha1Client sourcesV1alpha1 *sourcesv1alpha1.SourcesV1alpha1Client } @@ -48,6 +51,11 @@ func (c *Clientset) EventingV1alpha1() eventingv1alpha1.EventingV1alpha1Interfac return c.eventingV1alpha1 } +// 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 @@ -78,6 +86,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 @@ -99,6 +111,7 @@ func NewForConfig(c *rest.Config) (*Clientset, error) { func NewForConfigOrDie(c *rest.Config) *Clientset { var cs Clientset cs.eventingV1alpha1 = eventingv1alpha1.NewForConfigOrDie(c) + cs.flowsV1beta1 = flowsv1beta1.NewForConfigOrDie(c) cs.messagingV1alpha1 = messagingv1alpha1.NewForConfigOrDie(c) cs.sourcesV1alpha1 = sourcesv1alpha1.NewForConfigOrDie(c) @@ -110,6 +123,7 @@ func NewForConfigOrDie(c *rest.Config) *Clientset { func New(c rest.Interface) *Clientset { var cs Clientset cs.eventingV1alpha1 = eventingv1alpha1.New(c) + cs.flowsV1beta1 = flowsv1beta1.New(c) cs.messagingV1alpha1 = messagingv1alpha1.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 70355263fa8..147927e7346 100644 --- a/pkg/client/clientset/versioned/fake/clientset_generated.go +++ b/pkg/client/clientset/versioned/fake/clientset_generated.go @@ -27,6 +27,8 @@ import ( clientset "knative.dev/eventing/pkg/client/clientset/versioned" eventingv1alpha1 "knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1alpha1" fakeeventingv1alpha1 "knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/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" sourcesv1alpha1 "knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1" @@ -85,6 +87,11 @@ func (c *Clientset) EventingV1alpha1() eventingv1alpha1.EventingV1alpha1Interfac return &fakeeventingv1alpha1.FakeEventingV1alpha1{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 7592773098f..6f2165c0641 100644 --- a/pkg/client/clientset/versioned/fake/register.go +++ b/pkg/client/clientset/versioned/fake/register.go @@ -25,6 +25,7 @@ import ( serializer "k8s.io/apimachinery/pkg/runtime/serializer" utilruntime "k8s.io/apimachinery/pkg/util/runtime" eventingv1alpha1 "knative.dev/eventing/pkg/apis/eventing/v1alpha1" + flowsv1beta1 "knative.dev/eventing/pkg/apis/flows/v1beta1" messagingv1alpha1 "knative.dev/eventing/pkg/apis/messaging/v1alpha1" sourcesv1alpha1 "knative.dev/eventing/pkg/apis/sources/v1alpha1" ) @@ -34,6 +35,7 @@ var codecs = serializer.NewCodecFactory(scheme) var parameterCodec = runtime.NewParameterCodec(scheme) var localSchemeBuilder = runtime.SchemeBuilder{ eventingv1alpha1.AddToScheme, + flowsv1beta1.AddToScheme, messagingv1alpha1.AddToScheme, sourcesv1alpha1.AddToScheme, } diff --git a/pkg/client/clientset/versioned/scheme/register.go b/pkg/client/clientset/versioned/scheme/register.go index badcd878f15..ea7f0162802 100644 --- a/pkg/client/clientset/versioned/scheme/register.go +++ b/pkg/client/clientset/versioned/scheme/register.go @@ -25,6 +25,7 @@ import ( serializer "k8s.io/apimachinery/pkg/runtime/serializer" utilruntime "k8s.io/apimachinery/pkg/util/runtime" eventingv1alpha1 "knative.dev/eventing/pkg/apis/eventing/v1alpha1" + flowsv1beta1 "knative.dev/eventing/pkg/apis/flows/v1beta1" messagingv1alpha1 "knative.dev/eventing/pkg/apis/messaging/v1alpha1" sourcesv1alpha1 "knative.dev/eventing/pkg/apis/sources/v1alpha1" ) @@ -34,6 +35,7 @@ var Codecs = serializer.NewCodecFactory(Scheme) var ParameterCodec = runtime.NewParameterCodec(Scheme) var localSchemeBuilder = runtime.SchemeBuilder{ eventingv1alpha1.AddToScheme, + flowsv1beta1.AddToScheme, messagingv1alpha1.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..ede2d4a2879 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/flows/v1beta1/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2019 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +// This package has the automatically generated typed clients. +package 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..a00e5d7b21a --- /dev/null +++ b/pkg/client/clientset/versioned/typed/flows/v1beta1/fake/doc.go @@ -0,0 +1,20 @@ +/* +Copyright 2019 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +// Package fake has the automatically generated clients. +package fake diff --git a/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..6de1435267f --- /dev/null +++ b/pkg/client/clientset/versioned/typed/flows/v1beta1/fake/fake_flows_client.go @@ -0,0 +1,44 @@ +/* +Copyright 2019 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + rest "k8s.io/client-go/rest" + testing "k8s.io/client-go/testing" + 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..e5305263a41 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/flows/v1beta1/fake/fake_parallel.go @@ -0,0 +1,140 @@ +/* +Copyright 2019 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + schema "k8s.io/apimachinery/pkg/runtime/schema" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" + 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..bc939eb7ed8 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/flows/v1beta1/fake/fake_sequence.go @@ -0,0 +1,140 @@ +/* +Copyright 2019 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + labels "k8s.io/apimachinery/pkg/labels" + schema "k8s.io/apimachinery/pkg/runtime/schema" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + testing "k8s.io/client-go/testing" + 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..b6a4de90026 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/flows/v1beta1/flows_client.go @@ -0,0 +1,94 @@ +/* +Copyright 2019 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package 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..4cc45c964fb --- /dev/null +++ b/pkg/client/clientset/versioned/typed/flows/v1beta1/generated_expansion.go @@ -0,0 +1,23 @@ +/* +Copyright 2019 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package 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..4654e49ab8a --- /dev/null +++ b/pkg/client/clientset/versioned/typed/flows/v1beta1/parallel.go @@ -0,0 +1,191 @@ +/* +Copyright 2019 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package 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..d003e87700e --- /dev/null +++ b/pkg/client/clientset/versioned/typed/flows/v1beta1/sequence.go @@ -0,0 +1,191 @@ +/* +Copyright 2019 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package 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/factory.go b/pkg/client/informers/externalversions/factory.go index 33382e10521..e476d75ac48 100644 --- a/pkg/client/informers/externalversions/factory.go +++ b/pkg/client/informers/externalversions/factory.go @@ -29,6 +29,7 @@ import ( cache "k8s.io/client-go/tools/cache" versioned "knative.dev/eventing/pkg/client/clientset/versioned" eventing "knative.dev/eventing/pkg/client/informers/externalversions/eventing" + flows "knative.dev/eventing/pkg/client/informers/externalversions/flows" internalinterfaces "knative.dev/eventing/pkg/client/informers/externalversions/internalinterfaces" messaging "knative.dev/eventing/pkg/client/informers/externalversions/messaging" sources "knative.dev/eventing/pkg/client/informers/externalversions/sources" @@ -175,6 +176,7 @@ type SharedInformerFactory interface { WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool Eventing() eventing.Interface + Flows() flows.Interface Messaging() messaging.Interface Sources() sources.Interface } @@ -183,6 +185,10 @@ func (f *sharedInformerFactory) Eventing() eventing.Interface { return eventing.New(f, f.namespace, f.tweakListOptions) } +func (f *sharedInformerFactory) Flows() flows.Interface { + return flows.New(f, f.namespace, f.tweakListOptions) +} + func (f *sharedInformerFactory) Messaging() messaging.Interface { return messaging.New(f, f.namespace, f.tweakListOptions) } diff --git a/pkg/client/informers/externalversions/flows/interface.go b/pkg/client/informers/externalversions/flows/interface.go new file mode 100644 index 00000000000..5d253ea4d7c --- /dev/null +++ b/pkg/client/informers/externalversions/flows/interface.go @@ -0,0 +1,46 @@ +/* +Copyright 2019 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by informer-gen. DO NOT EDIT. + +package flows + +import ( + v1beta1 "knative.dev/eventing/pkg/client/informers/externalversions/flows/v1beta1" + internalinterfaces "knative.dev/eventing/pkg/client/informers/externalversions/internalinterfaces" +) + +// Interface provides access to each of this group's versions. +type Interface interface { + // V1beta1 provides access to shared informers for resources in V1beta1. + V1beta1() v1beta1.Interface +} + +type group 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 &group{factory: f, namespace: namespace, tweakListOptions: 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..38838af960b --- /dev/null +++ b/pkg/client/informers/externalversions/flows/v1beta1/interface.go @@ -0,0 +1,52 @@ +/* +Copyright 2019 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by 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..e775c7af2ab --- /dev/null +++ b/pkg/client/informers/externalversions/flows/v1beta1/parallel.go @@ -0,0 +1,89 @@ +/* +Copyright 2019 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// 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..c453ff6a5f5 --- /dev/null +++ b/pkg/client/informers/externalversions/flows/v1beta1/sequence.go @@ -0,0 +1,89 @@ +/* +Copyright 2019 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// 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 d17d3f7c0f2..3febc83c7cf 100644 --- a/pkg/client/informers/externalversions/generic.go +++ b/pkg/client/informers/externalversions/generic.go @@ -24,6 +24,7 @@ import ( schema "k8s.io/apimachinery/pkg/runtime/schema" cache "k8s.io/client-go/tools/cache" v1alpha1 "knative.dev/eventing/pkg/apis/eventing/v1alpha1" + v1beta1 "knative.dev/eventing/pkg/apis/flows/v1beta1" messagingv1alpha1 "knative.dev/eventing/pkg/apis/messaging/v1alpha1" sourcesv1alpha1 "knative.dev/eventing/pkg/apis/sources/v1alpha1" ) @@ -62,6 +63,12 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource case v1alpha1.SchemeGroupVersion.WithResource("triggers"): return &genericInformer{resource: resource.GroupResource(), informer: f.Eventing().V1alpha1().Triggers().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..cf6572ae422 --- /dev/null +++ b/pkg/client/injection/informers/flows/v1beta1/parallel/fake/fake.go @@ -0,0 +1,40 @@ +/* +Copyright 2019 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by 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..8d249678cb0 --- /dev/null +++ b/pkg/client/injection/informers/flows/v1beta1/parallel/parallel.go @@ -0,0 +1,52 @@ +/* +Copyright 2019 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by 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..f4bb646753d --- /dev/null +++ b/pkg/client/injection/informers/flows/v1beta1/sequence/fake/fake.go @@ -0,0 +1,40 @@ +/* +Copyright 2019 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by 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..826c95fb69e --- /dev/null +++ b/pkg/client/injection/informers/flows/v1beta1/sequence/sequence.go @@ -0,0 +1,52 @@ +/* +Copyright 2019 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by 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..a68e66930b9 --- /dev/null +++ b/pkg/client/listers/flows/v1beta1/expansion_generated.go @@ -0,0 +1,35 @@ +/* +Copyright 2019 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// 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..b4a37e48e27 --- /dev/null +++ b/pkg/client/listers/flows/v1beta1/parallel.go @@ -0,0 +1,94 @@ +/* +Copyright 2019 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by 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..4d3868120b6 --- /dev/null +++ b/pkg/client/listers/flows/v1beta1/sequence.go @@ -0,0 +1,94 @@ +/* +Copyright 2019 The Knative Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by 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 4b5cd1db8c5ee06f860f36aa11e92fbe5aa04088 Mon Sep 17 00:00:00 2001 From: Ville Aikas Date: Wed, 6 Nov 2019 19:05:22 -0800 Subject: [PATCH 2/4] fix copyright year. guess it is 2019... --- pkg/apis/flows/v1beta1/register.go | 2 +- pkg/apis/flows/v1beta1/register_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/apis/flows/v1beta1/register.go b/pkg/apis/flows/v1beta1/register.go index 05ddddbbf9c..79e2dd4246c 100644 --- a/pkg/apis/flows/v1beta1/register.go +++ b/pkg/apis/flows/v1beta1/register.go @@ -1,5 +1,5 @@ /* -Copyright 2018 The Knative Authors +Copyright 2019 The Knative Authors Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/pkg/apis/flows/v1beta1/register_test.go b/pkg/apis/flows/v1beta1/register_test.go index c373ae27cdb..2cee4f4f223 100644 --- a/pkg/apis/flows/v1beta1/register_test.go +++ b/pkg/apis/flows/v1beta1/register_test.go @@ -1,5 +1,5 @@ /* -Copyright 2018 The Knative Authors +Copyright 2019 The Knative Authors Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at From 2bef1ce8a5981031831be93bbfdeac55155983d9 Mon Sep 17 00:00:00 2001 From: Ville Aikas Date: Thu, 7 Nov 2019 09:29:32 -0800 Subject: [PATCH 3/4] Destination moved --- pkg/apis/flows/register.go | 2 +- pkg/apis/flows/v1beta1/doc.go | 2 +- pkg/apis/flows/v1beta1/parallel_types.go | 10 +++---- .../flows/v1beta1/parallel_validation_test.go | 20 +++++++------- pkg/apis/flows/v1beta1/sequence_types.go | 6 ++--- .../flows/v1beta1/sequence_validation_test.go | 26 +++++++++---------- .../flows/v1beta1/zz_generated.deepcopy.go | 18 ++++++------- 7 files changed, 42 insertions(+), 42 deletions(-) diff --git a/pkg/apis/flows/register.go b/pkg/apis/flows/register.go index bf9e7baf01c..d356ace39bc 100644 --- a/pkg/apis/flows/register.go +++ b/pkg/apis/flows/register.go @@ -1,5 +1,5 @@ /* -Copyright 2018 The Knative Authors +Copyright 2019 The Knative Authors Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/pkg/apis/flows/v1beta1/doc.go b/pkg/apis/flows/v1beta1/doc.go index f194c62c1eb..f7513de7fe2 100644 --- a/pkg/apis/flows/v1beta1/doc.go +++ b/pkg/apis/flows/v1beta1/doc.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Package v1alpha1 is the v1alpha1 version of the API. +// 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 index 4ab4f3ba90a..b07d169f6f5 100644 --- a/pkg/apis/flows/v1beta1/parallel_types.go +++ b/pkg/apis/flows/v1beta1/parallel_types.go @@ -25,7 +25,7 @@ import ( "knative.dev/pkg/apis" duckv1 "knative.dev/pkg/apis/duck/v1" duckv1alpha1 "knative.dev/pkg/apis/duck/v1alpha1" - "knative.dev/pkg/apis/v1alpha1" + duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" "knative.dev/pkg/kmeta" ) @@ -76,20 +76,20 @@ type ParallelSpec struct { // 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 *v1alpha1.Destination `json:"reply,omitempty"` + Reply *duckv1beta1.Destination `json:"reply,omitempty"` } type ParallelBranch struct { // Filter is the expression guarding the branch - Filter *v1alpha1.Destination `json:"filter,omitempty"` + Filter *duckv1beta1.Destination `json:"filter,omitempty"` // Subscriber receiving the event when the filter passes - Subscriber v1alpha1.Destination `json:"subscriber"` + Subscriber duckv1beta1.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 *v1alpha1.Destination `json:"reply,omitempty"` + Reply *duckv1beta1.Destination `json:"reply,omitempty"` } // ParallelStatus represents the current state of a Parallel. diff --git a/pkg/apis/flows/v1beta1/parallel_validation_test.go b/pkg/apis/flows/v1beta1/parallel_validation_test.go index 5fa518c5ad2..ea7de8d4f6b 100644 --- a/pkg/apis/flows/v1beta1/parallel_validation_test.go +++ b/pkg/apis/flows/v1beta1/parallel_validation_test.go @@ -25,7 +25,7 @@ import ( "k8s.io/apimachinery/pkg/runtime" eventingduck "knative.dev/eventing/pkg/apis/duck/v1alpha1" "knative.dev/pkg/apis" - "knative.dev/pkg/apis/v1alpha1" + duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" ) func TestParallelValidation(t *testing.T) { @@ -54,7 +54,7 @@ func TestParallelSpecValidation(t *testing.T) { }, Spec: &runtime.RawExtension{}, } - invalidReplyInParallel := ParallelBranch{Subscriber: v1alpha1.Destination{URI: subscriberURI}, + invalidReplyInParallel := ParallelBranch{Subscriber: duckv1beta1.Destination{URI: subscriberURI}, Reply: makeInvalidReply("reply-channel")} tests := []struct { @@ -80,7 +80,7 @@ func TestParallelSpecValidation(t *testing.T) { }, { name: "missing channeltemplatespec", ts: &ParallelSpec{ - Branches: []ParallelBranch{{Subscriber: v1alpha1.Destination{URI: subscriberURI}}}, + Branches: []ParallelBranch{{Subscriber: duckv1beta1.Destination{URI: subscriberURI}}}, }, want: func() *apis.FieldError { fe := apis.ErrMissingField("channelTemplate") @@ -92,7 +92,7 @@ func TestParallelSpecValidation(t *testing.T) { ChannelTemplate: &eventingduck.ChannelTemplateSpec{ TypeMeta: metav1.TypeMeta{Kind: "mykind"}, Spec: &runtime.RawExtension{}}, - Branches: []ParallelBranch{{Subscriber: v1alpha1.Destination{URI: subscriberURI}}}, + Branches: []ParallelBranch{{Subscriber: duckv1beta1.Destination{URI: subscriberURI}}}, }, want: func() *apis.FieldError { fe := apis.ErrMissingField("channelTemplate.apiVersion") @@ -104,7 +104,7 @@ func TestParallelSpecValidation(t *testing.T) { ChannelTemplate: &eventingduck.ChannelTemplateSpec{ TypeMeta: metav1.TypeMeta{APIVersion: "myapiversion"}, Spec: &runtime.RawExtension{}}, - Branches: []ParallelBranch{{Subscriber: v1alpha1.Destination{URI: subscriberURI}}}, + Branches: []ParallelBranch{{Subscriber: duckv1beta1.Destination{URI: subscriberURI}}}, }, want: func() *apis.FieldError { fe := apis.ErrMissingField("channelTemplate.kind") @@ -114,7 +114,7 @@ func TestParallelSpecValidation(t *testing.T) { name: "valid parallel", ts: &ParallelSpec{ ChannelTemplate: validChannelTemplate, - Branches: []ParallelBranch{{Subscriber: v1alpha1.Destination{URI: subscriberURI}}}, + Branches: []ParallelBranch{{Subscriber: duckv1beta1.Destination{URI: subscriberURI}}}, }, want: func() *apis.FieldError { return nil @@ -123,7 +123,7 @@ func TestParallelSpecValidation(t *testing.T) { name: "valid parallel with valid reply", ts: &ParallelSpec{ ChannelTemplate: validChannelTemplate, - Branches: []ParallelBranch{{Subscriber: v1alpha1.Destination{URI: subscriberURI}}}, + Branches: []ParallelBranch{{Subscriber: duckv1beta1.Destination{URI: subscriberURI}}}, Reply: makeValidReply("reply-channel"), }, want: func() *apis.FieldError { @@ -133,8 +133,8 @@ func TestParallelSpecValidation(t *testing.T) { name: "parallel with invalid missing name", ts: &ParallelSpec{ ChannelTemplate: validChannelTemplate, - Branches: []ParallelBranch{{Subscriber: v1alpha1.Destination{URI: subscriberURI}}}, - Reply: &v1alpha1.Destination{ + Branches: []ParallelBranch{{Subscriber: duckv1beta1.Destination{URI: subscriberURI}}}, + Reply: &duckv1beta1.Destination{ DeprecatedAPIVersion: "messaging.knative.dev/v1alpha1", DeprecatedKind: "inmemorychannel", }, @@ -147,7 +147,7 @@ func TestParallelSpecValidation(t *testing.T) { name: "parallel with invalid reply", ts: &ParallelSpec{ ChannelTemplate: validChannelTemplate, - Branches: []ParallelBranch{{Subscriber: v1alpha1.Destination{URI: subscriberURI}}}, + Branches: []ParallelBranch{{Subscriber: duckv1beta1.Destination{URI: subscriberURI}}}, Reply: makeInvalidReply("reply-channel"), }, want: func() *apis.FieldError { diff --git a/pkg/apis/flows/v1beta1/sequence_types.go b/pkg/apis/flows/v1beta1/sequence_types.go index 0d2fe288bc3..4c9ebd8165b 100644 --- a/pkg/apis/flows/v1beta1/sequence_types.go +++ b/pkg/apis/flows/v1beta1/sequence_types.go @@ -25,7 +25,7 @@ import ( "knative.dev/pkg/apis" duckv1 "knative.dev/pkg/apis/duck/v1" duckv1alpha1 "knative.dev/pkg/apis/duck/v1alpha1" - "knative.dev/pkg/apis/v1alpha1" + duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" "knative.dev/pkg/kmeta" ) @@ -67,7 +67,7 @@ var ( type SequenceSpec struct { // Steps is the list of Destinations (processors / functions) that will be called in the order // provided. - Steps []v1alpha1.Destination `json:"steps"` + Steps []duckv1beta1.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). @@ -76,7 +76,7 @@ type SequenceSpec struct { // Reply is a Reference to where the result of the last Subscriber gets sent to. // +optional - Reply *v1alpha1.Destination `json:"reply,omitempty"` + Reply *duckv1beta1.Destination `json:"reply,omitempty"` } type SequenceChannelStatus struct { diff --git a/pkg/apis/flows/v1beta1/sequence_validation_test.go b/pkg/apis/flows/v1beta1/sequence_validation_test.go index 52aec74825f..ede47f12b9a 100644 --- a/pkg/apis/flows/v1beta1/sequence_validation_test.go +++ b/pkg/apis/flows/v1beta1/sequence_validation_test.go @@ -25,7 +25,7 @@ import ( "k8s.io/apimachinery/pkg/runtime" eventingduck "knative.dev/eventing/pkg/apis/duck/v1alpha1" "knative.dev/pkg/apis" - "knative.dev/pkg/apis/v1alpha1" + duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" ) func TestSequenceValidation(t *testing.T) { @@ -45,16 +45,16 @@ func TestSequenceValidation(t *testing.T) { }) } -func makeValidReply(channelName string) *v1alpha1.Destination { - return &v1alpha1.Destination{ +func makeValidReply(channelName string) *duckv1beta1.Destination { + return &duckv1beta1.Destination{ DeprecatedAPIVersion: "messaging.knative.dev/v1alpha1", DeprecatedKind: "inmemorychannel", DeprecatedName: channelName, } } -func makeInvalidReply(channelName string) *v1alpha1.Destination { - return &v1alpha1.Destination{ +func makeInvalidReply(channelName string) *duckv1beta1.Destination { + return &duckv1beta1.Destination{ DeprecatedKind: "inmemorychannel", DeprecatedName: channelName, } @@ -92,7 +92,7 @@ func TestSequenceSpecValidation(t *testing.T) { }, { name: "missing channeltemplatespec", ts: &SequenceSpec{ - Steps: []v1alpha1.Destination{{URI: subscriberURI}}, + Steps: []duckv1beta1.Destination{{URI: subscriberURI}}, }, want: func() *apis.FieldError { fe := apis.ErrMissingField("channelTemplate") @@ -102,7 +102,7 @@ func TestSequenceSpecValidation(t *testing.T) { name: "invalid channeltemplatespec missing APIVersion", ts: &SequenceSpec{ ChannelTemplate: &eventingduck.ChannelTemplateSpec{TypeMeta: metav1.TypeMeta{Kind: "mykind"}, Spec: &runtime.RawExtension{}}, - Steps: []v1alpha1.Destination{{URI: subscriberURI}}, + Steps: []duckv1beta1.Destination{{URI: subscriberURI}}, }, want: func() *apis.FieldError { fe := apis.ErrMissingField("channelTemplate.apiVersion") @@ -112,7 +112,7 @@ func TestSequenceSpecValidation(t *testing.T) { name: "invalid channeltemplatespec missing Kind", ts: &SequenceSpec{ ChannelTemplate: &eventingduck.ChannelTemplateSpec{TypeMeta: metav1.TypeMeta{APIVersion: "myapiversion"}, Spec: &runtime.RawExtension{}}, - Steps: []v1alpha1.Destination{{URI: subscriberURI}}, + Steps: []duckv1beta1.Destination{{URI: subscriberURI}}, }, want: func() *apis.FieldError { fe := apis.ErrMissingField("channelTemplate.kind") @@ -122,7 +122,7 @@ func TestSequenceSpecValidation(t *testing.T) { name: "valid sequence", ts: &SequenceSpec{ ChannelTemplate: validChannelTemplate, - Steps: []v1alpha1.Destination{{URI: subscriberURI}}, + Steps: []duckv1beta1.Destination{{URI: subscriberURI}}, }, want: func() *apis.FieldError { return nil @@ -131,7 +131,7 @@ func TestSequenceSpecValidation(t *testing.T) { name: "valid sequence with valid reply", ts: &SequenceSpec{ ChannelTemplate: validChannelTemplate, - Steps: []v1alpha1.Destination{{URI: subscriberURI}}, + Steps: []duckv1beta1.Destination{{URI: subscriberURI}}, Reply: makeValidReply("reply-channel"), }, want: func() *apis.FieldError { @@ -141,8 +141,8 @@ func TestSequenceSpecValidation(t *testing.T) { name: "valid sequence with invalid missing name", ts: &SequenceSpec{ ChannelTemplate: validChannelTemplate, - Steps: []v1alpha1.Destination{{URI: subscriberURI}}, - Reply: &v1alpha1.Destination{ + Steps: []duckv1beta1.Destination{{URI: subscriberURI}}, + Reply: &duckv1beta1.Destination{ DeprecatedAPIVersion: "messaging.knative.dev/v1alpha1", DeprecatedKind: "inmemorychannel", }, @@ -155,7 +155,7 @@ func TestSequenceSpecValidation(t *testing.T) { name: "valid sequence with invalid reply", ts: &SequenceSpec{ ChannelTemplate: validChannelTemplate, - Steps: []v1alpha1.Destination{{URI: subscriberURI}}, + Steps: []duckv1beta1.Destination{{URI: subscriberURI}}, Reply: makeInvalidReply("reply-channel"), }, want: func() *apis.FieldError { diff --git a/pkg/apis/flows/v1beta1/zz_generated.deepcopy.go b/pkg/apis/flows/v1beta1/zz_generated.deepcopy.go index 92f8b3c2309..e26f2902e93 100644 --- a/pkg/apis/flows/v1beta1/zz_generated.deepcopy.go +++ b/pkg/apis/flows/v1beta1/zz_generated.deepcopy.go @@ -22,8 +22,8 @@ package v1beta1 import ( runtime "k8s.io/apimachinery/pkg/runtime" - duckv1alpha1 "knative.dev/eventing/pkg/apis/duck/v1alpha1" - v1alpha1 "knative.dev/pkg/apis/v1alpha1" + v1alpha1 "knative.dev/eventing/pkg/apis/duck/v1alpha1" + duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" ) // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. @@ -59,13 +59,13 @@ func (in *ParallelBranch) DeepCopyInto(out *ParallelBranch) { *out = *in if in.Filter != nil { in, out := &in.Filter, &out.Filter - *out = new(v1alpha1.Destination) + *out = new(duckv1beta1.Destination) (*in).DeepCopyInto(*out) } in.Subscriber.DeepCopyInto(&out.Subscriber) if in.Reply != nil { in, out := &in.Reply, &out.Reply - *out = new(v1alpha1.Destination) + *out = new(duckv1beta1.Destination) (*in).DeepCopyInto(*out) } return @@ -163,12 +163,12 @@ func (in *ParallelSpec) DeepCopyInto(out *ParallelSpec) { } if in.ChannelTemplate != nil { in, out := &in.ChannelTemplate, &out.ChannelTemplate - *out = new(duckv1alpha1.ChannelTemplateSpec) + *out = new(v1alpha1.ChannelTemplateSpec) (*in).DeepCopyInto(*out) } if in.Reply != nil { in, out := &in.Reply, &out.Reply - *out = new(v1alpha1.Destination) + *out = new(duckv1beta1.Destination) (*in).DeepCopyInto(*out) } return @@ -312,19 +312,19 @@ func (in *SequenceSpec) DeepCopyInto(out *SequenceSpec) { *out = *in if in.Steps != nil { in, out := &in.Steps, &out.Steps - *out = make([]v1alpha1.Destination, len(*in)) + *out = make([]duckv1beta1.Destination, len(*in)) for i := range *in { (*in)[i].DeepCopyInto(&(*out)[i]) } } if in.ChannelTemplate != nil { in, out := &in.ChannelTemplate, &out.ChannelTemplate - *out = new(duckv1alpha1.ChannelTemplateSpec) + *out = new(v1alpha1.ChannelTemplateSpec) (*in).DeepCopyInto(*out) } if in.Reply != nil { in, out := &in.Reply, &out.Reply - *out = new(v1alpha1.Destination) + *out = new(duckv1beta1.Destination) (*in).DeepCopyInto(*out) } return From c6b66ba4ee84828e56b61be8efb7137e58a4f88f Mon Sep 17 00:00:00 2001 From: Ville Aikas Date: Fri, 8 Nov 2019 09:42:38 -0800 Subject: [PATCH 4/4] v1beta1 -> v1alpha1 --- hack/update-codegen.sh | 4 +- pkg/apis/flows/{v1beta1 => v1alpha1}/doc.go | 4 +- .../parallel_defaults.go | 2 +- .../parallel_defaults_test.go | 2 +- .../parallel_lifecycle.go | 2 +- .../parallel_lifecycle_test.go | 2 +- .../{v1beta1 => v1alpha1}/parallel_types.go | 2 +- .../parallel_types_test.go | 4 +- .../parallel_validation.go | 2 +- .../parallel_validation_test.go | 2 +- .../flows/{v1beta1 => v1alpha1}/register.go | 4 +- .../{v1beta1 => v1alpha1}/register_test.go | 2 +- .../sequence_defaults.go | 2 +- .../sequence_defaults_test.go | 2 +- .../sequence_lifecycle.go | 2 +- .../sequence_lifecycle_test.go | 2 +- .../{v1beta1 => v1alpha1}/sequence_types.go | 2 +- .../sequence_types_test.go | 4 +- .../sequence_validation.go | 2 +- .../sequence_validation_test.go | 2 +- .../{v1beta1 => v1alpha1}/test_helpers.go | 2 +- .../zz_generated.deepcopy.go | 20 ++++---- pkg/client/clientset/versioned/clientset.go | 18 +++---- .../versioned/fake/clientset_generated.go | 10 ++-- .../clientset/versioned/fake/register.go | 4 +- .../clientset/versioned/scheme/register.go | 4 +- .../typed/flows/{v1beta1 => v1alpha1}/doc.go | 2 +- .../flows/{v1beta1 => v1alpha1}/fake/doc.go | 0 .../fake/fake_flows_client.go | 10 ++-- .../fake/fake_parallel.go | 50 +++++++++---------- .../fake/fake_sequence.go | 50 +++++++++---------- .../{v1beta1 => v1alpha1}/flows_client.go | 34 ++++++------- .../generated_expansion.go | 2 +- .../flows/{v1beta1 => v1alpha1}/parallel.go | 42 ++++++++-------- .../flows/{v1beta1 => v1alpha1}/sequence.go | 42 ++++++++-------- .../externalversions/flows/interface.go | 12 ++--- .../flows/{v1beta1 => v1alpha1}/interface.go | 2 +- .../flows/{v1beta1 => v1alpha1}/parallel.go | 20 ++++---- .../flows/{v1beta1 => v1alpha1}/sequence.go | 20 ++++---- .../informers/externalversions/generic.go | 12 ++--- .../parallel/fake/fake.go | 4 +- .../parallel/parallel.go | 10 ++-- .../sequence/fake/fake.go | 4 +- .../sequence/sequence.go | 10 ++-- .../expansion_generated.go | 2 +- .../flows/{v1beta1 => v1alpha1}/parallel.go | 24 ++++----- .../flows/{v1beta1 => v1alpha1}/sequence.go | 24 ++++----- 47 files changed, 242 insertions(+), 242 deletions(-) rename pkg/apis/flows/{v1beta1 => v1alpha1}/doc.go (89%) rename pkg/apis/flows/{v1beta1 => v1alpha1}/parallel_defaults.go (98%) rename pkg/apis/flows/{v1beta1 => v1alpha1}/parallel_defaults_test.go (99%) rename pkg/apis/flows/{v1beta1 => v1alpha1}/parallel_lifecycle.go (99%) rename pkg/apis/flows/{v1beta1 => v1alpha1}/parallel_lifecycle_test.go (99%) rename pkg/apis/flows/{v1beta1 => v1alpha1}/parallel_types.go (99%) rename pkg/apis/flows/{v1beta1 => v1alpha1}/parallel_types_test.go (94%) rename pkg/apis/flows/{v1beta1 => v1alpha1}/parallel_validation.go (99%) rename pkg/apis/flows/{v1beta1 => v1alpha1}/parallel_validation_test.go (99%) rename pkg/apis/flows/{v1beta1 => v1alpha1}/register.go (97%) rename pkg/apis/flows/{v1beta1 => v1alpha1}/register_test.go (99%) rename pkg/apis/flows/{v1beta1 => v1alpha1}/sequence_defaults.go (98%) rename pkg/apis/flows/{v1beta1 => v1alpha1}/sequence_defaults_test.go (99%) rename pkg/apis/flows/{v1beta1 => v1alpha1}/sequence_lifecycle.go (99%) rename pkg/apis/flows/{v1beta1 => v1alpha1}/sequence_lifecycle_test.go (99%) rename pkg/apis/flows/{v1beta1 => v1alpha1}/sequence_types.go (99%) rename pkg/apis/flows/{v1beta1 => v1alpha1}/sequence_types_test.go (95%) rename pkg/apis/flows/{v1beta1 => v1alpha1}/sequence_validation.go (98%) rename pkg/apis/flows/{v1beta1 => v1alpha1}/sequence_validation_test.go (99%) rename pkg/apis/flows/{v1beta1 => v1alpha1}/test_helpers.go (98%) rename pkg/apis/flows/{v1beta1 => v1alpha1}/zz_generated.deepcopy.go (96%) rename pkg/client/clientset/versioned/typed/flows/{v1beta1 => v1alpha1}/doc.go (97%) rename pkg/client/clientset/versioned/typed/flows/{v1beta1 => v1alpha1}/fake/doc.go (100%) rename pkg/client/clientset/versioned/typed/flows/{v1beta1 => v1alpha1}/fake/fake_flows_client.go (73%) rename pkg/client/clientset/versioned/typed/flows/{v1beta1 => v1alpha1}/fake/fake_parallel.go (73%) rename pkg/client/clientset/versioned/typed/flows/{v1beta1 => v1alpha1}/fake/fake_sequence.go (73%) rename pkg/client/clientset/versioned/typed/flows/{v1beta1 => v1alpha1}/flows_client.go (62%) rename pkg/client/clientset/versioned/typed/flows/{v1beta1 => v1alpha1}/generated_expansion.go (97%) rename pkg/client/clientset/versioned/typed/flows/{v1beta1 => v1alpha1}/parallel.go (80%) rename pkg/client/clientset/versioned/typed/flows/{v1beta1 => v1alpha1}/sequence.go (80%) rename pkg/client/informers/externalversions/flows/{v1beta1 => v1alpha1}/interface.go (99%) rename pkg/client/informers/externalversions/flows/{v1beta1 => v1alpha1}/parallel.go (84%) rename pkg/client/informers/externalversions/flows/{v1beta1 => v1alpha1}/sequence.go (84%) rename pkg/client/injection/informers/flows/{v1beta1 => v1alpha1}/parallel/fake/fake.go (94%) rename pkg/client/injection/informers/flows/{v1beta1 => v1alpha1}/parallel/parallel.go (82%) rename pkg/client/injection/informers/flows/{v1beta1 => v1alpha1}/sequence/fake/fake.go (94%) rename pkg/client/injection/informers/flows/{v1beta1 => v1alpha1}/sequence/sequence.go (82%) rename pkg/client/listers/flows/{v1beta1 => v1alpha1}/expansion_generated.go (98%) rename pkg/client/listers/flows/{v1beta1 => v1alpha1}/parallel.go (80%) rename pkg/client/listers/flows/{v1beta1 => v1alpha1}/sequence.go (80%) diff --git a/hack/update-codegen.sh b/hack/update-codegen.sh index fcd93d43559..4d27bef1044 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 ./ven # 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 sources:v1alpha1 messaging:v1alpha1 flows:v1beta1" \ + "eventing:v1alpha1 sources:v1alpha1 messaging:v1alpha1 flows:v1alpha1" \ --go-header-file ${REPO_ROOT_DIR}/hack/boilerplate/boilerplate.go.txt # Only deepcopy the Duck types, as they are not real resources. @@ -42,7 +42,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 sources:v1alpha1 messaging:v1alpha1 flows:v1beta1" \ + "eventing:v1alpha1 sources:v1alpha1 messaging:v1alpha1 flows:v1alpha1" \ --go-header-file ${REPO_ROOT_DIR}/hack/boilerplate/boilerplate.go.txt # Make sure our dependencies are up-to-date diff --git a/pkg/apis/flows/v1beta1/doc.go b/pkg/apis/flows/v1alpha1/doc.go similarity index 89% rename from pkg/apis/flows/v1beta1/doc.go rename to pkg/apis/flows/v1alpha1/doc.go index f7513de7fe2..a1ad8899602 100644 --- a/pkg/apis/flows/v1beta1/doc.go +++ b/pkg/apis/flows/v1alpha1/doc.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -// Package v1beta1 is the v1beta1 version of the API. +// Package v1alpha1 is the v1alpha1 version of the API. // +k8s:deepcopy-gen=package // +groupName=flows.knative.dev -package v1beta1 +package v1alpha1 diff --git a/pkg/apis/flows/v1beta1/parallel_defaults.go b/pkg/apis/flows/v1alpha1/parallel_defaults.go similarity index 98% rename from pkg/apis/flows/v1beta1/parallel_defaults.go rename to pkg/apis/flows/v1alpha1/parallel_defaults.go index 20f90179854..21461dff7c5 100644 --- a/pkg/apis/flows/v1beta1/parallel_defaults.go +++ b/pkg/apis/flows/v1alpha1/parallel_defaults.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v1beta1 +package v1alpha1 import ( "context" diff --git a/pkg/apis/flows/v1beta1/parallel_defaults_test.go b/pkg/apis/flows/v1alpha1/parallel_defaults_test.go similarity index 99% rename from pkg/apis/flows/v1beta1/parallel_defaults_test.go rename to pkg/apis/flows/v1alpha1/parallel_defaults_test.go index 893a6f6b41b..3c58958cf1e 100644 --- a/pkg/apis/flows/v1beta1/parallel_defaults_test.go +++ b/pkg/apis/flows/v1alpha1/parallel_defaults_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v1beta1 +package v1alpha1 import ( "context" diff --git a/pkg/apis/flows/v1beta1/parallel_lifecycle.go b/pkg/apis/flows/v1alpha1/parallel_lifecycle.go similarity index 99% rename from pkg/apis/flows/v1beta1/parallel_lifecycle.go rename to pkg/apis/flows/v1alpha1/parallel_lifecycle.go index b3e1af1f5a5..170fa0dc64b 100644 --- a/pkg/apis/flows/v1beta1/parallel_lifecycle.go +++ b/pkg/apis/flows/v1alpha1/parallel_lifecycle.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package v1beta1 +package v1alpha1 import ( "time" diff --git a/pkg/apis/flows/v1beta1/parallel_lifecycle_test.go b/pkg/apis/flows/v1alpha1/parallel_lifecycle_test.go similarity index 99% rename from pkg/apis/flows/v1beta1/parallel_lifecycle_test.go rename to pkg/apis/flows/v1alpha1/parallel_lifecycle_test.go index 546bcd10e9a..8588891a271 100644 --- a/pkg/apis/flows/v1beta1/parallel_lifecycle_test.go +++ b/pkg/apis/flows/v1alpha1/parallel_lifecycle_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v1beta1 +package v1alpha1 import ( "testing" diff --git a/pkg/apis/flows/v1beta1/parallel_types.go b/pkg/apis/flows/v1alpha1/parallel_types.go similarity index 99% rename from pkg/apis/flows/v1beta1/parallel_types.go rename to pkg/apis/flows/v1alpha1/parallel_types.go index b07d169f6f5..8739e7ab1d1 100644 --- a/pkg/apis/flows/v1beta1/parallel_types.go +++ b/pkg/apis/flows/v1alpha1/parallel_types.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package v1beta1 +package v1alpha1 import ( corev1 "k8s.io/api/core/v1" diff --git a/pkg/apis/flows/v1beta1/parallel_types_test.go b/pkg/apis/flows/v1alpha1/parallel_types_test.go similarity index 94% rename from pkg/apis/flows/v1beta1/parallel_types_test.go rename to pkg/apis/flows/v1alpha1/parallel_types_test.go index 8f7ccc1281d..468a2e4ee09 100644 --- a/pkg/apis/flows/v1beta1/parallel_types_test.go +++ b/pkg/apis/flows/v1alpha1/parallel_types_test.go @@ -14,13 +14,13 @@ * limitations under the License. */ -package v1beta1 +package v1alpha1 import "testing" func TestParallelKind(t *testing.T) { parallel := Parallel{} - if parallel.GetGroupVersionKind().String() != "flows.knative.dev/v1beta1, Kind=Parallel" { + if parallel.GetGroupVersionKind().String() != "flows.knative.dev/v1alpha1, Kind=Parallel" { t.Errorf("unexpected gvk: %v", parallel.GetGroupVersionKind()) } } diff --git a/pkg/apis/flows/v1beta1/parallel_validation.go b/pkg/apis/flows/v1alpha1/parallel_validation.go similarity index 99% rename from pkg/apis/flows/v1beta1/parallel_validation.go rename to pkg/apis/flows/v1alpha1/parallel_validation.go index 02a57aa8706..ba6ae1f290b 100644 --- a/pkg/apis/flows/v1beta1/parallel_validation.go +++ b/pkg/apis/flows/v1alpha1/parallel_validation.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v1beta1 +package v1alpha1 import ( "context" diff --git a/pkg/apis/flows/v1beta1/parallel_validation_test.go b/pkg/apis/flows/v1alpha1/parallel_validation_test.go similarity index 99% rename from pkg/apis/flows/v1beta1/parallel_validation_test.go rename to pkg/apis/flows/v1alpha1/parallel_validation_test.go index ea7de8d4f6b..1d257cb09bf 100644 --- a/pkg/apis/flows/v1beta1/parallel_validation_test.go +++ b/pkg/apis/flows/v1alpha1/parallel_validation_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v1beta1 +package v1alpha1 import ( "context" diff --git a/pkg/apis/flows/v1beta1/register.go b/pkg/apis/flows/v1alpha1/register.go similarity index 97% rename from pkg/apis/flows/v1beta1/register.go rename to pkg/apis/flows/v1alpha1/register.go index 79e2dd4246c..b0d49a5876a 100644 --- a/pkg/apis/flows/v1beta1/register.go +++ b/pkg/apis/flows/v1alpha1/register.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v1beta1 +package v1alpha1 import ( "knative.dev/eventing/pkg/apis/flows" @@ -25,7 +25,7 @@ import ( ) // SchemeGroupVersion is group version used to register these objects -var SchemeGroupVersion = schema.GroupVersion{Group: flows.GroupName, Version: "v1beta1"} +var SchemeGroupVersion = schema.GroupVersion{Group: flows.GroupName, Version: "v1alpha1"} // Kind takes an unqualified kind and returns back a Group qualified GroupKind func Kind(kind string) schema.GroupKind { diff --git a/pkg/apis/flows/v1beta1/register_test.go b/pkg/apis/flows/v1alpha1/register_test.go similarity index 99% rename from pkg/apis/flows/v1beta1/register_test.go rename to pkg/apis/flows/v1alpha1/register_test.go index 2cee4f4f223..18781584ff7 100644 --- a/pkg/apis/flows/v1beta1/register_test.go +++ b/pkg/apis/flows/v1alpha1/register_test.go @@ -10,7 +10,7 @@ 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 +package v1alpha1 import ( "testing" diff --git a/pkg/apis/flows/v1beta1/sequence_defaults.go b/pkg/apis/flows/v1alpha1/sequence_defaults.go similarity index 98% rename from pkg/apis/flows/v1beta1/sequence_defaults.go rename to pkg/apis/flows/v1alpha1/sequence_defaults.go index 7ab18167d05..017268237e6 100644 --- a/pkg/apis/flows/v1beta1/sequence_defaults.go +++ b/pkg/apis/flows/v1alpha1/sequence_defaults.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v1beta1 +package v1alpha1 import ( "context" diff --git a/pkg/apis/flows/v1beta1/sequence_defaults_test.go b/pkg/apis/flows/v1alpha1/sequence_defaults_test.go similarity index 99% rename from pkg/apis/flows/v1beta1/sequence_defaults_test.go rename to pkg/apis/flows/v1alpha1/sequence_defaults_test.go index ad9e3e2bc49..67a5ba5df48 100644 --- a/pkg/apis/flows/v1beta1/sequence_defaults_test.go +++ b/pkg/apis/flows/v1alpha1/sequence_defaults_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v1beta1 +package v1alpha1 import ( "context" diff --git a/pkg/apis/flows/v1beta1/sequence_lifecycle.go b/pkg/apis/flows/v1alpha1/sequence_lifecycle.go similarity index 99% rename from pkg/apis/flows/v1beta1/sequence_lifecycle.go rename to pkg/apis/flows/v1alpha1/sequence_lifecycle.go index 4293076387b..ec50f273660 100644 --- a/pkg/apis/flows/v1beta1/sequence_lifecycle.go +++ b/pkg/apis/flows/v1alpha1/sequence_lifecycle.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package v1beta1 +package v1alpha1 import ( "time" diff --git a/pkg/apis/flows/v1beta1/sequence_lifecycle_test.go b/pkg/apis/flows/v1alpha1/sequence_lifecycle_test.go similarity index 99% rename from pkg/apis/flows/v1beta1/sequence_lifecycle_test.go rename to pkg/apis/flows/v1alpha1/sequence_lifecycle_test.go index f466591259d..e5126f93409 100644 --- a/pkg/apis/flows/v1beta1/sequence_lifecycle_test.go +++ b/pkg/apis/flows/v1alpha1/sequence_lifecycle_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v1beta1 +package v1alpha1 import ( "testing" diff --git a/pkg/apis/flows/v1beta1/sequence_types.go b/pkg/apis/flows/v1alpha1/sequence_types.go similarity index 99% rename from pkg/apis/flows/v1beta1/sequence_types.go rename to pkg/apis/flows/v1alpha1/sequence_types.go index 4c9ebd8165b..31e385a8e1e 100644 --- a/pkg/apis/flows/v1beta1/sequence_types.go +++ b/pkg/apis/flows/v1alpha1/sequence_types.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package v1beta1 +package v1alpha1 import ( corev1 "k8s.io/api/core/v1" diff --git a/pkg/apis/flows/v1beta1/sequence_types_test.go b/pkg/apis/flows/v1alpha1/sequence_types_test.go similarity index 95% rename from pkg/apis/flows/v1beta1/sequence_types_test.go rename to pkg/apis/flows/v1alpha1/sequence_types_test.go index 87476fbf61d..9b9edde146d 100644 --- a/pkg/apis/flows/v1beta1/sequence_types_test.go +++ b/pkg/apis/flows/v1alpha1/sequence_types_test.go @@ -14,13 +14,13 @@ * limitations under the License. */ -package v1beta1 +package v1alpha1 import "testing" func TestSequenceKind(t *testing.T) { sequence := Sequence{} - if sequence.GetGroupVersionKind().String() != "flows.knative.dev/v1beta1, Kind=Sequence" { + if sequence.GetGroupVersionKind().String() != "flows.knative.dev/v1alpha1, Kind=Sequence" { t.Errorf("unexpected gvk: %v", sequence.GetGroupVersionKind()) } } diff --git a/pkg/apis/flows/v1beta1/sequence_validation.go b/pkg/apis/flows/v1alpha1/sequence_validation.go similarity index 98% rename from pkg/apis/flows/v1beta1/sequence_validation.go rename to pkg/apis/flows/v1alpha1/sequence_validation.go index 850ed7c1a5b..c7c388cf359 100644 --- a/pkg/apis/flows/v1beta1/sequence_validation.go +++ b/pkg/apis/flows/v1alpha1/sequence_validation.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v1beta1 +package v1alpha1 import ( "context" diff --git a/pkg/apis/flows/v1beta1/sequence_validation_test.go b/pkg/apis/flows/v1alpha1/sequence_validation_test.go similarity index 99% rename from pkg/apis/flows/v1beta1/sequence_validation_test.go rename to pkg/apis/flows/v1alpha1/sequence_validation_test.go index ede47f12b9a..0f7188bbcd2 100644 --- a/pkg/apis/flows/v1beta1/sequence_validation_test.go +++ b/pkg/apis/flows/v1alpha1/sequence_validation_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v1beta1 +package v1alpha1 import ( "context" diff --git a/pkg/apis/flows/v1beta1/test_helpers.go b/pkg/apis/flows/v1alpha1/test_helpers.go similarity index 98% rename from pkg/apis/flows/v1beta1/test_helpers.go rename to pkg/apis/flows/v1alpha1/test_helpers.go index 36ab11de4f6..9cc7f48074d 100644 --- a/pkg/apis/flows/v1beta1/test_helpers.go +++ b/pkg/apis/flows/v1alpha1/test_helpers.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package v1beta1 +package v1alpha1 import ( "github.com/google/go-cmp/cmp/cmpopts" diff --git a/pkg/apis/flows/v1beta1/zz_generated.deepcopy.go b/pkg/apis/flows/v1alpha1/zz_generated.deepcopy.go similarity index 96% rename from pkg/apis/flows/v1beta1/zz_generated.deepcopy.go rename to pkg/apis/flows/v1alpha1/zz_generated.deepcopy.go index e26f2902e93..4d02bd90508 100644 --- a/pkg/apis/flows/v1beta1/zz_generated.deepcopy.go +++ b/pkg/apis/flows/v1alpha1/zz_generated.deepcopy.go @@ -18,12 +18,12 @@ limitations under the License. // Code generated by deepcopy-gen. DO NOT EDIT. -package v1beta1 +package v1alpha1 import ( runtime "k8s.io/apimachinery/pkg/runtime" - v1alpha1 "knative.dev/eventing/pkg/apis/duck/v1alpha1" - duckv1beta1 "knative.dev/pkg/apis/duck/v1beta1" + duckv1alpha1 "knative.dev/eventing/pkg/apis/duck/v1alpha1" + v1beta1 "knative.dev/pkg/apis/duck/v1beta1" ) // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. @@ -59,13 +59,13 @@ func (in *ParallelBranch) DeepCopyInto(out *ParallelBranch) { *out = *in if in.Filter != nil { in, out := &in.Filter, &out.Filter - *out = new(duckv1beta1.Destination) + *out = new(v1beta1.Destination) (*in).DeepCopyInto(*out) } in.Subscriber.DeepCopyInto(&out.Subscriber) if in.Reply != nil { in, out := &in.Reply, &out.Reply - *out = new(duckv1beta1.Destination) + *out = new(v1beta1.Destination) (*in).DeepCopyInto(*out) } return @@ -163,12 +163,12 @@ func (in *ParallelSpec) DeepCopyInto(out *ParallelSpec) { } if in.ChannelTemplate != nil { in, out := &in.ChannelTemplate, &out.ChannelTemplate - *out = new(v1alpha1.ChannelTemplateSpec) + *out = new(duckv1alpha1.ChannelTemplateSpec) (*in).DeepCopyInto(*out) } if in.Reply != nil { in, out := &in.Reply, &out.Reply - *out = new(duckv1beta1.Destination) + *out = new(v1beta1.Destination) (*in).DeepCopyInto(*out) } return @@ -312,19 +312,19 @@ func (in *SequenceSpec) DeepCopyInto(out *SequenceSpec) { *out = *in if in.Steps != nil { in, out := &in.Steps, &out.Steps - *out = make([]duckv1beta1.Destination, len(*in)) + *out = make([]v1beta1.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) + *out = new(duckv1alpha1.ChannelTemplateSpec) (*in).DeepCopyInto(*out) } if in.Reply != nil { in, out := &in.Reply, &out.Reply - *out = new(duckv1beta1.Destination) + *out = new(v1beta1.Destination) (*in).DeepCopyInto(*out) } return diff --git a/pkg/client/clientset/versioned/clientset.go b/pkg/client/clientset/versioned/clientset.go index caedff8a041..7315a7ac9a7 100644 --- a/pkg/client/clientset/versioned/clientset.go +++ b/pkg/client/clientset/versioned/clientset.go @@ -23,7 +23,7 @@ import ( rest "k8s.io/client-go/rest" flowcontrol "k8s.io/client-go/util/flowcontrol" eventingv1alpha1 "knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1alpha1" - flowsv1beta1 "knative.dev/eventing/pkg/client/clientset/versioned/typed/flows/v1beta1" + flowsv1alpha1 "knative.dev/eventing/pkg/client/clientset/versioned/typed/flows/v1alpha1" messagingv1alpha1 "knative.dev/eventing/pkg/client/clientset/versioned/typed/messaging/v1alpha1" sourcesv1alpha1 "knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1" ) @@ -31,7 +31,7 @@ import ( type Interface interface { Discovery() discovery.DiscoveryInterface EventingV1alpha1() eventingv1alpha1.EventingV1alpha1Interface - FlowsV1beta1() flowsv1beta1.FlowsV1beta1Interface + FlowsV1alpha1() flowsv1alpha1.FlowsV1alpha1Interface MessagingV1alpha1() messagingv1alpha1.MessagingV1alpha1Interface SourcesV1alpha1() sourcesv1alpha1.SourcesV1alpha1Interface } @@ -41,7 +41,7 @@ type Interface interface { type Clientset struct { *discovery.DiscoveryClient eventingV1alpha1 *eventingv1alpha1.EventingV1alpha1Client - flowsV1beta1 *flowsv1beta1.FlowsV1beta1Client + flowsV1alpha1 *flowsv1alpha1.FlowsV1alpha1Client messagingV1alpha1 *messagingv1alpha1.MessagingV1alpha1Client sourcesV1alpha1 *sourcesv1alpha1.SourcesV1alpha1Client } @@ -51,9 +51,9 @@ func (c *Clientset) EventingV1alpha1() eventingv1alpha1.EventingV1alpha1Interfac return c.eventingV1alpha1 } -// FlowsV1beta1 retrieves the FlowsV1beta1Client -func (c *Clientset) FlowsV1beta1() flowsv1beta1.FlowsV1beta1Interface { - return c.flowsV1beta1 +// FlowsV1alpha1 retrieves the FlowsV1alpha1Client +func (c *Clientset) FlowsV1alpha1() flowsv1alpha1.FlowsV1alpha1Interface { + return c.flowsV1alpha1 } // MessagingV1alpha1 retrieves the MessagingV1alpha1Client @@ -86,7 +86,7 @@ func NewForConfig(c *rest.Config) (*Clientset, error) { if err != nil { return nil, err } - cs.flowsV1beta1, err = flowsv1beta1.NewForConfig(&configShallowCopy) + cs.flowsV1alpha1, err = flowsv1alpha1.NewForConfig(&configShallowCopy) if err != nil { return nil, err } @@ -111,7 +111,7 @@ func NewForConfig(c *rest.Config) (*Clientset, error) { func NewForConfigOrDie(c *rest.Config) *Clientset { var cs Clientset cs.eventingV1alpha1 = eventingv1alpha1.NewForConfigOrDie(c) - cs.flowsV1beta1 = flowsv1beta1.NewForConfigOrDie(c) + cs.flowsV1alpha1 = flowsv1alpha1.NewForConfigOrDie(c) cs.messagingV1alpha1 = messagingv1alpha1.NewForConfigOrDie(c) cs.sourcesV1alpha1 = sourcesv1alpha1.NewForConfigOrDie(c) @@ -123,7 +123,7 @@ func NewForConfigOrDie(c *rest.Config) *Clientset { func New(c rest.Interface) *Clientset { var cs Clientset cs.eventingV1alpha1 = eventingv1alpha1.New(c) - cs.flowsV1beta1 = flowsv1beta1.New(c) + cs.flowsV1alpha1 = flowsv1alpha1.New(c) cs.messagingV1alpha1 = messagingv1alpha1.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 147927e7346..9b1def4c3c6 100644 --- a/pkg/client/clientset/versioned/fake/clientset_generated.go +++ b/pkg/client/clientset/versioned/fake/clientset_generated.go @@ -27,8 +27,8 @@ import ( clientset "knative.dev/eventing/pkg/client/clientset/versioned" eventingv1alpha1 "knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1alpha1" fakeeventingv1alpha1 "knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/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" + flowsv1alpha1 "knative.dev/eventing/pkg/client/clientset/versioned/typed/flows/v1alpha1" + fakeflowsv1alpha1 "knative.dev/eventing/pkg/client/clientset/versioned/typed/flows/v1alpha1/fake" messagingv1alpha1 "knative.dev/eventing/pkg/client/clientset/versioned/typed/messaging/v1alpha1" fakemessagingv1alpha1 "knative.dev/eventing/pkg/client/clientset/versioned/typed/messaging/v1alpha1/fake" sourcesv1alpha1 "knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha1" @@ -87,9 +87,9 @@ func (c *Clientset) EventingV1alpha1() eventingv1alpha1.EventingV1alpha1Interfac return &fakeeventingv1alpha1.FakeEventingV1alpha1{Fake: &c.Fake} } -// FlowsV1beta1 retrieves the FlowsV1beta1Client -func (c *Clientset) FlowsV1beta1() flowsv1beta1.FlowsV1beta1Interface { - return &fakeflowsv1beta1.FakeFlowsV1beta1{Fake: &c.Fake} +// FlowsV1alpha1 retrieves the FlowsV1alpha1Client +func (c *Clientset) FlowsV1alpha1() flowsv1alpha1.FlowsV1alpha1Interface { + return &fakeflowsv1alpha1.FakeFlowsV1alpha1{Fake: &c.Fake} } // MessagingV1alpha1 retrieves the MessagingV1alpha1Client diff --git a/pkg/client/clientset/versioned/fake/register.go b/pkg/client/clientset/versioned/fake/register.go index 6f2165c0641..0db5432ae03 100644 --- a/pkg/client/clientset/versioned/fake/register.go +++ b/pkg/client/clientset/versioned/fake/register.go @@ -25,7 +25,7 @@ import ( serializer "k8s.io/apimachinery/pkg/runtime/serializer" utilruntime "k8s.io/apimachinery/pkg/util/runtime" eventingv1alpha1 "knative.dev/eventing/pkg/apis/eventing/v1alpha1" - flowsv1beta1 "knative.dev/eventing/pkg/apis/flows/v1beta1" + flowsv1alpha1 "knative.dev/eventing/pkg/apis/flows/v1alpha1" messagingv1alpha1 "knative.dev/eventing/pkg/apis/messaging/v1alpha1" sourcesv1alpha1 "knative.dev/eventing/pkg/apis/sources/v1alpha1" ) @@ -35,7 +35,7 @@ var codecs = serializer.NewCodecFactory(scheme) var parameterCodec = runtime.NewParameterCodec(scheme) var localSchemeBuilder = runtime.SchemeBuilder{ eventingv1alpha1.AddToScheme, - flowsv1beta1.AddToScheme, + flowsv1alpha1.AddToScheme, messagingv1alpha1.AddToScheme, sourcesv1alpha1.AddToScheme, } diff --git a/pkg/client/clientset/versioned/scheme/register.go b/pkg/client/clientset/versioned/scheme/register.go index ea7f0162802..9c2239c0dd7 100644 --- a/pkg/client/clientset/versioned/scheme/register.go +++ b/pkg/client/clientset/versioned/scheme/register.go @@ -25,7 +25,7 @@ import ( serializer "k8s.io/apimachinery/pkg/runtime/serializer" utilruntime "k8s.io/apimachinery/pkg/util/runtime" eventingv1alpha1 "knative.dev/eventing/pkg/apis/eventing/v1alpha1" - flowsv1beta1 "knative.dev/eventing/pkg/apis/flows/v1beta1" + flowsv1alpha1 "knative.dev/eventing/pkg/apis/flows/v1alpha1" messagingv1alpha1 "knative.dev/eventing/pkg/apis/messaging/v1alpha1" sourcesv1alpha1 "knative.dev/eventing/pkg/apis/sources/v1alpha1" ) @@ -35,7 +35,7 @@ var Codecs = serializer.NewCodecFactory(Scheme) var ParameterCodec = runtime.NewParameterCodec(Scheme) var localSchemeBuilder = runtime.SchemeBuilder{ eventingv1alpha1.AddToScheme, - flowsv1beta1.AddToScheme, + flowsv1alpha1.AddToScheme, messagingv1alpha1.AddToScheme, sourcesv1alpha1.AddToScheme, } diff --git a/pkg/client/clientset/versioned/typed/flows/v1beta1/doc.go b/pkg/client/clientset/versioned/typed/flows/v1alpha1/doc.go similarity index 97% rename from pkg/client/clientset/versioned/typed/flows/v1beta1/doc.go rename to pkg/client/clientset/versioned/typed/flows/v1alpha1/doc.go index ede2d4a2879..a1c6bb9fe8f 100644 --- a/pkg/client/clientset/versioned/typed/flows/v1beta1/doc.go +++ b/pkg/client/clientset/versioned/typed/flows/v1alpha1/doc.go @@ -17,4 +17,4 @@ limitations under the License. // Code generated by client-gen. DO NOT EDIT. // This package has the automatically generated typed clients. -package v1beta1 +package v1alpha1 diff --git a/pkg/client/clientset/versioned/typed/flows/v1beta1/fake/doc.go b/pkg/client/clientset/versioned/typed/flows/v1alpha1/fake/doc.go similarity index 100% rename from pkg/client/clientset/versioned/typed/flows/v1beta1/fake/doc.go rename to pkg/client/clientset/versioned/typed/flows/v1alpha1/fake/doc.go diff --git a/pkg/client/clientset/versioned/typed/flows/v1beta1/fake/fake_flows_client.go b/pkg/client/clientset/versioned/typed/flows/v1alpha1/fake/fake_flows_client.go similarity index 73% rename from pkg/client/clientset/versioned/typed/flows/v1beta1/fake/fake_flows_client.go rename to pkg/client/clientset/versioned/typed/flows/v1alpha1/fake/fake_flows_client.go index 6de1435267f..2bb15f9ffed 100644 --- a/pkg/client/clientset/versioned/typed/flows/v1beta1/fake/fake_flows_client.go +++ b/pkg/client/clientset/versioned/typed/flows/v1alpha1/fake/fake_flows_client.go @@ -21,24 +21,24 @@ 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" + v1alpha1 "knative.dev/eventing/pkg/client/clientset/versioned/typed/flows/v1alpha1" ) -type FakeFlowsV1beta1 struct { +type FakeFlowsV1alpha1 struct { *testing.Fake } -func (c *FakeFlowsV1beta1) Parallels(namespace string) v1beta1.ParallelInterface { +func (c *FakeFlowsV1alpha1) Parallels(namespace string) v1alpha1.ParallelInterface { return &FakeParallels{c, namespace} } -func (c *FakeFlowsV1beta1) Sequences(namespace string) v1beta1.SequenceInterface { +func (c *FakeFlowsV1alpha1) Sequences(namespace string) v1alpha1.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 { +func (c *FakeFlowsV1alpha1) 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/v1alpha1/fake/fake_parallel.go similarity index 73% rename from pkg/client/clientset/versioned/typed/flows/v1beta1/fake/fake_parallel.go rename to pkg/client/clientset/versioned/typed/flows/v1alpha1/fake/fake_parallel.go index e5305263a41..3829d87f45f 100644 --- a/pkg/client/clientset/versioned/typed/flows/v1beta1/fake/fake_parallel.go +++ b/pkg/client/clientset/versioned/typed/flows/v1alpha1/fake/fake_parallel.go @@ -25,34 +25,34 @@ import ( 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" + v1alpha1 "knative.dev/eventing/pkg/apis/flows/v1alpha1" ) // FakeParallels implements ParallelInterface type FakeParallels struct { - Fake *FakeFlowsV1beta1 + Fake *FakeFlowsV1alpha1 ns string } -var parallelsResource = schema.GroupVersionResource{Group: "flows.knative.dev", Version: "v1beta1", Resource: "parallels"} +var parallelsResource = schema.GroupVersionResource{Group: "flows.knative.dev", Version: "v1alpha1", Resource: "parallels"} -var parallelsKind = schema.GroupVersionKind{Group: "flows.knative.dev", Version: "v1beta1", Kind: "Parallel"} +var parallelsKind = schema.GroupVersionKind{Group: "flows.knative.dev", Version: "v1alpha1", 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) { +func (c *FakeParallels) Get(name string, options v1.GetOptions) (result *v1alpha1.Parallel, err error) { obj, err := c.Fake. - Invokes(testing.NewGetAction(parallelsResource, c.ns, name), &v1beta1.Parallel{}) + Invokes(testing.NewGetAction(parallelsResource, c.ns, name), &v1alpha1.Parallel{}) if obj == nil { return nil, err } - return obj.(*v1beta1.Parallel), err + return obj.(*v1alpha1.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) { +func (c *FakeParallels) List(opts v1.ListOptions) (result *v1alpha1.ParallelList, err error) { obj, err := c.Fake. - Invokes(testing.NewListAction(parallelsResource, parallelsKind, c.ns, opts), &v1beta1.ParallelList{}) + Invokes(testing.NewListAction(parallelsResource, parallelsKind, c.ns, opts), &v1alpha1.ParallelList{}) if obj == nil { return nil, err @@ -62,8 +62,8 @@ func (c *FakeParallels) List(opts v1.ListOptions) (result *v1beta1.ParallelList, if label == nil { label = labels.Everything() } - list := &v1beta1.ParallelList{ListMeta: obj.(*v1beta1.ParallelList).ListMeta} - for _, item := range obj.(*v1beta1.ParallelList).Items { + list := &v1alpha1.ParallelList{ListMeta: obj.(*v1alpha1.ParallelList).ListMeta} + for _, item := range obj.(*v1alpha1.ParallelList).Items { if label.Matches(labels.Set(item.Labels)) { list.Items = append(list.Items, item) } @@ -79,43 +79,43 @@ func (c *FakeParallels) Watch(opts v1.ListOptions) (watch.Interface, error) { } // 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) { +func (c *FakeParallels) Create(parallel *v1alpha1.Parallel) (result *v1alpha1.Parallel, err error) { obj, err := c.Fake. - Invokes(testing.NewCreateAction(parallelsResource, c.ns, parallel), &v1beta1.Parallel{}) + Invokes(testing.NewCreateAction(parallelsResource, c.ns, parallel), &v1alpha1.Parallel{}) if obj == nil { return nil, err } - return obj.(*v1beta1.Parallel), err + return obj.(*v1alpha1.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) { +func (c *FakeParallels) Update(parallel *v1alpha1.Parallel) (result *v1alpha1.Parallel, err error) { obj, err := c.Fake. - Invokes(testing.NewUpdateAction(parallelsResource, c.ns, parallel), &v1beta1.Parallel{}) + Invokes(testing.NewUpdateAction(parallelsResource, c.ns, parallel), &v1alpha1.Parallel{}) if obj == nil { return nil, err } - return obj.(*v1beta1.Parallel), err + return obj.(*v1alpha1.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) { +func (c *FakeParallels) UpdateStatus(parallel *v1alpha1.Parallel) (*v1alpha1.Parallel, error) { obj, err := c.Fake. - Invokes(testing.NewUpdateSubresourceAction(parallelsResource, "status", c.ns, parallel), &v1beta1.Parallel{}) + Invokes(testing.NewUpdateSubresourceAction(parallelsResource, "status", c.ns, parallel), &v1alpha1.Parallel{}) if obj == nil { return nil, err } - return obj.(*v1beta1.Parallel), err + return obj.(*v1alpha1.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{}) + Invokes(testing.NewDeleteAction(parallelsResource, c.ns, name), &v1alpha1.Parallel{}) return err } @@ -124,17 +124,17 @@ func (c *FakeParallels) Delete(name string, options *v1.DeleteOptions) error { 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{}) + _, err := c.Fake.Invokes(action, &v1alpha1.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) { +func (c *FakeParallels) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.Parallel, err error) { obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(parallelsResource, c.ns, name, pt, data, subresources...), &v1beta1.Parallel{}) + Invokes(testing.NewPatchSubresourceAction(parallelsResource, c.ns, name, pt, data, subresources...), &v1alpha1.Parallel{}) if obj == nil { return nil, err } - return obj.(*v1beta1.Parallel), err + return obj.(*v1alpha1.Parallel), err } diff --git a/pkg/client/clientset/versioned/typed/flows/v1beta1/fake/fake_sequence.go b/pkg/client/clientset/versioned/typed/flows/v1alpha1/fake/fake_sequence.go similarity index 73% rename from pkg/client/clientset/versioned/typed/flows/v1beta1/fake/fake_sequence.go rename to pkg/client/clientset/versioned/typed/flows/v1alpha1/fake/fake_sequence.go index bc939eb7ed8..7bf1239ba6a 100644 --- a/pkg/client/clientset/versioned/typed/flows/v1beta1/fake/fake_sequence.go +++ b/pkg/client/clientset/versioned/typed/flows/v1alpha1/fake/fake_sequence.go @@ -25,34 +25,34 @@ import ( 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" + v1alpha1 "knative.dev/eventing/pkg/apis/flows/v1alpha1" ) // FakeSequences implements SequenceInterface type FakeSequences struct { - Fake *FakeFlowsV1beta1 + Fake *FakeFlowsV1alpha1 ns string } -var sequencesResource = schema.GroupVersionResource{Group: "flows.knative.dev", Version: "v1beta1", Resource: "sequences"} +var sequencesResource = schema.GroupVersionResource{Group: "flows.knative.dev", Version: "v1alpha1", Resource: "sequences"} -var sequencesKind = schema.GroupVersionKind{Group: "flows.knative.dev", Version: "v1beta1", Kind: "Sequence"} +var sequencesKind = schema.GroupVersionKind{Group: "flows.knative.dev", Version: "v1alpha1", 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) { +func (c *FakeSequences) Get(name string, options v1.GetOptions) (result *v1alpha1.Sequence, err error) { obj, err := c.Fake. - Invokes(testing.NewGetAction(sequencesResource, c.ns, name), &v1beta1.Sequence{}) + Invokes(testing.NewGetAction(sequencesResource, c.ns, name), &v1alpha1.Sequence{}) if obj == nil { return nil, err } - return obj.(*v1beta1.Sequence), err + return obj.(*v1alpha1.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) { +func (c *FakeSequences) List(opts v1.ListOptions) (result *v1alpha1.SequenceList, err error) { obj, err := c.Fake. - Invokes(testing.NewListAction(sequencesResource, sequencesKind, c.ns, opts), &v1beta1.SequenceList{}) + Invokes(testing.NewListAction(sequencesResource, sequencesKind, c.ns, opts), &v1alpha1.SequenceList{}) if obj == nil { return nil, err @@ -62,8 +62,8 @@ func (c *FakeSequences) List(opts v1.ListOptions) (result *v1beta1.SequenceList, if label == nil { label = labels.Everything() } - list := &v1beta1.SequenceList{ListMeta: obj.(*v1beta1.SequenceList).ListMeta} - for _, item := range obj.(*v1beta1.SequenceList).Items { + list := &v1alpha1.SequenceList{ListMeta: obj.(*v1alpha1.SequenceList).ListMeta} + for _, item := range obj.(*v1alpha1.SequenceList).Items { if label.Matches(labels.Set(item.Labels)) { list.Items = append(list.Items, item) } @@ -79,43 +79,43 @@ func (c *FakeSequences) Watch(opts v1.ListOptions) (watch.Interface, error) { } // 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) { +func (c *FakeSequences) Create(sequence *v1alpha1.Sequence) (result *v1alpha1.Sequence, err error) { obj, err := c.Fake. - Invokes(testing.NewCreateAction(sequencesResource, c.ns, sequence), &v1beta1.Sequence{}) + Invokes(testing.NewCreateAction(sequencesResource, c.ns, sequence), &v1alpha1.Sequence{}) if obj == nil { return nil, err } - return obj.(*v1beta1.Sequence), err + return obj.(*v1alpha1.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) { +func (c *FakeSequences) Update(sequence *v1alpha1.Sequence) (result *v1alpha1.Sequence, err error) { obj, err := c.Fake. - Invokes(testing.NewUpdateAction(sequencesResource, c.ns, sequence), &v1beta1.Sequence{}) + Invokes(testing.NewUpdateAction(sequencesResource, c.ns, sequence), &v1alpha1.Sequence{}) if obj == nil { return nil, err } - return obj.(*v1beta1.Sequence), err + return obj.(*v1alpha1.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) { +func (c *FakeSequences) UpdateStatus(sequence *v1alpha1.Sequence) (*v1alpha1.Sequence, error) { obj, err := c.Fake. - Invokes(testing.NewUpdateSubresourceAction(sequencesResource, "status", c.ns, sequence), &v1beta1.Sequence{}) + Invokes(testing.NewUpdateSubresourceAction(sequencesResource, "status", c.ns, sequence), &v1alpha1.Sequence{}) if obj == nil { return nil, err } - return obj.(*v1beta1.Sequence), err + return obj.(*v1alpha1.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{}) + Invokes(testing.NewDeleteAction(sequencesResource, c.ns, name), &v1alpha1.Sequence{}) return err } @@ -124,17 +124,17 @@ func (c *FakeSequences) Delete(name string, options *v1.DeleteOptions) error { 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{}) + _, err := c.Fake.Invokes(action, &v1alpha1.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) { +func (c *FakeSequences) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.Sequence, err error) { obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(sequencesResource, c.ns, name, pt, data, subresources...), &v1beta1.Sequence{}) + Invokes(testing.NewPatchSubresourceAction(sequencesResource, c.ns, name, pt, data, subresources...), &v1alpha1.Sequence{}) if obj == nil { return nil, err } - return obj.(*v1beta1.Sequence), err + return obj.(*v1alpha1.Sequence), err } diff --git a/pkg/client/clientset/versioned/typed/flows/v1beta1/flows_client.go b/pkg/client/clientset/versioned/typed/flows/v1alpha1/flows_client.go similarity index 62% rename from pkg/client/clientset/versioned/typed/flows/v1beta1/flows_client.go rename to pkg/client/clientset/versioned/typed/flows/v1alpha1/flows_client.go index b6a4de90026..bbe1f32d639 100644 --- a/pkg/client/clientset/versioned/typed/flows/v1beta1/flows_client.go +++ b/pkg/client/clientset/versioned/typed/flows/v1alpha1/flows_client.go @@ -16,35 +16,35 @@ limitations under the License. // Code generated by client-gen. DO NOT EDIT. -package v1beta1 +package v1alpha1 import ( rest "k8s.io/client-go/rest" - v1beta1 "knative.dev/eventing/pkg/apis/flows/v1beta1" + v1alpha1 "knative.dev/eventing/pkg/apis/flows/v1alpha1" "knative.dev/eventing/pkg/client/clientset/versioned/scheme" ) -type FlowsV1beta1Interface interface { +type FlowsV1alpha1Interface interface { RESTClient() rest.Interface ParallelsGetter SequencesGetter } -// FlowsV1beta1Client is used to interact with features provided by the flows.knative.dev group. -type FlowsV1beta1Client struct { +// FlowsV1alpha1Client is used to interact with features provided by the flows.knative.dev group. +type FlowsV1alpha1Client struct { restClient rest.Interface } -func (c *FlowsV1beta1Client) Parallels(namespace string) ParallelInterface { +func (c *FlowsV1alpha1Client) Parallels(namespace string) ParallelInterface { return newParallels(c, namespace) } -func (c *FlowsV1beta1Client) Sequences(namespace string) SequenceInterface { +func (c *FlowsV1alpha1Client) Sequences(namespace string) SequenceInterface { return newSequences(c, namespace) } -// NewForConfig creates a new FlowsV1beta1Client for the given config. -func NewForConfig(c *rest.Config) (*FlowsV1beta1Client, error) { +// NewForConfig creates a new FlowsV1alpha1Client for the given config. +func NewForConfig(c *rest.Config) (*FlowsV1alpha1Client, error) { config := *c if err := setConfigDefaults(&config); err != nil { return nil, err @@ -53,12 +53,12 @@ func NewForConfig(c *rest.Config) (*FlowsV1beta1Client, error) { if err != nil { return nil, err } - return &FlowsV1beta1Client{client}, nil + return &FlowsV1alpha1Client{client}, nil } -// NewForConfigOrDie creates a new FlowsV1beta1Client for the given config and +// NewForConfigOrDie creates a new FlowsV1alpha1Client for the given config and // panics if there is an error in the config. -func NewForConfigOrDie(c *rest.Config) *FlowsV1beta1Client { +func NewForConfigOrDie(c *rest.Config) *FlowsV1alpha1Client { client, err := NewForConfig(c) if err != nil { panic(err) @@ -66,13 +66,13 @@ func NewForConfigOrDie(c *rest.Config) *FlowsV1beta1Client { return client } -// New creates a new FlowsV1beta1Client for the given RESTClient. -func New(c rest.Interface) *FlowsV1beta1Client { - return &FlowsV1beta1Client{c} +// New creates a new FlowsV1alpha1Client for the given RESTClient. +func New(c rest.Interface) *FlowsV1alpha1Client { + return &FlowsV1alpha1Client{c} } func setConfigDefaults(config *rest.Config) error { - gv := v1beta1.SchemeGroupVersion + gv := v1alpha1.SchemeGroupVersion config.GroupVersion = &gv config.APIPath = "/apis" config.NegotiatedSerializer = scheme.Codecs.WithoutConversion() @@ -86,7 +86,7 @@ func setConfigDefaults(config *rest.Config) error { // RESTClient returns a RESTClient that is used to communicate // with API server by this client implementation. -func (c *FlowsV1beta1Client) RESTClient() rest.Interface { +func (c *FlowsV1alpha1Client) RESTClient() rest.Interface { if c == nil { return nil } diff --git a/pkg/client/clientset/versioned/typed/flows/v1beta1/generated_expansion.go b/pkg/client/clientset/versioned/typed/flows/v1alpha1/generated_expansion.go similarity index 97% rename from pkg/client/clientset/versioned/typed/flows/v1beta1/generated_expansion.go rename to pkg/client/clientset/versioned/typed/flows/v1alpha1/generated_expansion.go index 4cc45c964fb..13e7348a3c7 100644 --- a/pkg/client/clientset/versioned/typed/flows/v1beta1/generated_expansion.go +++ b/pkg/client/clientset/versioned/typed/flows/v1alpha1/generated_expansion.go @@ -16,7 +16,7 @@ limitations under the License. // Code generated by client-gen. DO NOT EDIT. -package v1beta1 +package v1alpha1 type ParallelExpansion interface{} diff --git a/pkg/client/clientset/versioned/typed/flows/v1beta1/parallel.go b/pkg/client/clientset/versioned/typed/flows/v1alpha1/parallel.go similarity index 80% rename from pkg/client/clientset/versioned/typed/flows/v1beta1/parallel.go rename to pkg/client/clientset/versioned/typed/flows/v1alpha1/parallel.go index 4654e49ab8a..9d22e7feafe 100644 --- a/pkg/client/clientset/versioned/typed/flows/v1beta1/parallel.go +++ b/pkg/client/clientset/versioned/typed/flows/v1alpha1/parallel.go @@ -16,7 +16,7 @@ limitations under the License. // Code generated by client-gen. DO NOT EDIT. -package v1beta1 +package v1alpha1 import ( "time" @@ -25,7 +25,7 @@ import ( 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" + v1alpha1 "knative.dev/eventing/pkg/apis/flows/v1alpha1" scheme "knative.dev/eventing/pkg/client/clientset/versioned/scheme" ) @@ -37,15 +37,15 @@ type ParallelsGetter interface { // 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) + Create(*v1alpha1.Parallel) (*v1alpha1.Parallel, error) + Update(*v1alpha1.Parallel) (*v1alpha1.Parallel, error) + UpdateStatus(*v1alpha1.Parallel) (*v1alpha1.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) + Get(name string, options v1.GetOptions) (*v1alpha1.Parallel, error) + List(opts v1.ListOptions) (*v1alpha1.ParallelList, error) Watch(opts v1.ListOptions) (watch.Interface, error) - Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.Parallel, err error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.Parallel, err error) ParallelExpansion } @@ -56,7 +56,7 @@ type parallels struct { } // newParallels returns a Parallels -func newParallels(c *FlowsV1beta1Client, namespace string) *parallels { +func newParallels(c *FlowsV1alpha1Client, namespace string) *parallels { return ¶llels{ client: c.RESTClient(), ns: namespace, @@ -64,8 +64,8 @@ func newParallels(c *FlowsV1beta1Client, namespace string) *parallels { } // 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{} +func (c *parallels) Get(name string, options v1.GetOptions) (result *v1alpha1.Parallel, err error) { + result = &v1alpha1.Parallel{} err = c.client.Get(). Namespace(c.ns). Resource("parallels"). @@ -77,12 +77,12 @@ func (c *parallels) Get(name string, options v1.GetOptions) (result *v1beta1.Par } // 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) { +func (c *parallels) List(opts v1.ListOptions) (result *v1alpha1.ParallelList, err error) { var timeout time.Duration if opts.TimeoutSeconds != nil { timeout = time.Duration(*opts.TimeoutSeconds) * time.Second } - result = &v1beta1.ParallelList{} + result = &v1alpha1.ParallelList{} err = c.client.Get(). Namespace(c.ns). Resource("parallels"). @@ -109,8 +109,8 @@ func (c *parallels) Watch(opts v1.ListOptions) (watch.Interface, error) { } // 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{} +func (c *parallels) Create(parallel *v1alpha1.Parallel) (result *v1alpha1.Parallel, err error) { + result = &v1alpha1.Parallel{} err = c.client.Post(). Namespace(c.ns). Resource("parallels"). @@ -121,8 +121,8 @@ func (c *parallels) Create(parallel *v1beta1.Parallel) (result *v1beta1.Parallel } // 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{} +func (c *parallels) Update(parallel *v1alpha1.Parallel) (result *v1alpha1.Parallel, err error) { + result = &v1alpha1.Parallel{} err = c.client.Put(). Namespace(c.ns). Resource("parallels"). @@ -136,8 +136,8 @@ func (c *parallels) Update(parallel *v1beta1.Parallel) (result *v1beta1.Parallel // 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{} +func (c *parallels) UpdateStatus(parallel *v1alpha1.Parallel) (result *v1alpha1.Parallel, err error) { + result = &v1alpha1.Parallel{} err = c.client.Put(). Namespace(c.ns). Resource("parallels"). @@ -177,8 +177,8 @@ func (c *parallels) DeleteCollection(options *v1.DeleteOptions, listOptions v1.L } // 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{} +func (c *parallels) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.Parallel, err error) { + result = &v1alpha1.Parallel{} err = c.client.Patch(pt). Namespace(c.ns). Resource("parallels"). diff --git a/pkg/client/clientset/versioned/typed/flows/v1beta1/sequence.go b/pkg/client/clientset/versioned/typed/flows/v1alpha1/sequence.go similarity index 80% rename from pkg/client/clientset/versioned/typed/flows/v1beta1/sequence.go rename to pkg/client/clientset/versioned/typed/flows/v1alpha1/sequence.go index d003e87700e..d54fd3fb1ce 100644 --- a/pkg/client/clientset/versioned/typed/flows/v1beta1/sequence.go +++ b/pkg/client/clientset/versioned/typed/flows/v1alpha1/sequence.go @@ -16,7 +16,7 @@ limitations under the License. // Code generated by client-gen. DO NOT EDIT. -package v1beta1 +package v1alpha1 import ( "time" @@ -25,7 +25,7 @@ import ( 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" + v1alpha1 "knative.dev/eventing/pkg/apis/flows/v1alpha1" scheme "knative.dev/eventing/pkg/client/clientset/versioned/scheme" ) @@ -37,15 +37,15 @@ type SequencesGetter interface { // 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) + Create(*v1alpha1.Sequence) (*v1alpha1.Sequence, error) + Update(*v1alpha1.Sequence) (*v1alpha1.Sequence, error) + UpdateStatus(*v1alpha1.Sequence) (*v1alpha1.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) + Get(name string, options v1.GetOptions) (*v1alpha1.Sequence, error) + List(opts v1.ListOptions) (*v1alpha1.SequenceList, error) Watch(opts v1.ListOptions) (watch.Interface, error) - Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1beta1.Sequence, err error) + Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.Sequence, err error) SequenceExpansion } @@ -56,7 +56,7 @@ type sequences struct { } // newSequences returns a Sequences -func newSequences(c *FlowsV1beta1Client, namespace string) *sequences { +func newSequences(c *FlowsV1alpha1Client, namespace string) *sequences { return &sequences{ client: c.RESTClient(), ns: namespace, @@ -64,8 +64,8 @@ func newSequences(c *FlowsV1beta1Client, namespace string) *sequences { } // 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{} +func (c *sequences) Get(name string, options v1.GetOptions) (result *v1alpha1.Sequence, err error) { + result = &v1alpha1.Sequence{} err = c.client.Get(). Namespace(c.ns). Resource("sequences"). @@ -77,12 +77,12 @@ func (c *sequences) Get(name string, options v1.GetOptions) (result *v1beta1.Seq } // 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) { +func (c *sequences) List(opts v1.ListOptions) (result *v1alpha1.SequenceList, err error) { var timeout time.Duration if opts.TimeoutSeconds != nil { timeout = time.Duration(*opts.TimeoutSeconds) * time.Second } - result = &v1beta1.SequenceList{} + result = &v1alpha1.SequenceList{} err = c.client.Get(). Namespace(c.ns). Resource("sequences"). @@ -109,8 +109,8 @@ func (c *sequences) Watch(opts v1.ListOptions) (watch.Interface, error) { } // 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{} +func (c *sequences) Create(sequence *v1alpha1.Sequence) (result *v1alpha1.Sequence, err error) { + result = &v1alpha1.Sequence{} err = c.client.Post(). Namespace(c.ns). Resource("sequences"). @@ -121,8 +121,8 @@ func (c *sequences) Create(sequence *v1beta1.Sequence) (result *v1beta1.Sequence } // 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{} +func (c *sequences) Update(sequence *v1alpha1.Sequence) (result *v1alpha1.Sequence, err error) { + result = &v1alpha1.Sequence{} err = c.client.Put(). Namespace(c.ns). Resource("sequences"). @@ -136,8 +136,8 @@ func (c *sequences) Update(sequence *v1beta1.Sequence) (result *v1beta1.Sequence // 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{} +func (c *sequences) UpdateStatus(sequence *v1alpha1.Sequence) (result *v1alpha1.Sequence, err error) { + result = &v1alpha1.Sequence{} err = c.client.Put(). Namespace(c.ns). Resource("sequences"). @@ -177,8 +177,8 @@ func (c *sequences) DeleteCollection(options *v1.DeleteOptions, listOptions v1.L } // 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{} +func (c *sequences) Patch(name string, pt types.PatchType, data []byte, subresources ...string) (result *v1alpha1.Sequence, err error) { + result = &v1alpha1.Sequence{} err = c.client.Patch(pt). Namespace(c.ns). Resource("sequences"). diff --git a/pkg/client/informers/externalversions/flows/interface.go b/pkg/client/informers/externalversions/flows/interface.go index 5d253ea4d7c..c9216cddf0b 100644 --- a/pkg/client/informers/externalversions/flows/interface.go +++ b/pkg/client/informers/externalversions/flows/interface.go @@ -19,14 +19,14 @@ limitations under the License. package flows import ( - v1beta1 "knative.dev/eventing/pkg/client/informers/externalversions/flows/v1beta1" + v1alpha1 "knative.dev/eventing/pkg/client/informers/externalversions/flows/v1alpha1" internalinterfaces "knative.dev/eventing/pkg/client/informers/externalversions/internalinterfaces" ) // Interface provides access to each of this group's versions. type Interface interface { - // V1beta1 provides access to shared informers for resources in V1beta1. - V1beta1() v1beta1.Interface + // V1alpha1 provides access to shared informers for resources in V1alpha1. + V1alpha1() v1alpha1.Interface } type group struct { @@ -40,7 +40,7 @@ func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakList return &group{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} } -// V1beta1 returns a new v1beta1.Interface. -func (g *group) V1beta1() v1beta1.Interface { - return v1beta1.New(g.factory, g.namespace, g.tweakListOptions) +// V1alpha1 returns a new v1alpha1.Interface. +func (g *group) V1alpha1() v1alpha1.Interface { + return v1alpha1.New(g.factory, g.namespace, g.tweakListOptions) } diff --git a/pkg/client/informers/externalversions/flows/v1beta1/interface.go b/pkg/client/informers/externalversions/flows/v1alpha1/interface.go similarity index 99% rename from pkg/client/informers/externalversions/flows/v1beta1/interface.go rename to pkg/client/informers/externalversions/flows/v1alpha1/interface.go index 38838af960b..ba5b97cd2a3 100644 --- a/pkg/client/informers/externalversions/flows/v1beta1/interface.go +++ b/pkg/client/informers/externalversions/flows/v1alpha1/interface.go @@ -16,7 +16,7 @@ limitations under the License. // Code generated by informer-gen. DO NOT EDIT. -package v1beta1 +package v1alpha1 import ( internalinterfaces "knative.dev/eventing/pkg/client/informers/externalversions/internalinterfaces" diff --git a/pkg/client/informers/externalversions/flows/v1beta1/parallel.go b/pkg/client/informers/externalversions/flows/v1alpha1/parallel.go similarity index 84% rename from pkg/client/informers/externalversions/flows/v1beta1/parallel.go rename to pkg/client/informers/externalversions/flows/v1alpha1/parallel.go index e775c7af2ab..6ca59ad50b6 100644 --- a/pkg/client/informers/externalversions/flows/v1beta1/parallel.go +++ b/pkg/client/informers/externalversions/flows/v1alpha1/parallel.go @@ -16,7 +16,7 @@ limitations under the License. // Code generated by informer-gen. DO NOT EDIT. -package v1beta1 +package v1alpha1 import ( time "time" @@ -25,17 +25,17 @@ import ( 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" + flowsv1alpha1 "knative.dev/eventing/pkg/apis/flows/v1alpha1" 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" + v1alpha1 "knative.dev/eventing/pkg/client/listers/flows/v1alpha1" ) // ParallelInformer provides access to a shared informer and lister for // Parallels. type ParallelInformer interface { Informer() cache.SharedIndexInformer - Lister() v1beta1.ParallelLister + Lister() v1alpha1.ParallelLister } type parallelInformer struct { @@ -61,16 +61,16 @@ func NewFilteredParallelInformer(client versioned.Interface, namespace string, r if tweakListOptions != nil { tweakListOptions(&options) } - return client.FlowsV1beta1().Parallels(namespace).List(options) + return client.FlowsV1alpha1().Parallels(namespace).List(options) }, WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.FlowsV1beta1().Parallels(namespace).Watch(options) + return client.FlowsV1alpha1().Parallels(namespace).Watch(options) }, }, - &flowsv1beta1.Parallel{}, + &flowsv1alpha1.Parallel{}, resyncPeriod, indexers, ) @@ -81,9 +81,9 @@ func (f *parallelInformer) defaultInformer(client versioned.Interface, resyncPer } func (f *parallelInformer) Informer() cache.SharedIndexInformer { - return f.factory.InformerFor(&flowsv1beta1.Parallel{}, f.defaultInformer) + return f.factory.InformerFor(&flowsv1alpha1.Parallel{}, f.defaultInformer) } -func (f *parallelInformer) Lister() v1beta1.ParallelLister { - return v1beta1.NewParallelLister(f.Informer().GetIndexer()) +func (f *parallelInformer) Lister() v1alpha1.ParallelLister { + return v1alpha1.NewParallelLister(f.Informer().GetIndexer()) } diff --git a/pkg/client/informers/externalversions/flows/v1beta1/sequence.go b/pkg/client/informers/externalversions/flows/v1alpha1/sequence.go similarity index 84% rename from pkg/client/informers/externalversions/flows/v1beta1/sequence.go rename to pkg/client/informers/externalversions/flows/v1alpha1/sequence.go index c453ff6a5f5..3a253af3396 100644 --- a/pkg/client/informers/externalversions/flows/v1beta1/sequence.go +++ b/pkg/client/informers/externalversions/flows/v1alpha1/sequence.go @@ -16,7 +16,7 @@ limitations under the License. // Code generated by informer-gen. DO NOT EDIT. -package v1beta1 +package v1alpha1 import ( time "time" @@ -25,17 +25,17 @@ import ( 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" + flowsv1alpha1 "knative.dev/eventing/pkg/apis/flows/v1alpha1" 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" + v1alpha1 "knative.dev/eventing/pkg/client/listers/flows/v1alpha1" ) // SequenceInformer provides access to a shared informer and lister for // Sequences. type SequenceInformer interface { Informer() cache.SharedIndexInformer - Lister() v1beta1.SequenceLister + Lister() v1alpha1.SequenceLister } type sequenceInformer struct { @@ -61,16 +61,16 @@ func NewFilteredSequenceInformer(client versioned.Interface, namespace string, r if tweakListOptions != nil { tweakListOptions(&options) } - return client.FlowsV1beta1().Sequences(namespace).List(options) + return client.FlowsV1alpha1().Sequences(namespace).List(options) }, WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.FlowsV1beta1().Sequences(namespace).Watch(options) + return client.FlowsV1alpha1().Sequences(namespace).Watch(options) }, }, - &flowsv1beta1.Sequence{}, + &flowsv1alpha1.Sequence{}, resyncPeriod, indexers, ) @@ -81,9 +81,9 @@ func (f *sequenceInformer) defaultInformer(client versioned.Interface, resyncPer } func (f *sequenceInformer) Informer() cache.SharedIndexInformer { - return f.factory.InformerFor(&flowsv1beta1.Sequence{}, f.defaultInformer) + return f.factory.InformerFor(&flowsv1alpha1.Sequence{}, f.defaultInformer) } -func (f *sequenceInformer) Lister() v1beta1.SequenceLister { - return v1beta1.NewSequenceLister(f.Informer().GetIndexer()) +func (f *sequenceInformer) Lister() v1alpha1.SequenceLister { + return v1alpha1.NewSequenceLister(f.Informer().GetIndexer()) } diff --git a/pkg/client/informers/externalversions/generic.go b/pkg/client/informers/externalversions/generic.go index 3febc83c7cf..9c446fdeada 100644 --- a/pkg/client/informers/externalversions/generic.go +++ b/pkg/client/informers/externalversions/generic.go @@ -24,7 +24,7 @@ import ( schema "k8s.io/apimachinery/pkg/runtime/schema" cache "k8s.io/client-go/tools/cache" v1alpha1 "knative.dev/eventing/pkg/apis/eventing/v1alpha1" - v1beta1 "knative.dev/eventing/pkg/apis/flows/v1beta1" + flowsv1alpha1 "knative.dev/eventing/pkg/apis/flows/v1alpha1" messagingv1alpha1 "knative.dev/eventing/pkg/apis/messaging/v1alpha1" sourcesv1alpha1 "knative.dev/eventing/pkg/apis/sources/v1alpha1" ) @@ -63,11 +63,11 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource case v1alpha1.SchemeGroupVersion.WithResource("triggers"): return &genericInformer{resource: resource.GroupResource(), informer: f.Eventing().V1alpha1().Triggers().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=flows.knative.dev, Version=v1alpha1 + case flowsv1alpha1.SchemeGroupVersion.WithResource("parallels"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Flows().V1alpha1().Parallels().Informer()}, nil + case flowsv1alpha1.SchemeGroupVersion.WithResource("sequences"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Flows().V1alpha1().Sequences().Informer()}, nil // Group=messaging.knative.dev, Version=v1alpha1 case messagingv1alpha1.SchemeGroupVersion.WithResource("channels"): diff --git a/pkg/client/injection/informers/flows/v1beta1/parallel/fake/fake.go b/pkg/client/injection/informers/flows/v1alpha1/parallel/fake/fake.go similarity index 94% rename from pkg/client/injection/informers/flows/v1beta1/parallel/fake/fake.go rename to pkg/client/injection/informers/flows/v1alpha1/parallel/fake/fake.go index cf6572ae422..bacf044328a 100644 --- a/pkg/client/injection/informers/flows/v1beta1/parallel/fake/fake.go +++ b/pkg/client/injection/informers/flows/v1alpha1/parallel/fake/fake.go @@ -22,7 +22,7 @@ import ( "context" fake "knative.dev/eventing/pkg/client/injection/informers/factory/fake" - parallel "knative.dev/eventing/pkg/client/injection/informers/flows/v1beta1/parallel" + parallel "knative.dev/eventing/pkg/client/injection/informers/flows/v1alpha1/parallel" controller "knative.dev/pkg/controller" injection "knative.dev/pkg/injection" ) @@ -35,6 +35,6 @@ func init() { func withInformer(ctx context.Context) (context.Context, controller.Informer) { f := fake.Get(ctx) - inf := f.Flows().V1beta1().Parallels() + inf := f.Flows().V1alpha1().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/v1alpha1/parallel/parallel.go similarity index 82% rename from pkg/client/injection/informers/flows/v1beta1/parallel/parallel.go rename to pkg/client/injection/informers/flows/v1alpha1/parallel/parallel.go index 8d249678cb0..257e11bb201 100644 --- a/pkg/client/injection/informers/flows/v1beta1/parallel/parallel.go +++ b/pkg/client/injection/informers/flows/v1alpha1/parallel/parallel.go @@ -21,7 +21,7 @@ package parallel import ( "context" - v1beta1 "knative.dev/eventing/pkg/client/informers/externalversions/flows/v1beta1" + v1alpha1 "knative.dev/eventing/pkg/client/informers/externalversions/flows/v1alpha1" factory "knative.dev/eventing/pkg/client/injection/informers/factory" controller "knative.dev/pkg/controller" injection "knative.dev/pkg/injection" @@ -37,16 +37,16 @@ type Key struct{} func withInformer(ctx context.Context) (context.Context, controller.Informer) { f := factory.Get(ctx) - inf := f.Flows().V1beta1().Parallels() + inf := f.Flows().V1alpha1().Parallels() return context.WithValue(ctx, Key{}, inf), inf.Informer() } // Get extracts the typed informer from the context. -func Get(ctx context.Context) v1beta1.ParallelInformer { +func Get(ctx context.Context) v1alpha1.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.") + "Unable to fetch knative.dev/eventing/pkg/client/informers/externalversions/flows/v1alpha1.ParallelInformer from context.") } - return untyped.(v1beta1.ParallelInformer) + return untyped.(v1alpha1.ParallelInformer) } diff --git a/pkg/client/injection/informers/flows/v1beta1/sequence/fake/fake.go b/pkg/client/injection/informers/flows/v1alpha1/sequence/fake/fake.go similarity index 94% rename from pkg/client/injection/informers/flows/v1beta1/sequence/fake/fake.go rename to pkg/client/injection/informers/flows/v1alpha1/sequence/fake/fake.go index f4bb646753d..eec8fb5099b 100644 --- a/pkg/client/injection/informers/flows/v1beta1/sequence/fake/fake.go +++ b/pkg/client/injection/informers/flows/v1alpha1/sequence/fake/fake.go @@ -22,7 +22,7 @@ import ( "context" fake "knative.dev/eventing/pkg/client/injection/informers/factory/fake" - sequence "knative.dev/eventing/pkg/client/injection/informers/flows/v1beta1/sequence" + sequence "knative.dev/eventing/pkg/client/injection/informers/flows/v1alpha1/sequence" controller "knative.dev/pkg/controller" injection "knative.dev/pkg/injection" ) @@ -35,6 +35,6 @@ func init() { func withInformer(ctx context.Context) (context.Context, controller.Informer) { f := fake.Get(ctx) - inf := f.Flows().V1beta1().Sequences() + inf := f.Flows().V1alpha1().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/v1alpha1/sequence/sequence.go similarity index 82% rename from pkg/client/injection/informers/flows/v1beta1/sequence/sequence.go rename to pkg/client/injection/informers/flows/v1alpha1/sequence/sequence.go index 826c95fb69e..c6cd4079d49 100644 --- a/pkg/client/injection/informers/flows/v1beta1/sequence/sequence.go +++ b/pkg/client/injection/informers/flows/v1alpha1/sequence/sequence.go @@ -21,7 +21,7 @@ package sequence import ( "context" - v1beta1 "knative.dev/eventing/pkg/client/informers/externalversions/flows/v1beta1" + v1alpha1 "knative.dev/eventing/pkg/client/informers/externalversions/flows/v1alpha1" factory "knative.dev/eventing/pkg/client/injection/informers/factory" controller "knative.dev/pkg/controller" injection "knative.dev/pkg/injection" @@ -37,16 +37,16 @@ type Key struct{} func withInformer(ctx context.Context) (context.Context, controller.Informer) { f := factory.Get(ctx) - inf := f.Flows().V1beta1().Sequences() + inf := f.Flows().V1alpha1().Sequences() return context.WithValue(ctx, Key{}, inf), inf.Informer() } // Get extracts the typed informer from the context. -func Get(ctx context.Context) v1beta1.SequenceInformer { +func Get(ctx context.Context) v1alpha1.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.") + "Unable to fetch knative.dev/eventing/pkg/client/informers/externalversions/flows/v1alpha1.SequenceInformer from context.") } - return untyped.(v1beta1.SequenceInformer) + return untyped.(v1alpha1.SequenceInformer) } diff --git a/pkg/client/listers/flows/v1beta1/expansion_generated.go b/pkg/client/listers/flows/v1alpha1/expansion_generated.go similarity index 98% rename from pkg/client/listers/flows/v1beta1/expansion_generated.go rename to pkg/client/listers/flows/v1alpha1/expansion_generated.go index a68e66930b9..6ba6372bc12 100644 --- a/pkg/client/listers/flows/v1beta1/expansion_generated.go +++ b/pkg/client/listers/flows/v1alpha1/expansion_generated.go @@ -16,7 +16,7 @@ limitations under the License. // Code generated by lister-gen. DO NOT EDIT. -package v1beta1 +package v1alpha1 // ParallelListerExpansion allows custom methods to be added to // ParallelLister. diff --git a/pkg/client/listers/flows/v1beta1/parallel.go b/pkg/client/listers/flows/v1alpha1/parallel.go similarity index 80% rename from pkg/client/listers/flows/v1beta1/parallel.go rename to pkg/client/listers/flows/v1alpha1/parallel.go index b4a37e48e27..42d088a32b3 100644 --- a/pkg/client/listers/flows/v1beta1/parallel.go +++ b/pkg/client/listers/flows/v1alpha1/parallel.go @@ -16,19 +16,19 @@ limitations under the License. // Code generated by lister-gen. DO NOT EDIT. -package v1beta1 +package v1alpha1 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" + v1alpha1 "knative.dev/eventing/pkg/apis/flows/v1alpha1" ) // ParallelLister helps list Parallels. type ParallelLister interface { // List lists all Parallels in the indexer. - List(selector labels.Selector) (ret []*v1beta1.Parallel, err error) + List(selector labels.Selector) (ret []*v1alpha1.Parallel, err error) // Parallels returns an object that can list and get Parallels. Parallels(namespace string) ParallelNamespaceLister ParallelListerExpansion @@ -45,9 +45,9 @@ func NewParallelLister(indexer cache.Indexer) ParallelLister { } // List lists all Parallels in the indexer. -func (s *parallelLister) List(selector labels.Selector) (ret []*v1beta1.Parallel, err error) { +func (s *parallelLister) List(selector labels.Selector) (ret []*v1alpha1.Parallel, err error) { err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v1beta1.Parallel)) + ret = append(ret, m.(*v1alpha1.Parallel)) }) return ret, err } @@ -60,9 +60,9 @@ func (s *parallelLister) Parallels(namespace string) ParallelNamespaceLister { // 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) + List(selector labels.Selector) (ret []*v1alpha1.Parallel, err error) // Get retrieves the Parallel from the indexer for a given namespace and name. - Get(name string) (*v1beta1.Parallel, error) + Get(name string) (*v1alpha1.Parallel, error) ParallelNamespaceListerExpansion } @@ -74,21 +74,21 @@ type parallelNamespaceLister struct { } // List lists all Parallels in the indexer for a given namespace. -func (s parallelNamespaceLister) List(selector labels.Selector) (ret []*v1beta1.Parallel, err error) { +func (s parallelNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.Parallel, err error) { err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { - ret = append(ret, m.(*v1beta1.Parallel)) + ret = append(ret, m.(*v1alpha1.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) { +func (s parallelNamespaceLister) Get(name string) (*v1alpha1.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 nil, errors.NewNotFound(v1alpha1.Resource("parallel"), name) } - return obj.(*v1beta1.Parallel), nil + return obj.(*v1alpha1.Parallel), nil } diff --git a/pkg/client/listers/flows/v1beta1/sequence.go b/pkg/client/listers/flows/v1alpha1/sequence.go similarity index 80% rename from pkg/client/listers/flows/v1beta1/sequence.go rename to pkg/client/listers/flows/v1alpha1/sequence.go index 4d3868120b6..f863b3c78bc 100644 --- a/pkg/client/listers/flows/v1beta1/sequence.go +++ b/pkg/client/listers/flows/v1alpha1/sequence.go @@ -16,19 +16,19 @@ limitations under the License. // Code generated by lister-gen. DO NOT EDIT. -package v1beta1 +package v1alpha1 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" + v1alpha1 "knative.dev/eventing/pkg/apis/flows/v1alpha1" ) // SequenceLister helps list Sequences. type SequenceLister interface { // List lists all Sequences in the indexer. - List(selector labels.Selector) (ret []*v1beta1.Sequence, err error) + List(selector labels.Selector) (ret []*v1alpha1.Sequence, err error) // Sequences returns an object that can list and get Sequences. Sequences(namespace string) SequenceNamespaceLister SequenceListerExpansion @@ -45,9 +45,9 @@ func NewSequenceLister(indexer cache.Indexer) SequenceLister { } // List lists all Sequences in the indexer. -func (s *sequenceLister) List(selector labels.Selector) (ret []*v1beta1.Sequence, err error) { +func (s *sequenceLister) List(selector labels.Selector) (ret []*v1alpha1.Sequence, err error) { err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v1beta1.Sequence)) + ret = append(ret, m.(*v1alpha1.Sequence)) }) return ret, err } @@ -60,9 +60,9 @@ func (s *sequenceLister) Sequences(namespace string) SequenceNamespaceLister { // 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) + List(selector labels.Selector) (ret []*v1alpha1.Sequence, err error) // Get retrieves the Sequence from the indexer for a given namespace and name. - Get(name string) (*v1beta1.Sequence, error) + Get(name string) (*v1alpha1.Sequence, error) SequenceNamespaceListerExpansion } @@ -74,21 +74,21 @@ type sequenceNamespaceLister struct { } // List lists all Sequences in the indexer for a given namespace. -func (s sequenceNamespaceLister) List(selector labels.Selector) (ret []*v1beta1.Sequence, err error) { +func (s sequenceNamespaceLister) List(selector labels.Selector) (ret []*v1alpha1.Sequence, err error) { err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { - ret = append(ret, m.(*v1beta1.Sequence)) + ret = append(ret, m.(*v1alpha1.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) { +func (s sequenceNamespaceLister) Get(name string) (*v1alpha1.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 nil, errors.NewNotFound(v1alpha1.Resource("sequence"), name) } - return obj.(*v1beta1.Sequence), nil + return obj.(*v1alpha1.Sequence), nil }