diff --git a/config/core/resources/pingsource.yaml b/config/core/resources/pingsource.yaml index 0b7fdf326dd..d50327d78de 100644 --- a/config/core/resources/pingsource.yaml +++ b/config/core/resources/pingsource.yaml @@ -33,7 +33,7 @@ spec: - &version name: v1alpha2 served: true - storage: true + storage: false subresources: status: {} schema: @@ -182,7 +182,7 @@ spec: - <<: *version name: v1beta1 served: true - storage: false + storage: true schema: openAPIV3Schema: type: object diff --git a/config/pre-install/v0.18.0/clusterrole.yaml b/config/pre-install/v0.18.0/clusterrole.yaml index 768303c4346..25a342d90e7 100644 --- a/config/pre-install/v0.18.0/clusterrole.yaml +++ b/config/pre-install/v0.18.0/clusterrole.yaml @@ -37,6 +37,7 @@ rules: resources: - "containersources" - "sinkbindings" + - "pingsources" verbs: &everything - "get" - "list" diff --git a/config/pre-install/v0.18.0/pingsource.yaml b/config/pre-install/v0.18.0/pingsource.yaml new file mode 100644 index 00000000000..df5f9e6175d --- /dev/null +++ b/config/pre-install/v0.18.0/pingsource.yaml @@ -0,0 +1,337 @@ +# Copyright 2020 The Knative Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + labels: + eventing.knative.dev/release: devel + eventing.knative.dev/source: "true" + duck.knative.dev/source: "true" + knative.dev/crd-install: "true" + annotations: + # TODO add schemas and descriptions + registry.knative.dev/eventTypes: | + [ + { "type": "dev.knative.sources.ping" } + ] + name: pingsources.sources.knative.dev +spec: + group: sources.knative.dev + versions: + - &version + name: v1alpha2 + served: true + storage: false + subresources: + status: {} + schema: + openAPIV3Schema: + type: object + description: 'PingSource describes an event source with a fixed payload produced on a specified cron schedule.' + properties: + spec: + type: object + description: 'PingSourceSpec defines the desired state of the PingSource (from the client).' + properties: + ceOverrides: + description: 'CloudEventOverrides defines overrides to control the + output format and modifications of the event sent to the sink.' + type: object + properties: + extensions: + description: 'Extensions specify what attribute are added or + overridden on the outbound event. Each `Extensions` key-value + pair are set on the event as an attribute extension independently.' + type: object + additionalProperties: + type: string + x-kubernetes-preserve-unknown-fields: true + jsonData: + description: 'JsonData is json encoded data used as the body of the + event posted to the sink. Default is empty. If set, datacontenttype + will also be set to "application/json".' + type: string + schedule: + description: 'Schedule is the cronjob schedule. Defaults to `* * * + * *`.' + type: string + sink: + description: 'Sink is a reference to an object that will resolve to + a uri to use as the sink.' + type: object + properties: + ref: + description: 'Ref points to an Addressable.' + type: object + properties: + apiVersion: + description: 'API version of the referent.' + type: string + kind: + description: 'Kind of the referent. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names' + type: string + namespace: + description: 'Namespace of the referent. More info: + https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/ + This is optional field, it gets defaulted to the + object holding it if left out.' + type: string + uri: + description: 'URI can be an absolute URL(non-empty scheme and + non-empty host) pointing to the target or a relative URI. + Relative URIs will be resolved using the base URI retrieved + from Ref.' + type: string + status: + type: object + description: 'PingSourceStatus defines the observed state of PingSource (from the controller).' + properties: + annotations: + description: 'Annotations is additional Status fields for the Resource + to save some additional State as well as convey more information + to the user. This is roughly akin to Annotations on any k8s resource, + just the reconciler conveying richer information outwards.' + type: object + x-kubernetes-preserve-unknown-fields: true + ceAttributes: + description: 'CloudEventAttributes are the specific attributes that + the Source uses as part of its CloudEvents.' + type: array + items: + type: object + properties: + source: + description: 'Source is the CloudEvents source attribute.' + type: string + type: + description: 'Type refers to the CloudEvent type attribute.' + type: string + conditions: + description: 'Conditions the latest available observations of a resource''s + current state.' + type: array + items: + type: object + required: + - type + - status + properties: + lastTransitionTime: + description: 'LastTransitionTime is the last time the condition + transitioned from one status to another. We use VolatileTime + in place of metav1.Time to exclude this from creating + equality.Semantic differences (all other things held + constant).' + type: string + message: + description: 'A human readable message indicating details + about the transition.' + type: string + reason: + description: 'The reason for the condition''s last transition.' + type: string + severity: + description: 'Severity with which to treat failures of + this type of condition. When this is not specified, + it defaults to Error.' + type: string + status: + description: 'Status of the condition, one of True, False, + Unknown.' + type: string + type: + description: 'Type of condition.' + type: string + observedGeneration: + description: 'ObservedGeneration is the "Generation" of the Service + that was last processed by the controller.' + type: integer + format: int64 + sinkUri: + description: 'SinkURI is the current active sink URI that has been + configured for the Source.' + type: string + additionalPrinterColumns: + - name: Sink + type: string + jsonPath: .status.sinkUri + - name: Age + type: date + jsonPath: .metadata.creationTimestamp + - name: Ready + type: string + jsonPath: ".status.conditions[?(@.type=='Ready')].status" + - name: Reason + type: string + jsonPath: ".status.conditions[?(@.type=='Ready')].reason" + - <<: *version + name: v1beta1 + served: true + storage: true + schema: + openAPIV3Schema: + type: object + description: 'PingSource describes an event source with a fixed payload produced on a specified cron schedule.' + properties: + spec: + type: object + description: 'PingSourceSpec defines the desired state of the PingSource (from the client).' + properties: + ceOverrides: + description: 'CloudEventOverrides defines overrides to control the + output format and modifications of the event sent to the sink.' + type: object + properties: + extensions: + description: 'Extensions specify what attribute are added or + overridden on the outbound event. Each `Extensions` key-value + pair are set on the event as an attribute extension independently.' + type: object + additionalProperties: + type: string + x-kubernetes-preserve-unknown-fields: true + jsonData: + description: 'JsonData is json encoded data used as the body of the + event posted to the sink. Default is empty. If set, datacontenttype + will also be set to "application/json".' + type: string + schedule: + description: 'Schedule is the cronjob schedule. Defaults to `* * * + * *`.' + type: string + sink: + description: 'Sink is a reference to an object that will resolve to + a uri to use as the sink.' + type: object + properties: + ref: + description: 'Ref points to an Addressable.' + type: object + properties: + apiVersion: + description: 'API version of the referent.' + type: string + kind: + description: 'Kind of the referent. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + name: + description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names' + type: string + namespace: + description: 'Namespace of the referent. More info: + https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/ + This is optional field, it gets defaulted to the + object holding it if left out.' + type: string + uri: + description: 'URI can be an absolute URL(non-empty scheme and + non-empty host) pointing to the target or a relative URI. + Relative URIs will be resolved using the base URI retrieved + from Ref.' + type: string + timezone: + description: 'Timezone modifies the actual time relative to the specified + timezone. Defaults to the system time zone. More general information + about time zones: https://www.iana.org/time-zones List of valid + timezone values: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones' + type: string + status: + type: object + description: 'PingSourceStatus defines the observed state of PingSource (from the controller).' + properties: + annotations: + description: 'Annotations is additional Status fields for the Resource + to save some additional State as well as convey more information + to the user. This is roughly akin to Annotations on any k8s resource, + just the reconciler conveying richer information outwards.' + type: object + x-kubernetes-preserve-unknown-fields: true + ceAttributes: + description: 'CloudEventAttributes are the specific attributes that + the Source uses as part of its CloudEvents.' + type: array + items: + type: object + properties: + source: + description: 'Source is the CloudEvents source attribute.' + type: string + type: + description: 'Type refers to the CloudEvent type attribute.' + type: string + conditions: + description: 'Conditions the latest available observations of a resource''s + current state.' + type: array + items: + type: object + required: + - type + - status + properties: + lastTransitionTime: + description: 'LastTransitionTime is the last time the condition + transitioned from one status to another. We use VolatileTime + in place of metav1.Time to exclude this from creating + equality.Semantic differences (all other things held + constant).' + type: string + message: + description: 'A human readable message indicating details + about the transition.' + type: string + reason: + description: 'The reason for the condition''s last transition.' + type: string + severity: + description: 'Severity with which to treat failures of + this type of condition. When this is not specified, + it defaults to Error.' + type: string + status: + description: 'Status of the condition, one of True, False, + Unknown.' + type: string + type: + description: 'Type of condition.' + type: string + observedGeneration: + description: 'ObservedGeneration is the "Generation" of the Service + that was last processed by the controller.' + type: integer + format: int64 + sinkUri: + description: 'SinkURI is the current active sink URI that has been + configured for the Source.' + type: string + names: + categories: + - all + - knative + - sources + kind: PingSource + plural: pingsources + scope: Namespaced + conversion: + strategy: Webhook + webhook: + conversionReviewVersions: ["v1", "v1beta1"] + clientConfig: + service: + name: eventing-webhook + namespace: knative-eventing diff --git a/config/pre-install/v0.18.0/storage-version-migration.yaml b/config/pre-install/v0.18.0/storage-version-migration.yaml index 4933465ca78..24aaa2bed93 100644 --- a/config/pre-install/v0.18.0/storage-version-migration.yaml +++ b/config/pre-install/v0.18.0/storage-version-migration.yaml @@ -47,3 +47,4 @@ spec: - "subscriptions.messaging.knative.dev" - "parallels.flows.knative.dev" - "sequences.flows.knative.dev" + - "pingsources.sources.knative.dev" diff --git a/pkg/adapter/mtping/config.go b/pkg/adapter/mtping/config.go index 2c14aa4a5ae..d24f9fc38ef 100644 --- a/pkg/adapter/mtping/config.go +++ b/pkg/adapter/mtping/config.go @@ -20,7 +20,7 @@ import ( corev1 "k8s.io/api/core/v1" "knative.dev/eventing/pkg/apis/eventing" - "knative.dev/eventing/pkg/apis/sources/v1alpha2" + "knative.dev/eventing/pkg/apis/sources/v1beta1" ) type PingConfig struct { @@ -50,7 +50,7 @@ type PingConfigs map[string]PingConfig // Project creates a PingConfig for the given source func Project(i interface{}) interface{} { - obj := i.(*v1alpha2.PingSource) + obj := i.(*v1beta1.PingSource) if scope, ok := obj.Annotations[eventing.ScopeAnnotationKey]; ok && scope != eventing.ScopeCluster { return nil diff --git a/pkg/adapter/mtping/config_test.go b/pkg/adapter/mtping/config_test.go index 61d57dff932..a176697d7c8 100644 --- a/pkg/adapter/mtping/config_test.go +++ b/pkg/adapter/mtping/config_test.go @@ -26,28 +26,28 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" duckv1 "knative.dev/pkg/apis/duck/v1" - sourcesv1alpha2 "knative.dev/eventing/pkg/apis/sources/v1alpha2" + sourcesv1beta1 "knative.dev/eventing/pkg/apis/sources/v1beta1" ) func TestProject(t *testing.T) { testCases := map[string]struct { - source sourcesv1alpha2.PingSource + source sourcesv1beta1.PingSource expected PingConfig }{ "TestAddRunRemoveSchedule": { - source: sourcesv1alpha2.PingSource{ + source: sourcesv1beta1.PingSource{ ObjectMeta: metav1.ObjectMeta{ Name: "test-name", Namespace: "test-ns"}, - Spec: sourcesv1alpha2.PingSourceSpec{ + Spec: sourcesv1beta1.PingSourceSpec{ SourceSpec: duckv1.SourceSpec{ CloudEventOverrides: nil, }, Schedule: "* * * * ?", JsonData: "some data", }, - Status: sourcesv1alpha2.PingSourceStatus{ + Status: sourcesv1beta1.PingSourceStatus{ SourceStatus: duckv1.SourceStatus{ SinkURI: &apis.URL{ Host: "asink", @@ -65,11 +65,11 @@ func TestProject(t *testing.T) { SinkURI: "//asink", }}, "TestAddRunRemoveScheduleWithExtensionOverride": { - source: sourcesv1alpha2.PingSource{ + source: sourcesv1beta1.PingSource{ ObjectMeta: metav1.ObjectMeta{ Name: "test-name", Namespace: "test-ns"}, - Spec: sourcesv1alpha2.PingSourceSpec{ + Spec: sourcesv1beta1.PingSourceSpec{ SourceSpec: duckv1.SourceSpec{ Sink: duckv1.Destination{}, CloudEventOverrides: &duckv1.CloudEventOverrides{ @@ -79,7 +79,7 @@ func TestProject(t *testing.T) { Schedule: "* * * * ?", JsonData: "some data", }, - Status: sourcesv1alpha2.PingSourceStatus{ + Status: sourcesv1beta1.PingSourceStatus{ SourceStatus: duckv1.SourceStatus{ SinkURI: &apis.URL{Host: "anothersink"}, }, diff --git a/pkg/adapter/mtping/controller.go b/pkg/adapter/mtping/controller.go index 4d1aa7f1c3d..699463ab234 100644 --- a/pkg/adapter/mtping/controller.go +++ b/pkg/adapter/mtping/controller.go @@ -22,8 +22,8 @@ import ( "github.com/robfig/cron/v3" eventingclient "knative.dev/eventing/pkg/client/injection/client" - pingsourceinformer "knative.dev/eventing/pkg/client/injection/informers/sources/v1alpha2/pingsource" - pingsourcereconciler "knative.dev/eventing/pkg/client/injection/reconciler/sources/v1alpha2/pingsource" + pingsourceinformer "knative.dev/eventing/pkg/client/injection/informers/sources/v1beta1/pingsource" + pingsourcereconciler "knative.dev/eventing/pkg/client/injection/reconciler/sources/v1beta1/pingsource" kubeclient "knative.dev/pkg/client/injection/kube/client" "knative.dev/pkg/controller" "knative.dev/pkg/logging" diff --git a/pkg/adapter/mtping/controller_test.go b/pkg/adapter/mtping/controller_test.go index df3010ef3e7..97562cf14a5 100644 --- a/pkg/adapter/mtping/controller_test.go +++ b/pkg/adapter/mtping/controller_test.go @@ -22,7 +22,7 @@ import ( . "knative.dev/pkg/reconciler/testing" // Fake injection informers - _ "knative.dev/eventing/pkg/client/injection/informers/sources/v1alpha2/pingsource/fake" + _ "knative.dev/eventing/pkg/client/injection/informers/sources/v1beta1/pingsource/fake" ) func TestNew(t *testing.T) { diff --git a/pkg/adapter/mtping/pingsource.go b/pkg/adapter/mtping/pingsource.go index d01a2e18a82..270d0b29942 100644 --- a/pkg/adapter/mtping/pingsource.go +++ b/pkg/adapter/mtping/pingsource.go @@ -30,10 +30,10 @@ import ( pkgreconciler "knative.dev/pkg/reconciler" "knative.dev/eventing/pkg/apis/eventing" - "knative.dev/eventing/pkg/apis/sources/v1alpha2" + "knative.dev/eventing/pkg/apis/sources/v1beta1" clientset "knative.dev/eventing/pkg/client/clientset/versioned" - pingsourcereconciler "knative.dev/eventing/pkg/client/injection/reconciler/sources/v1alpha2/pingsource" - sourceslisters "knative.dev/eventing/pkg/client/listers/sources/v1alpha2" + pingsourcereconciler "knative.dev/eventing/pkg/client/injection/reconciler/sources/v1beta1/pingsource" + sourceslisters "knative.dev/eventing/pkg/client/listers/sources/v1beta1" ) // Reconciler reconciles PingSources @@ -53,7 +53,7 @@ var _ pingsourcereconciler.Interface = (*Reconciler)(nil) // Check that our Reconciler implements FinalizeKind. var _ pingsourcereconciler.Finalizer = (*Reconciler)(nil) -func (r *Reconciler) ReconcileKind(ctx context.Context, source *v1alpha2.PingSource) pkgreconciler.Event { +func (r *Reconciler) ReconcileKind(ctx context.Context, source *v1beta1.PingSource) pkgreconciler.Event { scope, ok := source.Annotations[eventing.ScopeAnnotationKey] if ok && scope != eventing.ScopeCluster { // Not our responsibility @@ -74,7 +74,7 @@ func (r *Reconciler) ReconcileKind(ctx context.Context, source *v1alpha2.PingSou return reconcileErr } -func (r *Reconciler) reconcile(ctx context.Context, source *v1alpha2.PingSource) error { +func (r *Reconciler) reconcile(ctx context.Context, source *v1beta1.PingSource) error { logging.FromContext(ctx).Info("synchronizing schedule") key := fmt.Sprintf("%s/%s", source.Namespace, source.Name) @@ -110,7 +110,7 @@ func (r *Reconciler) reconcile(ctx context.Context, source *v1alpha2.PingSource) return nil } -func (r *Reconciler) FinalizeKind(ctx context.Context, source *v1alpha2.PingSource) pkgreconciler.Event { +func (r *Reconciler) FinalizeKind(ctx context.Context, source *v1beta1.PingSource) pkgreconciler.Event { key := fmt.Sprintf("%s/%s", source.Namespace, source.Name) r.entryidMu.RLock() diff --git a/pkg/adapter/mtping/pingsource_test.go b/pkg/adapter/mtping/pingsource_test.go index f149ef23550..5c21d04e593 100644 --- a/pkg/adapter/mtping/pingsource_test.go +++ b/pkg/adapter/mtping/pingsource_test.go @@ -28,10 +28,10 @@ import ( testclient "k8s.io/client-go/kubernetes/fake" clientgotesting "k8s.io/client-go/testing" adaptertesting "knative.dev/eventing/pkg/adapter/v2/test" - sourcesv1alpha2 "knative.dev/eventing/pkg/apis/sources/v1alpha2" + sourcesv1beta1 "knative.dev/eventing/pkg/apis/sources/v1beta1" eventingclient "knative.dev/eventing/pkg/client/injection/client" fakeeventingclient "knative.dev/eventing/pkg/client/injection/client/fake" - "knative.dev/eventing/pkg/client/injection/reconciler/sources/v1alpha2/pingsource" + "knative.dev/eventing/pkg/client/injection/reconciler/sources/v1beta1/pingsource" . "knative.dev/eventing/pkg/reconciler/testing" "knative.dev/pkg/apis" duckv1 "knative.dev/pkg/apis/duck/v1" @@ -75,8 +75,8 @@ func TestAllCases(t *testing.T) { Name: "valid schedule", Key: pingsourceKey, Objects: []runtime.Object{ - NewPingSourceV1Alpha2(pingSourceName, testNS, - WithPingSourceV1A2Spec(sourcesv1alpha2.PingSourceSpec{ + NewPingSourceV1Beta1(pingSourceName, testNS, + WithPingSourceV1B1Spec(sourcesv1beta1.PingSourceSpec{ Schedule: testSchedule, JsonData: testData, SourceSpec: duckv1.SourceSpec{ @@ -84,11 +84,10 @@ func TestAllCases(t *testing.T) { CloudEventOverrides: nil, }, }), - WithInitPingSourceV1A2Conditions, - WithValidPingSourceV1A2Schedule, - WithPingSourceV1A2Deployed, - WithPingSourceV1A2Sink(sinkURI), - WithPingSourceV1A2CloudEventAttributes, + WithInitPingSourceV1B1Conditions, + WithPingSourceV1B1Deployed, + WithPingSourceV1B1Sink(sinkURI), + WithPingSourceV1B1CloudEventAttributes, ), }, WantEvents: []string{ @@ -102,8 +101,8 @@ func TestAllCases(t *testing.T) { Name: "valid schedule, with finalizer", Key: pingsourceKey, Objects: []runtime.Object{ - NewPingSourceV1Alpha2(pingSourceName, testNS, - WithPingSourceV1A2Spec(sourcesv1alpha2.PingSourceSpec{ + NewPingSourceV1Beta1(pingSourceName, testNS, + WithPingSourceV1B1Spec(sourcesv1beta1.PingSourceSpec{ Schedule: testSchedule, JsonData: testData, SourceSpec: duckv1.SourceSpec{ @@ -111,12 +110,11 @@ func TestAllCases(t *testing.T) { CloudEventOverrides: nil, }, }), - WithInitPingSourceV1A2Conditions, - WithValidPingSourceV1A2Schedule, - WithPingSourceV1A2Deployed, - WithPingSourceV1A2Sink(sinkURI), - WithPingSourceV1A2CloudEventAttributes, - WithPingSourceV1A2Finalizers(defaultFinalizerName), + WithInitPingSourceV1B1Conditions, + WithPingSourceV1B1Deployed, + WithPingSourceV1B1Sink(sinkURI), + WithPingSourceV1B1CloudEventAttributes, + WithPingSourceV1B1Finalizers(defaultFinalizerName), ), }, WantErr: false, @@ -124,8 +122,8 @@ func TestAllCases(t *testing.T) { Name: "valid schedule, deleted with finalizer", Key: pingsourceKey, Objects: []runtime.Object{ - NewPingSourceV1Alpha2(pingSourceName, testNS, - WithPingSourceV1A2Spec(sourcesv1alpha2.PingSourceSpec{ + NewPingSourceV1Beta1(pingSourceName, testNS, + WithPingSourceV1B1Spec(sourcesv1beta1.PingSourceSpec{ Schedule: testSchedule, JsonData: testData, SourceSpec: duckv1.SourceSpec{ @@ -133,13 +131,12 @@ func TestAllCases(t *testing.T) { CloudEventOverrides: nil, }, }), - WithInitPingSourceV1A2Conditions, - WithValidPingSourceV1A2Schedule, - WithPingSourceV1A2Deployed, - WithPingSourceV1A2Sink(sinkURI), - WithPingSourceV1A2CloudEventAttributes, - WithPingSourceV1A2Finalizers(defaultFinalizerName), - WithPingSourceV1A2Deleted, + WithInitPingSourceV1B1Conditions, + WithPingSourceV1B1Deployed, + WithPingSourceV1B1Sink(sinkURI), + WithPingSourceV1B1CloudEventAttributes, + WithPingSourceV1B1Finalizers(defaultFinalizerName), + WithPingSourceV1B1Deleted, ), }, WantEvents: []string{ @@ -153,8 +150,8 @@ func TestAllCases(t *testing.T) { Name: "valid schedule, deleted without finalizer", Key: pingsourceKey, Objects: []runtime.Object{ - NewPingSourceV1Alpha2(pingSourceName, testNS, - WithPingSourceV1A2Spec(sourcesv1alpha2.PingSourceSpec{ + NewPingSourceV1Beta1(pingSourceName, testNS, + WithPingSourceV1B1Spec(sourcesv1beta1.PingSourceSpec{ Schedule: testSchedule, JsonData: testData, SourceSpec: duckv1.SourceSpec{ @@ -162,12 +159,11 @@ func TestAllCases(t *testing.T) { CloudEventOverrides: nil, }, }), - WithInitPingSourceV1A2Conditions, - WithValidPingSourceV1A2Schedule, - WithPingSourceV1A2Deployed, - WithPingSourceV1A2Sink(sinkURI), - WithPingSourceV1A2CloudEventAttributes, - WithPingSourceV1A2Deleted, + WithInitPingSourceV1B1Conditions, + WithPingSourceV1B1Deployed, + WithPingSourceV1B1Sink(sinkURI), + WithPingSourceV1B1CloudEventAttributes, + WithPingSourceV1B1Deleted, ), }, WantErr: false, @@ -181,13 +177,13 @@ func TestAllCases(t *testing.T) { r := &Reconciler{ kubeClient: testclient.NewSimpleClientset(), eventingClientSet: eventingclient.Get(ctx), - pingsourceLister: listers.GetPingSourceV1alpha2Lister(), + pingsourceLister: listers.GetPingSourceV1beta1Lister(), cronRunner: NewCronJobsRunner(ce, testclient.NewSimpleClientset(), logger), entryidMu: sync.RWMutex{}, entryids: make(map[string]cron.EntryID), } return pingsource.NewReconciler(ctx, logging.FromContext(ctx), - fakeeventingclient.Get(ctx), listers.GetPingSourceV1alpha2Lister(), + fakeeventingclient.Get(ctx), listers.GetPingSourceV1beta1Lister(), controller.GetEventRecorder(ctx), r) }, false, logger)) @@ -202,7 +198,7 @@ func patchFinalizers(namespace, name string, finalizers string) clientgotesting. ActionImpl: clientgotesting.ActionImpl{ Namespace: namespace, Verb: "patch", - Resource: schema.GroupVersionResource{Group: "sources.knative.dev", Version: "v1alpha2", Resource: "pingsources"}, + Resource: schema.GroupVersionResource{Group: "sources.knative.dev", Version: "v1beta1", Resource: "pingsources"}, Subresource: "", }, Name: name, diff --git a/pkg/adapter/mtping/runner.go b/pkg/adapter/mtping/runner.go index 5439deceb3a..41743ff525a 100644 --- a/pkg/adapter/mtping/runner.go +++ b/pkg/adapter/mtping/runner.go @@ -35,7 +35,7 @@ import ( kncloudevents "knative.dev/eventing/pkg/adapter/v2" "knative.dev/eventing/pkg/adapter/v2/util/crstatusevent" - sourcesv1alpha2 "knative.dev/eventing/pkg/apis/sources/v1alpha2" + sourcesv1beta1 "knative.dev/eventing/pkg/apis/sources/v1beta1" "knative.dev/eventing/pkg/utils/cache" ) @@ -77,8 +77,8 @@ func NewCronJobsRunner(ceClient cloudevents.Client, kubeClient kubernetes.Interf func (a *cronJobsRunner) AddSchedule(cfg PingConfig) cron.EntryID { event := cloudevents.NewEvent() - event.SetType(sourcesv1alpha2.PingSourceEventType) - event.SetSource(sourcesv1alpha2.PingSourceSource(cfg.Namespace, cfg.Name)) + event.SetType(sourcesv1beta1.PingSourceEventType) + event.SetSource(sourcesv1beta1.PingSourceSource(cfg.Namespace, cfg.Name)) event.SetData(cloudevents.ApplicationJSON, message(cfg.JsonData)) if cfg.Extensions != nil { for key, override := range cfg.Extensions { @@ -179,7 +179,7 @@ func (a *cronJobsRunner) updateFromConfigMap(cm *corev1.ConfigMap) { } for key, cfg := range cfgs { - cfg.APIVersion = sourcesv1alpha2.SchemeGroupVersion.String() + cfg.APIVersion = sourcesv1beta1.SchemeGroupVersion.String() cfg.Kind = "PingSource" // Is the schedule already cached? diff --git a/pkg/reconciler/mtbroker/broker_test.go b/pkg/reconciler/mtbroker/broker_test.go index 9d6a6b190a8..72a81ea3d72 100644 --- a/pkg/reconciler/mtbroker/broker_test.go +++ b/pkg/reconciler/mtbroker/broker_test.go @@ -33,7 +33,7 @@ import ( "knative.dev/eventing/pkg/apis/eventing" eventingv1 "knative.dev/eventing/pkg/apis/eventing/v1" messagingv1 "knative.dev/eventing/pkg/apis/messaging/v1" - sourcesv1alpha2 "knative.dev/eventing/pkg/apis/sources/v1alpha2" + sourcesv1beta1 "knative.dev/eventing/pkg/apis/sources/v1beta1" fakeeventingclient "knative.dev/eventing/pkg/client/injection/client/fake" "knative.dev/eventing/pkg/client/injection/ducks/duck/v1/channelable" "knative.dev/eventing/pkg/client/injection/reconciler/eventing/v1/broker" @@ -85,7 +85,7 @@ const ( testSchedule = "*/2 * * * *" testData = "data" sinkName = "testsink" - dependencyAnnotation = "{\"kind\":\"PingSource\",\"name\":\"test-ping-source\",\"apiVersion\":\"sources.knative.dev/v1alpha2\"}" + dependencyAnnotation = "{\"kind\":\"PingSource\",\"name\":\"test-ping-source\",\"apiVersion\":\"sources.knative.dev/v1beta1\"}" subscriberURIReference = "foo" subscriberResolvedTargetURI = "http://example.com/subscriber/foo" @@ -724,39 +724,37 @@ func makeFalseStatusSubscription() *messagingv1.Subscription { return s } -func makeFalseStatusPingSource() *sourcesv1alpha2.PingSource { - return rtv1alpha1.NewPingSourceV1Alpha2(pingSourceName, testNS, rtv1alpha1.WithPingSourceV1A2SinkNotFound) +func makeFalseStatusPingSource() *sourcesv1beta1.PingSource { + return rtv1alpha1.NewPingSourceV1Beta1(pingSourceName, testNS, rtv1alpha1.WithPingSourceV1B1SinkNotFound) } -func makeUnknownStatusCronJobSource() *sourcesv1alpha2.PingSource { - cjs := rtv1alpha1.NewPingSourceV1Alpha2(pingSourceName, testNS) +func makeUnknownStatusCronJobSource() *sourcesv1beta1.PingSource { + cjs := rtv1alpha1.NewPingSourceV1Beta1(pingSourceName, testNS) cjs.Status.InitializeConditions() return cjs } -func makeGenerationNotEqualPingSource() *sourcesv1alpha2.PingSource { +func makeGenerationNotEqualPingSource() *sourcesv1beta1.PingSource { c := makeFalseStatusPingSource() c.Generation = currentGeneration c.Status.ObservedGeneration = outdatedGeneration return c } -func makeReadyPingSource() *sourcesv1alpha2.PingSource { +func makeReadyPingSource() *sourcesv1beta1.PingSource { u := apis.HTTP(sinkURI) - return rtv1alpha1.NewPingSourceV1Alpha2(pingSourceName, testNS, - rtv1alpha1.WithPingSourceV1A2Spec(sourcesv1alpha2.PingSourceSpec{ + return rtv1alpha1.NewPingSourceV1Beta1(pingSourceName, testNS, + rtv1alpha1.WithPingSourceV1B1Spec(sourcesv1beta1.PingSourceSpec{ Schedule: testSchedule, JsonData: testData, SourceSpec: duckv1.SourceSpec{ Sink: brokerDestv1, }, }), - rtv1alpha1.WithInitPingSourceV1A2Conditions, - rtv1alpha1.WithValidPingSourceV1A2Schedule, - rtv1alpha1.WithValidPingSourceV1A2Resources, - rtv1alpha1.WithPingSourceV1A2Deployed, - rtv1alpha1.WithPingSourceV1A2CloudEventAttributes, - rtv1alpha1.WithPingSourceV1A2Sink(u), + rtv1alpha1.WithInitPingSourceV1B1Conditions, + rtv1alpha1.WithPingSourceV1B1Deployed, + rtv1alpha1.WithPingSourceV1B1CloudEventAttributes, + rtv1alpha1.WithPingSourceV1B1Sink(u), ) } func makeSubscriberKubernetesServiceAsUnstructured() *unstructured.Unstructured { diff --git a/pkg/reconciler/mtbroker/trigger/trigger_test.go b/pkg/reconciler/mtbroker/trigger/trigger_test.go index b319ba51fd2..f904c486fe7 100644 --- a/pkg/reconciler/mtbroker/trigger/trigger_test.go +++ b/pkg/reconciler/mtbroker/trigger/trigger_test.go @@ -33,7 +33,7 @@ import ( "knative.dev/eventing/pkg/apis/eventing" eventingv1 "knative.dev/eventing/pkg/apis/eventing/v1" messagingv1 "knative.dev/eventing/pkg/apis/messaging/v1" - sourcesv1alpha2 "knative.dev/eventing/pkg/apis/sources/v1alpha2" + sourcesv1beta1 "knative.dev/eventing/pkg/apis/sources/v1beta1" fakeeventingclient "knative.dev/eventing/pkg/client/injection/client/fake" "knative.dev/eventing/pkg/client/injection/ducks/duck/v1/channelable" "knative.dev/eventing/pkg/client/injection/reconciler/eventing/v1/trigger" @@ -85,7 +85,7 @@ const ( testSchedule = "*/2 * * * *" testData = "data" sinkName = "testsink" - dependencyAnnotation = "{\"kind\":\"PingSource\",\"name\":\"test-ping-source\",\"apiVersion\":\"sources.knative.dev/v1alpha2\"}" + dependencyAnnotation = "{\"kind\":\"PingSource\",\"name\":\"test-ping-source\",\"apiVersion\":\"sources.knative.dev/v1beta1\"}" subscriberURIReference = "foo" subscriberResolvedTargetURI = "http://example.com/subscriber/foo" @@ -946,39 +946,37 @@ func makeFalseStatusSubscription() *messagingv1.Subscription { return s } -func makeFalseStatusPingSource() *sourcesv1alpha2.PingSource { - return rtv1alpha1.NewPingSourceV1Alpha2(pingSourceName, testNS, rtv1alpha1.WithPingSourceV1A2SinkNotFound) +func makeFalseStatusPingSource() *sourcesv1beta1.PingSource { + return rtv1alpha1.NewPingSourceV1Beta1(pingSourceName, testNS, rtv1alpha1.WithPingSourceV1B1SinkNotFound) } -func makeUnknownStatusCronJobSource() *sourcesv1alpha2.PingSource { - cjs := rtv1alpha1.NewPingSourceV1Alpha2(pingSourceName, testNS) +func makeUnknownStatusCronJobSource() *sourcesv1beta1.PingSource { + cjs := rtv1alpha1.NewPingSourceV1Beta1(pingSourceName, testNS) cjs.Status.InitializeConditions() return cjs } -func makeGenerationNotEqualPingSource() *sourcesv1alpha2.PingSource { +func makeGenerationNotEqualPingSource() *sourcesv1beta1.PingSource { c := makeFalseStatusPingSource() c.Generation = currentGeneration c.Status.ObservedGeneration = outdatedGeneration return c } -func makeReadyPingSource() *sourcesv1alpha2.PingSource { +func makeReadyPingSource() *sourcesv1beta1.PingSource { u, _ := apis.ParseURL(sinkURI) - return rtv1alpha1.NewPingSourceV1Alpha2(pingSourceName, testNS, - rtv1alpha1.WithPingSourceV1A2Spec(sourcesv1alpha2.PingSourceSpec{ + return rtv1alpha1.NewPingSourceV1Beta1(pingSourceName, testNS, + rtv1alpha1.WithPingSourceV1B1Spec(sourcesv1beta1.PingSourceSpec{ Schedule: testSchedule, JsonData: testData, SourceSpec: duckv1.SourceSpec{ Sink: brokerDestv1, }, }), - rtv1alpha1.WithInitPingSourceV1A2Conditions, - rtv1alpha1.WithValidPingSourceV1A2Schedule, - rtv1alpha1.WithValidPingSourceV1A2Resources, - rtv1alpha1.WithPingSourceV1A2Deployed, - rtv1alpha1.WithPingSourceV1A2CloudEventAttributes, - rtv1alpha1.WithPingSourceV1A2Sink(u), + rtv1alpha1.WithInitPingSourceV1B1Conditions, + rtv1alpha1.WithPingSourceV1B1Deployed, + rtv1alpha1.WithPingSourceV1B1CloudEventAttributes, + rtv1alpha1.WithPingSourceV1B1Sink(u), ) } func makeSubscriberKubernetesServiceAsUnstructured() *unstructured.Unstructured { diff --git a/pkg/reconciler/pingsource/controller.go b/pkg/reconciler/pingsource/controller.go index 1cfe2da6576..7b51f056f78 100644 --- a/pkg/reconciler/pingsource/controller.go +++ b/pkg/reconciler/pingsource/controller.go @@ -35,8 +35,8 @@ import ( "knative.dev/pkg/tracker" "knative.dev/eventing/pkg/adapter/v2" - pingsourceinformer "knative.dev/eventing/pkg/client/injection/informers/sources/v1alpha2/pingsource" - pingsourcereconciler "knative.dev/eventing/pkg/client/injection/reconciler/sources/v1alpha2/pingsource" + pingsourceinformer "knative.dev/eventing/pkg/client/injection/informers/sources/v1beta1/pingsource" + pingsourcereconciler "knative.dev/eventing/pkg/client/injection/reconciler/sources/v1beta1/pingsource" reconcilersource "knative.dev/eventing/pkg/reconciler/source" ) diff --git a/pkg/reconciler/pingsource/controller_test.go b/pkg/reconciler/pingsource/controller_test.go index 68691a713a8..6b30971477a 100644 --- a/pkg/reconciler/pingsource/controller_test.go +++ b/pkg/reconciler/pingsource/controller_test.go @@ -27,7 +27,7 @@ import ( // Fake injection informers _ "knative.dev/eventing/pkg/client/injection/informers/eventing/v1beta1/eventtype/fake" - _ "knative.dev/eventing/pkg/client/injection/informers/sources/v1alpha2/pingsource/fake" + _ "knative.dev/eventing/pkg/client/injection/informers/sources/v1beta1/pingsource/fake" _ "knative.dev/pkg/client/injection/ducks/duck/v1/addressable/fake" _ "knative.dev/pkg/client/injection/kube/informers/apps/v1/deployment/fake" _ "knative.dev/pkg/client/injection/kube/informers/core/v1/serviceaccount/fake" diff --git a/pkg/reconciler/pingsource/pingsource.go b/pkg/reconciler/pingsource/pingsource.go index 277e0ab1475..a60b871491a 100644 --- a/pkg/reconciler/pingsource/pingsource.go +++ b/pkg/reconciler/pingsource/pingsource.go @@ -39,9 +39,9 @@ import ( "knative.dev/pkg/tracker" "knative.dev/eventing/pkg/adapter/mtping" - "knative.dev/eventing/pkg/apis/sources/v1alpha2" - pingsourcereconciler "knative.dev/eventing/pkg/client/injection/reconciler/sources/v1alpha2/pingsource" - listers "knative.dev/eventing/pkg/client/listers/sources/v1alpha2" + "knative.dev/eventing/pkg/apis/sources/v1beta1" + pingsourcereconciler "knative.dev/eventing/pkg/client/injection/reconciler/sources/v1beta1/pingsource" + listers "knative.dev/eventing/pkg/client/listers/sources/v1beta1" "knative.dev/eventing/pkg/reconciler/pingsource/resources" reconcilersource "knative.dev/eventing/pkg/reconciler/source" ) @@ -84,7 +84,7 @@ type Reconciler struct { // Check that our Reconciler implements ReconcileKind var _ pingsourcereconciler.Interface = (*Reconciler)(nil) -func (r *Reconciler) ReconcileKind(ctx context.Context, source *v1alpha2.PingSource) pkgreconciler.Event { +func (r *Reconciler) ReconcileKind(ctx context.Context, source *v1beta1.PingSource) pkgreconciler.Event { // This Source attempts to reconcile three things. // 1. Determine the sink's URI. // - Nothing to delete. @@ -111,10 +111,6 @@ func (r *Reconciler) ReconcileKind(ctx context.Context, source *v1alpha2.PingSou } source.Status.MarkSink(sinkURI) - // The webhook does not allow for invalid schedules to be posted. - // TODO: remove MarkSchedule - source.Status.MarkSchedule() - // Make sure the global mt receive adapter is running d, err := r.reconcileReceiveAdapter(ctx, source) if err != nil { @@ -137,14 +133,14 @@ func (r *Reconciler) ReconcileKind(ctx context.Context, source *v1alpha2.PingSou } source.Status.CloudEventAttributes = []duckv1.CloudEventAttributes{{ - Type: v1alpha2.PingSourceEventType, - Source: v1alpha2.PingSourceSource(source.Namespace, source.Name), + Type: v1beta1.PingSourceEventType, + Source: v1beta1.PingSourceSource(source.Namespace, source.Name), }} return nil } -func (r *Reconciler) reconcileReceiveAdapter(ctx context.Context, source *v1alpha2.PingSource) (*appsv1.Deployment, error) { +func (r *Reconciler) reconcileReceiveAdapter(ctx context.Context, source *v1beta1.PingSource) (*appsv1.Deployment, error) { loggingConfig, err := logging.LoggingConfigToJson(r.configs.LoggingConfig()) if err != nil { logging.FromContext(ctx).Errorw("error while converting logging config to JSON", zap.Any("receiveAdapter", err)) diff --git a/pkg/reconciler/pingsource/pingsource_test.go b/pkg/reconciler/pingsource/pingsource_test.go index 83439ca8256..0f20a253569 100644 --- a/pkg/reconciler/pingsource/pingsource_test.go +++ b/pkg/reconciler/pingsource/pingsource_test.go @@ -28,9 +28,9 @@ import ( "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/kubernetes/scheme" clientgotesting "k8s.io/client-go/testing" - sourcesv1alpha2 "knative.dev/eventing/pkg/apis/sources/v1alpha2" + sourcesv1beta1 "knative.dev/eventing/pkg/apis/sources/v1beta1" fakeeventingclient "knative.dev/eventing/pkg/client/injection/client/fake" - "knative.dev/eventing/pkg/client/injection/reconciler/sources/v1alpha2/pingsource" + "knative.dev/eventing/pkg/client/injection/reconciler/sources/v1beta1/pingsource" "knative.dev/eventing/pkg/reconciler/pingsource/resources" "knative.dev/eventing/pkg/utils" "knative.dev/pkg/apis" @@ -102,34 +102,34 @@ func TestAllCases(t *testing.T) { }, { Name: "missing sink", Objects: []runtime.Object{ - NewPingSourceV1Alpha2(sourceName, testNS, - WithPingSourceV1A2Spec(sourcesv1alpha2.PingSourceSpec{ + NewPingSourceV1Beta1(sourceName, testNS, + WithPingSourceV1B1Spec(sourcesv1beta1.PingSourceSpec{ Schedule: testSchedule, JsonData: testData, SourceSpec: duckv1.SourceSpec{ Sink: sinkDest, }, }), - WithPingSourceV1A2UID(sourceUID), - WithPingSourceV1A2ObjectMetaGeneration(generation), + WithPingSourceV1B1UID(sourceUID), + WithPingSourceV1B1ObjectMetaGeneration(generation), ), }, Key: testNS + "/" + sourceName, WantStatusUpdates: []clientgotesting.UpdateActionImpl{{ - Object: NewPingSourceV1Alpha2(sourceName, testNS, - WithPingSourceV1A2Spec(sourcesv1alpha2.PingSourceSpec{ + Object: NewPingSourceV1Beta1(sourceName, testNS, + WithPingSourceV1B1Spec(sourcesv1beta1.PingSourceSpec{ Schedule: testSchedule, JsonData: testData, SourceSpec: duckv1.SourceSpec{ Sink: sinkDest, }, }), - WithPingSourceV1A2UID(sourceUID), - WithPingSourceV1A2ObjectMetaGeneration(generation), + WithPingSourceV1B1UID(sourceUID), + WithPingSourceV1B1ObjectMetaGeneration(generation), // Status Update: - WithInitPingSourceV1A2Conditions, - WithPingSourceV1A2StatusObservedGeneration(generation), - WithPingSourceV1A2SinkNotFound, + WithInitPingSourceV1B1Conditions, + WithPingSourceV1B1StatusObservedGeneration(generation), + WithPingSourceV1B1SinkNotFound, ), }}, WantEvents: []string{ @@ -139,16 +139,16 @@ func TestAllCases(t *testing.T) { }, { Name: "valid", Objects: []runtime.Object{ - NewPingSourceV1Alpha2(sourceName, testNS, - WithPingSourceV1A2Spec(sourcesv1alpha2.PingSourceSpec{ + NewPingSourceV1Beta1(sourceName, testNS, + WithPingSourceV1B1Spec(sourcesv1beta1.PingSourceSpec{ Schedule: testSchedule, JsonData: testData, SourceSpec: duckv1.SourceSpec{ Sink: sinkDest, }, }), - WithPingSourceV1A2UID(sourceUID), - WithPingSourceV1A2ObjectMetaGeneration(generation), + WithPingSourceV1B1UID(sourceUID), + WithPingSourceV1B1ObjectMetaGeneration(generation), ), rtv1beta1.NewChannel(sinkName, testNS, rtv1beta1.WithInitChannelConditions, @@ -158,40 +158,38 @@ func TestAllCases(t *testing.T) { }, Key: testNS + "/" + sourceName, WantStatusUpdates: []clientgotesting.UpdateActionImpl{{ - Object: NewPingSourceV1Alpha2(sourceName, testNS, - WithPingSourceV1A2Spec(sourcesv1alpha2.PingSourceSpec{ + Object: NewPingSourceV1Beta1(sourceName, testNS, + WithPingSourceV1B1Spec(sourcesv1beta1.PingSourceSpec{ Schedule: testSchedule, JsonData: testData, SourceSpec: duckv1.SourceSpec{ Sink: sinkDest, }, }), - WithPingSourceV1A2UID(sourceUID), - WithPingSourceV1A2ObjectMetaGeneration(generation), + WithPingSourceV1B1UID(sourceUID), + WithPingSourceV1B1ObjectMetaGeneration(generation), // Status Update: - WithInitPingSourceV1A2Conditions, - WithValidPingSourceV1A2Schedule, - - WithPingSourceV1A2Deployed, - WithPingSourceV1A2Sink(sinkURI), - WithPingSourceV1A2CloudEventAttributes, - WithPingSourceV1A2StatusObservedGeneration(generation), + WithInitPingSourceV1B1Conditions, + WithPingSourceV1B1Deployed, + WithPingSourceV1B1Sink(sinkURI), + WithPingSourceV1B1CloudEventAttributes, + WithPingSourceV1B1StatusObservedGeneration(generation), ), }}, }, { Name: "valid with cluster scope annotation, create deployment", SkipNamespaceValidation: true, Objects: []runtime.Object{ - NewPingSourceV1Alpha2(sourceName, testNS, - WithPingSourceV1A2Spec(sourcesv1alpha2.PingSourceSpec{ + NewPingSourceV1Beta1(sourceName, testNS, + WithPingSourceV1B1Spec(sourcesv1beta1.PingSourceSpec{ Schedule: testSchedule, JsonData: testData, SourceSpec: duckv1.SourceSpec{ Sink: sinkDest, }, }), - WithPingSourceV1A2UID(sourceUID), - WithPingSourceV1A2ObjectMetaGeneration(generation), + WithPingSourceV1B1UID(sourceUID), + WithPingSourceV1B1ObjectMetaGeneration(generation), ), rtv1beta1.NewChannel(sinkName, testNS, rtv1beta1.WithInitChannelConditions, @@ -206,23 +204,22 @@ func TestAllCases(t *testing.T) { MakeMTAdapter(), }, WantStatusUpdates: []clientgotesting.UpdateActionImpl{{ - Object: NewPingSourceV1Alpha2(sourceName, testNS, - WithPingSourceV1A2Spec(sourcesv1alpha2.PingSourceSpec{ + Object: NewPingSourceV1Beta1(sourceName, testNS, + WithPingSourceV1B1Spec(sourcesv1beta1.PingSourceSpec{ Schedule: testSchedule, JsonData: testData, SourceSpec: duckv1.SourceSpec{ Sink: sinkDest, }, }), - WithPingSourceV1A2UID(sourceUID), - WithPingSourceV1A2ObjectMetaGeneration(generation), + WithPingSourceV1B1UID(sourceUID), + WithPingSourceV1B1ObjectMetaGeneration(generation), // Status Update: - WithPingSourceV1A2NotDeployed(mtadapterName), - WithInitPingSourceV1A2Conditions, - WithValidPingSourceV1A2Schedule, - WithPingSourceV1A2CloudEventAttributes, - WithPingSourceV1A2Sink(sinkURI), - WithPingSourceV1A2StatusObservedGeneration(generation), + WithPingSourceV1B1NotDeployed(mtadapterName), + WithInitPingSourceV1B1Conditions, + WithPingSourceV1B1CloudEventAttributes, + WithPingSourceV1B1Sink(sinkURI), + WithPingSourceV1B1StatusObservedGeneration(generation), ), }}, }, @@ -233,7 +230,7 @@ func TestAllCases(t *testing.T) { ctx = addressable.WithDuck(ctx) r := &Reconciler{ kubeClientSet: fakekubeclient.Get(ctx), - pingLister: listers.GetPingSourceV1alpha2Lister(), + pingLister: listers.GetPingSourceV1beta1Lister(), deploymentLister: listers.GetDeploymentLister(), tracker: tracker.New(func(types.NamespacedName) {}, 0), receiveAdapterImage: mtimage, @@ -241,7 +238,7 @@ func TestAllCases(t *testing.T) { r.sinkResolver = resolver.NewURIResolver(ctx, func(types.NamespacedName) {}) return pingsource.NewReconciler(ctx, logging.FromContext(ctx), - fakeeventingclient.Get(ctx), listers.GetPingSourceV1alpha2Lister(), + fakeeventingclient.Get(ctx), listers.GetPingSourceV1beta1Lister(), controller.GetEventRecorder(ctx), r) }, true, diff --git a/pkg/reconciler/resources/service_account_test.go b/pkg/reconciler/resources/service_account_test.go index a9c13ef3d12..dea87165f91 100644 --- a/pkg/reconciler/resources/service_account_test.go +++ b/pkg/reconciler/resources/service_account_test.go @@ -24,13 +24,13 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "knative.dev/pkg/kmeta" - "knative.dev/eventing/pkg/apis/sources/v1alpha2" + "knative.dev/eventing/pkg/apis/sources/v1beta1" ) func TestNewServiceAccount(t *testing.T) { testNS := "test-ns" testName := "test-name" - obj := &v1alpha2.PingSource{ + obj := &v1beta1.PingSource{ ObjectMeta: metav1.ObjectMeta{ Name: testName, Namespace: testNS, diff --git a/pkg/reconciler/testing/listers.go b/pkg/reconciler/testing/listers.go index 22822b57342..ca24f2dc589 100644 --- a/pkg/reconciler/testing/listers.go +++ b/pkg/reconciler/testing/listers.go @@ -164,8 +164,8 @@ func (l *Listers) GetSinkBindingLister() sourcelisters.SinkBindingLister { return sourcelisters.NewSinkBindingLister(l.indexerFor(&sourcesv1alpha1.SinkBinding{})) } -func (l *Listers) GetPingSourceV1alpha2Lister() sourcev1alpha2listers.PingSourceLister { - return sourcev1alpha2listers.NewPingSourceLister(l.indexerFor(&sourcesv1alpha2.PingSource{})) +func (l *Listers) GetPingSourceV1beta1Lister() sourcev1beta1listers.PingSourceLister { + return sourcev1beta1listers.NewPingSourceLister(l.indexerFor(&sourcesv1beta1.PingSource{})) } func (l *Listers) GetContainerSourceV1alpha2Lister() sourcev1alpha2listers.ContainerSourceLister { diff --git a/pkg/reconciler/testing/pingsource.go b/pkg/reconciler/testing/pingsource.go index 5e235370d59..dec22bf5c10 100644 --- a/pkg/reconciler/testing/pingsource.go +++ b/pkg/reconciler/testing/pingsource.go @@ -116,12 +116,6 @@ func WithPingSourceV1A2Spec(spec v1alpha2.PingSourceSpec) PingSourceV1A2Option { } } -func WithPingSourceV1B1Spec(spec v1beta1.PingSourceSpec) PingSourceV1B1Option { - return func(c *v1beta1.PingSource) { - c.Spec = spec - } -} - func WithPingSourceV1A2StatusObservedGeneration(generation int64) PingSourceV1A2Option { return func(c *v1alpha2.PingSource) { c.Status.ObservedGeneration = generation @@ -144,3 +138,69 @@ func WithPingSourceV1A2Deleted(c *v1alpha2.PingSource) { t := metav1.NewTime(time.Unix(1e9, 0)) c.SetDeletionTimestamp(&t) } + +func WithPingSourceV1B1UID(uid string) PingSourceV1B1Option { + return func(c *v1beta1.PingSource) { + c.UID = types.UID(uid) + } +} + +func WithInitPingSourceV1B1Conditions(s *v1beta1.PingSource) { + s.Status.InitializeConditions() +} + +func WithPingSourceV1B1SinkNotFound(s *v1beta1.PingSource) { + s.Status.MarkNoSink("NotFound", "") +} + +func WithPingSourceV1B1Sink(uri *apis.URL) PingSourceV1B1Option { + return func(s *v1beta1.PingSource) { + s.Status.MarkSink(uri) + } +} + +func WithPingSourceV1B1NotDeployed(name string) PingSourceV1B1Option { + return func(s *v1beta1.PingSource) { + s.Status.PropagateDeploymentAvailability(NewDeployment(name, "any")) + } +} + +func WithPingSourceV1B1Deployed(s *v1beta1.PingSource) { + s.Status.PropagateDeploymentAvailability(NewDeployment("any", "any", WithDeploymentAvailable())) +} + +func WithPingSourceV1B1CloudEventAttributes(s *v1beta1.PingSource) { + s.Status.CloudEventAttributes = []duckv1.CloudEventAttributes{{ + Type: v1beta1.PingSourceEventType, + Source: v1beta1.PingSourceSource(s.Namespace, s.Name), + }} +} + +func WithPingSourceV1B1Spec(spec v1beta1.PingSourceSpec) PingSourceV1B1Option { + return func(c *v1beta1.PingSource) { + c.Spec = spec + } +} + +func WithPingSourceV1B1StatusObservedGeneration(generation int64) PingSourceV1B1Option { + return func(c *v1beta1.PingSource) { + c.Status.ObservedGeneration = generation + } +} + +func WithPingSourceV1B1ObjectMetaGeneration(generation int64) PingSourceV1B1Option { + return func(c *v1beta1.PingSource) { + c.ObjectMeta.Generation = generation + } +} + +func WithPingSourceV1B1Finalizers(finalizers ...string) PingSourceV1B1Option { + return func(c *v1beta1.PingSource) { + c.Finalizers = finalizers + } +} + +func WithPingSourceV1B1Deleted(c *v1beta1.PingSource) { + t := metav1.NewTime(time.Unix(1e9, 0)) + c.SetDeletionTimestamp(&t) +} diff --git a/pkg/reconciler/testing/v1beta1/listers.go b/pkg/reconciler/testing/v1beta1/listers.go index 9c046b0df24..da0b0cea48d 100644 --- a/pkg/reconciler/testing/v1beta1/listers.go +++ b/pkg/reconciler/testing/v1beta1/listers.go @@ -162,8 +162,8 @@ func (l *Listers) GetSinkBindingLister() sourcelisters.SinkBindingLister { return sourcelisters.NewSinkBindingLister(l.indexerFor(&sourcesv1alpha1.SinkBinding{})) } -func (l *Listers) GetPingSourceV1alpha2Lister() sourcev1alpha2listers.PingSourceLister { - return sourcev1alpha2listers.NewPingSourceLister(l.indexerFor(&sourcesv1alpha2.PingSource{})) +func (l *Listers) GetPingSourceV1beta1Lister() sourcev1beta1listers.PingSourceLister { + return sourcev1beta1listers.NewPingSourceLister(l.indexerFor(&sourcesv1beta1.PingSource{})) } func (l *Listers) GetContainerSourceLister() sourcev1alpha2listers.ContainerSourceLister { diff --git a/test/conformance/main_test.go b/test/conformance/main_test.go index ffe913d02bc..b1880801ab9 100644 --- a/test/conformance/main_test.go +++ b/test/conformance/main_test.go @@ -86,7 +86,7 @@ func addSourcesInitializers() { ) sourcesTestRunner.AddComponentSetupClientOption( testlib.PingSourceTypeMeta, - setupclientoptions.PingSourceV1A2ClientSetupOption(pingSrcName, + setupclientoptions.PingSourceV1B1ClientSetupOption(pingSrcName, recordEventsPingPodName), ) } diff --git a/test/e2e-conformance-tests.sh b/test/e2e-conformance-tests.sh index 92fe9c0a4b6..13bba73cebd 100755 --- a/test/e2e-conformance-tests.sh +++ b/test/e2e-conformance-tests.sh @@ -33,6 +33,6 @@ source "$(dirname "$0")/e2e-common.sh" initialize $@ --skip-istio-addon echo "Running tests with Multi Tenant Channel Based Broker" -go_test_e2e -timeout=30m -parallel=12 ./test/conformance -brokers=eventing.knative.dev/v1beta1:MTChannelBasedBroker -channels=messaging.knative.dev/v1beta1:Channel,messaging.knative.dev/v1beta1:InMemoryChannel,messaging.knative.dev/v1:Channel,messaging.knative.dev/v1:InMemoryChannel -sources=sources.knative.dev/v1beta1:ApiServerSource,sources.knative.dev/v1alpha2:ContainerSource,sources.knative.dev/v1alpha2:PingSource || fail_test +go_test_e2e -timeout=30m -parallel=12 ./test/conformance -brokers=eventing.knative.dev/v1beta1:MTChannelBasedBroker -channels=messaging.knative.dev/v1beta1:Channel,messaging.knative.dev/v1beta1:InMemoryChannel,messaging.knative.dev/v1:Channel,messaging.knative.dev/v1:InMemoryChannel -sources=sources.knative.dev/v1beta1:ApiServerSource,sources.knative.dev/v1alpha2:ContainerSource,sources.knative.dev/v1beta1:PingSource || fail_test success diff --git a/test/e2e/trigger_dependency_annotation_test.go b/test/e2e/trigger_dependency_annotation_test.go index efc65faa1f2..7fa76d7ae5c 100644 --- a/test/e2e/trigger_dependency_annotation_test.go +++ b/test/e2e/trigger_dependency_annotation_test.go @@ -30,7 +30,7 @@ import ( "knative.dev/pkg/apis" "knative.dev/eventing/pkg/apis/eventing" - sourcesv1alpha2 "knative.dev/eventing/pkg/apis/sources/v1alpha2" + sourcesv1beta1 "knative.dev/eventing/pkg/apis/sources/v1beta1" sugarresources "knative.dev/eventing/pkg/reconciler/sugar/resources" eventingtesting "knative.dev/eventing/pkg/reconciler/testing" testlib "knative.dev/eventing/test/lib" @@ -47,7 +47,7 @@ func TestTriggerDependencyAnnotation(t *testing.T) { defaultBrokerName = sugarresources.DefaultBrokerName triggerName = "trigger-annotation" subscriberName = "subscriber-annotation" - dependencyAnnotation = `{"kind":"PingSource","name":"test-ping-source-annotation","apiVersion":"sources.knative.dev/v1alpha2"}` + dependencyAnnotation = `{"kind":"PingSource","name":"test-ping-source-annotation","apiVersion":"sources.knative.dev/v1beta1"}` pingSourceName = "test-ping-source-annotation" // Every 1 minute starting from now schedule = "*/1 * * * *" @@ -74,10 +74,10 @@ func TestTriggerDependencyAnnotation(t *testing.T) { ) jsonData := fmt.Sprintf(`{"msg":"Test trigger-annotation %s"}`, uuid.NewUUID()) - pingSource := eventingtesting.NewPingSourceV1Alpha2( + pingSource := eventingtesting.NewPingSourceV1Beta1( pingSourceName, client.Namespace, - eventingtesting.WithPingSourceV1A2Spec(sourcesv1alpha2.PingSourceSpec{ + eventingtesting.WithPingSourceV1B1Spec(sourcesv1beta1.PingSourceSpec{ Schedule: schedule, JsonData: jsonData, SourceSpec: duckv1.SourceSpec{ @@ -93,13 +93,13 @@ func TestTriggerDependencyAnnotation(t *testing.T) { } } - client.CreatePingSourceV1Alpha2OrFail(pingSource) + client.CreatePingSourceV1Beta1OrFail(pingSource) // Trigger should become ready after pingSource was created client.WaitForResourceReadyOrFail(triggerName, testlib.TriggerTypeMeta) eventTracker.AssertAtLeast(1, recordevents.MatchEvent( - HasSource(sourcesv1alpha2.PingSourceSource(client.Namespace, pingSourceName)), + HasSource(sourcesv1beta1.PingSourceSource(client.Namespace, pingSourceName)), HasData([]byte(jsonData)), )) } diff --git a/test/lib/setupclientoptions/sources.go b/test/lib/setupclientoptions/sources.go index f5ab1246a12..3f271af1a1e 100644 --- a/test/lib/setupclientoptions/sources.go +++ b/test/lib/setupclientoptions/sources.go @@ -22,7 +22,6 @@ import ( rbacv1 "k8s.io/api/rbac/v1" "k8s.io/apimachinery/pkg/util/uuid" - sourcesv1alpha2 "knative.dev/eventing/pkg/apis/sources/v1alpha2" sourcesv1beta1 "knative.dev/eventing/pkg/apis/sources/v1beta1" eventingtesting "knative.dev/eventing/pkg/reconciler/testing" testlib "knative.dev/eventing/test/lib" @@ -68,10 +67,10 @@ func ApiServerSourceV1B1ClientSetupOption(name string, mode string, recordEvents } } -// PingSourceV1A2ClientSetupOption returns a ClientSetupOption that can be used +// PingSourceV1B1ClientSetupOption returns a ClientSetupOption that can be used // to create a new PingSource. It creates a RecordEvents pod and a // PingSource object with the RecordEvent pod as its sink. -func PingSourceV1A2ClientSetupOption(name string, recordEventsPodName string) testlib.SetupClientOption { +func PingSourceV1B1ClientSetupOption(name string, recordEventsPodName string) testlib.SetupClientOption { return func(client *testlib.Client) { // create event logger pod and service @@ -79,10 +78,10 @@ func PingSourceV1A2ClientSetupOption(name string, recordEventsPodName string) te // create cron job source data := fmt.Sprintf(`{"msg":"TestPingSource %s"}`, uuid.NewUUID()) - source := eventingtesting.NewPingSourceV1Alpha2( + source := eventingtesting.NewPingSourceV1Beta1( name, client.Namespace, - eventingtesting.WithPingSourceV1A2Spec(sourcesv1alpha2.PingSourceSpec{ + eventingtesting.WithPingSourceV1B1Spec(sourcesv1beta1.PingSourceSpec{ JsonData: data, SourceSpec: duckv1.SourceSpec{ Sink: duckv1.Destination{ @@ -91,7 +90,7 @@ func PingSourceV1A2ClientSetupOption(name string, recordEventsPodName string) te }, }), ) - client.CreatePingSourceV1Alpha2OrFail(source) + client.CreatePingSourceV1Beta1OrFail(source) // wait for all test resources to be ready client.WaitForAllTestResourcesReadyOrFail()