Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions config/core/resources/pingsource.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ spec:
- &version
name: v1alpha2
served: true
storage: true
storage: false
subresources:
status: {}
schema:
Expand Down Expand Up @@ -182,7 +182,7 @@ spec:
- <<: *version
name: v1beta1
served: true
storage: false
storage: true
schema:
openAPIV3Schema:
type: object
Expand Down
1 change: 1 addition & 0 deletions config/pre-install/v0.18.0/clusterrole.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ rules:
resources:
- "containersources"
- "sinkbindings"
- "pingsources"
verbs: &everything
- "get"
- "list"
Expand Down
337 changes: 337 additions & 0 deletions config/pre-install/v0.18.0/pingsource.yaml

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions config/pre-install/v0.18.0/storage-version-migration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,4 @@ spec:
- "subscriptions.messaging.knative.dev"
- "parallels.flows.knative.dev"
- "sequences.flows.knative.dev"
- "pingsources.sources.knative.dev"
Comment thread
aavarghese marked this conversation as resolved.
4 changes: 2 additions & 2 deletions pkg/adapter/mtping/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
16 changes: 8 additions & 8 deletions pkg/adapter/mtping/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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{
Expand All @@ -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"},
},
Expand Down
4 changes: 2 additions & 2 deletions pkg/adapter/mtping/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion pkg/adapter/mtping/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
12 changes: 6 additions & 6 deletions pkg/adapter/mtping/pingsource.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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()
Expand Down
70 changes: 33 additions & 37 deletions pkg/adapter/mtping/pingsource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -75,20 +75,19 @@ 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{
Sink: sinkDest,
CloudEventOverrides: nil,
},
}),
WithInitPingSourceV1A2Conditions,
WithValidPingSourceV1A2Schedule,
WithPingSourceV1A2Deployed,
WithPingSourceV1A2Sink(sinkURI),
WithPingSourceV1A2CloudEventAttributes,
WithInitPingSourceV1B1Conditions,
WithPingSourceV1B1Deployed,
WithPingSourceV1B1Sink(sinkURI),
WithPingSourceV1B1CloudEventAttributes,
),
},
WantEvents: []string{
Expand All @@ -102,44 +101,42 @@ 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{
Sink: sinkDest,
CloudEventOverrides: nil,
},
}),
WithInitPingSourceV1A2Conditions,
WithValidPingSourceV1A2Schedule,
WithPingSourceV1A2Deployed,
WithPingSourceV1A2Sink(sinkURI),
WithPingSourceV1A2CloudEventAttributes,
WithPingSourceV1A2Finalizers(defaultFinalizerName),
WithInitPingSourceV1B1Conditions,
WithPingSourceV1B1Deployed,
WithPingSourceV1B1Sink(sinkURI),
WithPingSourceV1B1CloudEventAttributes,
WithPingSourceV1B1Finalizers(defaultFinalizerName),
),
},
WantErr: false,
}, {
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{
Sink: sinkDest,
CloudEventOverrides: nil,
},
}),
WithInitPingSourceV1A2Conditions,
WithValidPingSourceV1A2Schedule,
WithPingSourceV1A2Deployed,
WithPingSourceV1A2Sink(sinkURI),
WithPingSourceV1A2CloudEventAttributes,
WithPingSourceV1A2Finalizers(defaultFinalizerName),
WithPingSourceV1A2Deleted,
WithInitPingSourceV1B1Conditions,
WithPingSourceV1B1Deployed,
WithPingSourceV1B1Sink(sinkURI),
WithPingSourceV1B1CloudEventAttributes,
WithPingSourceV1B1Finalizers(defaultFinalizerName),
WithPingSourceV1B1Deleted,
),
},
WantEvents: []string{
Expand All @@ -153,21 +150,20 @@ 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{
Sink: sinkDest,
CloudEventOverrides: nil,
},
}),
WithInitPingSourceV1A2Conditions,
WithValidPingSourceV1A2Schedule,
WithPingSourceV1A2Deployed,
WithPingSourceV1A2Sink(sinkURI),
WithPingSourceV1A2CloudEventAttributes,
WithPingSourceV1A2Deleted,
WithInitPingSourceV1B1Conditions,
WithPingSourceV1B1Deployed,
WithPingSourceV1B1Sink(sinkURI),
WithPingSourceV1B1CloudEventAttributes,
WithPingSourceV1B1Deleted,
),
},
WantErr: false,
Expand All @@ -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))

Expand All @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions pkg/adapter/mtping/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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?
Expand Down
Loading