Skip to content
This repository was archived by the owner on Jun 4, 2021. It is now read-only.

Commit 12d8580

Browse files
committed
Did some work, will do the rest after knative/eventing#3702 is done
1 parent 5b4e7dd commit 12d8580

File tree

12 files changed

+76
-91
lines changed

12 files changed

+76
-91
lines changed

kafka/channel/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ topics.
4242
1. Create the `KafkaChannel` custom objects:
4343

4444
```yaml
45-
apiVersion: messaging.knative.dev/v1alpha1
45+
apiVersion: messaging.knative.dev/v1beta1
4646
kind: KafkaChannel
4747
metadata:
4848
name: my-kafka-channel
@@ -119,7 +119,7 @@ data:
119119
Then create a KafkaChannel:
120120

121121
```yaml
122-
apiVersion: messaging.knative.dev/v1alpha1
122+
apiVersion: messaging.knative.dev/v1beta1
123123
kind: KafkaChannel
124124
metadata:
125125
name: my-kafka-channel

kafka/channel/pkg/dispatcher/dispatcher.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import (
3030
"go.opencensus.io/trace"
3131
"go.uber.org/zap"
3232
"k8s.io/apimachinery/pkg/types"
33-
eventingduck "knative.dev/eventing/pkg/apis/duck/v1beta1"
33+
eventingduck "knative.dev/eventing/pkg/apis/duck/v1"
3434
eventingchannels "knative.dev/eventing/pkg/channel"
3535
"knative.dev/eventing/pkg/channel/multichannelfanout"
3636
"knative.dev/eventing/pkg/kncloudevents"

kafka/channel/pkg/dispatcher/dispatcher_it_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import (
3131
protocolhttp "github.com/cloudevents/sdk-go/v2/protocol/http"
3232
"github.com/cloudevents/sdk-go/v2/test"
3333
"go.uber.org/zap"
34-
eventingduck "knative.dev/eventing/pkg/apis/duck/v1beta1"
34+
eventingduck "knative.dev/eventing/pkg/apis/duck/v1"
3535
"knative.dev/eventing/pkg/channel/fanout"
3636
"knative.dev/eventing/pkg/channel/multichannelfanout"
3737
"knative.dev/eventing/pkg/kncloudevents"

kafka/channel/pkg/dispatcher/dispatcher_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import (
3333
"go.uber.org/zap"
3434
"k8s.io/apimachinery/pkg/util/sets"
3535

36-
eventingduck "knative.dev/eventing/pkg/apis/duck/v1beta1"
36+
eventingduck "knative.dev/eventing/pkg/apis/duck/v1"
3737
eventingchannels "knative.dev/eventing/pkg/channel"
3838
"knative.dev/eventing/pkg/channel/fanout"
3939
"knative.dev/eventing/pkg/channel/multichannelfanout"

kafka/channel/pkg/reconciler/controller/controller.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ import (
4040
"knative.dev/pkg/system"
4141

4242
kafkaChannelClient "knative.dev/eventing-contrib/kafka/channel/pkg/client/injection/client"
43-
"knative.dev/eventing-contrib/kafka/channel/pkg/client/injection/informers/messaging/v1alpha1/kafkachannel"
44-
kafkaChannelReconciler "knative.dev/eventing-contrib/kafka/channel/pkg/client/injection/reconciler/messaging/v1alpha1/kafkachannel"
43+
"knative.dev/eventing-contrib/kafka/channel/pkg/client/injection/informers/messaging/v1beta1/kafkachannel"
44+
kafkaChannelReconciler "knative.dev/eventing-contrib/kafka/channel/pkg/client/injection/reconciler/messaging/v1beta1/kafkachannel"
4545
eventingClient "knative.dev/eventing/pkg/client/injection/client"
4646
)
4747

kafka/channel/pkg/reconciler/controller/kafkachannel.go

+13-13
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ import (
4848
"knative.dev/pkg/controller"
4949
pkgreconciler "knative.dev/pkg/reconciler"
5050

51-
"knative.dev/eventing-contrib/kafka/channel/pkg/apis/messaging/v1alpha1"
51+
"knative.dev/eventing-contrib/kafka/channel/pkg/apis/messaging/v1beta1"
5252
kafkaclientset "knative.dev/eventing-contrib/kafka/channel/pkg/client/clientset/versioned"
5353
kafkaScheme "knative.dev/eventing-contrib/kafka/channel/pkg/client/clientset/versioned/scheme"
54-
kafkaChannelReconciler "knative.dev/eventing-contrib/kafka/channel/pkg/client/injection/reconciler/messaging/v1alpha1/kafkachannel"
55-
listers "knative.dev/eventing-contrib/kafka/channel/pkg/client/listers/messaging/v1alpha1"
54+
kafkaChannelReconciler "knative.dev/eventing-contrib/kafka/channel/pkg/client/injection/reconciler/messaging/v1beta1/kafkachannel"
55+
listers "knative.dev/eventing-contrib/kafka/channel/pkg/client/listers/messaging/v1beta1"
5656
"knative.dev/eventing-contrib/kafka/channel/pkg/reconciler/controller/resources"
5757
"knative.dev/eventing-contrib/kafka/channel/pkg/utils"
5858
)
@@ -139,7 +139,7 @@ type envConfig struct {
139139
var _ kafkaChannelReconciler.Interface = (*Reconciler)(nil)
140140
var _ kafkaChannelReconciler.Finalizer = (*Reconciler)(nil)
141141

142-
func (r *Reconciler) ReconcileKind(ctx context.Context, kc *v1alpha1.KafkaChannel) pkgreconciler.Event {
142+
func (r *Reconciler) ReconcileKind(ctx context.Context, kc *v1beta1.KafkaChannel) pkgreconciler.Event {
143143
kc.Status.InitializeConditions()
144144

145145
logger := logging.FromContext(ctx)
@@ -247,7 +247,7 @@ func (r *Reconciler) ReconcileKind(ctx context.Context, kc *v1alpha1.KafkaChanne
247247
return newReconciledNormal(kc.Namespace, kc.Name)
248248
}
249249

250-
func (r *Reconciler) reconcileDispatcher(ctx context.Context, scope string, dispatcherNamespace string, kc *v1alpha1.KafkaChannel) (*appsv1.Deployment, error) {
250+
func (r *Reconciler) reconcileDispatcher(ctx context.Context, scope string, dispatcherNamespace string, kc *v1beta1.KafkaChannel) (*appsv1.Deployment, error) {
251251
if scope == scopeNamespace {
252252
// Configure RBAC in namespace to access the configmaps
253253
sa, err := r.reconcileServiceAccount(ctx, dispatcherNamespace, kc)
@@ -311,7 +311,7 @@ func (r *Reconciler) reconcileDispatcher(ctx context.Context, scope string, disp
311311
return d, nil
312312
}
313313

314-
func (r *Reconciler) reconcileServiceAccount(ctx context.Context, dispatcherNamespace string, kc *v1alpha1.KafkaChannel) (*corev1.ServiceAccount, error) {
314+
func (r *Reconciler) reconcileServiceAccount(ctx context.Context, dispatcherNamespace string, kc *v1beta1.KafkaChannel) (*corev1.ServiceAccount, error) {
315315
sa, err := r.serviceAccountLister.ServiceAccounts(dispatcherNamespace).Get(dispatcherName)
316316
if err != nil {
317317
if apierrs.IsNotFound(err) {
@@ -332,7 +332,7 @@ func (r *Reconciler) reconcileServiceAccount(ctx context.Context, dispatcherName
332332
return sa, err
333333
}
334334

335-
func (r *Reconciler) reconcileRoleBinding(ctx context.Context, name string, ns string, kc *v1alpha1.KafkaChannel, clusterRoleName string, sa *corev1.ServiceAccount) (*rbacv1.RoleBinding, error) {
335+
func (r *Reconciler) reconcileRoleBinding(ctx context.Context, name string, ns string, kc *v1beta1.KafkaChannel, clusterRoleName string, sa *corev1.ServiceAccount) (*rbacv1.RoleBinding, error) {
336336
rb, err := r.roleBindingLister.RoleBindings(ns).Get(name)
337337
if err != nil {
338338
if apierrs.IsNotFound(err) {
@@ -352,7 +352,7 @@ func (r *Reconciler) reconcileRoleBinding(ctx context.Context, name string, ns s
352352
return rb, err
353353
}
354354

355-
func (r *Reconciler) reconcileDispatcherService(ctx context.Context, dispatcherNamespace string, kc *v1alpha1.KafkaChannel) (*corev1.Service, error) {
355+
func (r *Reconciler) reconcileDispatcherService(ctx context.Context, dispatcherNamespace string, kc *v1beta1.KafkaChannel) (*corev1.Service, error) {
356356
svc, err := r.serviceLister.Services(dispatcherNamespace).Get(dispatcherName)
357357
if err != nil {
358358
if apierrs.IsNotFound(err) {
@@ -380,7 +380,7 @@ func (r *Reconciler) reconcileDispatcherService(ctx context.Context, dispatcherN
380380
return svc, nil
381381
}
382382

383-
func (r *Reconciler) reconcileChannelService(ctx context.Context, dispatcherNamespace string, channel *v1alpha1.KafkaChannel) (*corev1.Service, error) {
383+
func (r *Reconciler) reconcileChannelService(ctx context.Context, dispatcherNamespace string, channel *v1beta1.KafkaChannel) (*corev1.Service, error) {
384384
logger := logging.FromContext(ctx)
385385
// Get the Service and propagate the status to the Channel in case it does not exist.
386386
// We don't do anything with the service because it's status contains nothing useful, so just do
@@ -425,7 +425,7 @@ func (r *Reconciler) reconcileChannelService(ctx context.Context, dispatcherName
425425
return svc, nil
426426
}
427427

428-
func (r *Reconciler) createClient(ctx context.Context, kc *v1alpha1.KafkaChannel) (sarama.ClusterAdmin, error) {
428+
func (r *Reconciler) createClient(ctx context.Context, kc *v1beta1.KafkaChannel) (sarama.ClusterAdmin, error) {
429429
// We don't currently initialize r.kafkaClusterAdmin, hence we end up creating the cluster admin client every time.
430430
// This is because of an issue with Shopify/sarama. See https://github.com/Shopify/sarama/issues/1162.
431431
// Once the issue is fixed we should use a shared cluster admin client. Also, r.kafkaClusterAdmin is currently
@@ -441,7 +441,7 @@ func (r *Reconciler) createClient(ctx context.Context, kc *v1alpha1.KafkaChannel
441441
return kafkaClusterAdmin, nil
442442
}
443443

444-
func (r *Reconciler) createTopic(ctx context.Context, channel *v1alpha1.KafkaChannel, kafkaClusterAdmin sarama.ClusterAdmin) error {
444+
func (r *Reconciler) createTopic(ctx context.Context, channel *v1beta1.KafkaChannel, kafkaClusterAdmin sarama.ClusterAdmin) error {
445445
logger := logging.FromContext(ctx)
446446

447447
topicName := utils.TopicName(utils.KafkaChannelSeparator, channel.Namespace, channel.Name)
@@ -460,7 +460,7 @@ func (r *Reconciler) createTopic(ctx context.Context, channel *v1alpha1.KafkaCha
460460
return err
461461
}
462462

463-
func (r *Reconciler) deleteTopic(ctx context.Context, channel *v1alpha1.KafkaChannel, kafkaClusterAdmin sarama.ClusterAdmin) error {
463+
func (r *Reconciler) deleteTopic(ctx context.Context, channel *v1beta1.KafkaChannel, kafkaClusterAdmin sarama.ClusterAdmin) error {
464464
logger := logging.FromContext(ctx)
465465

466466
topicName := utils.TopicName(utils.KafkaChannelSeparator, channel.Namespace, channel.Name)
@@ -488,7 +488,7 @@ func (r *Reconciler) updateKafkaConfig(ctx context.Context, configMap *corev1.Co
488488
r.kafkaConfigError = err
489489
}
490490

491-
func (r *Reconciler) FinalizeKind(ctx context.Context, kc *v1alpha1.KafkaChannel) pkgreconciler.Event {
491+
func (r *Reconciler) FinalizeKind(ctx context.Context, kc *v1beta1.KafkaChannel) pkgreconciler.Event {
492492
// Do not attempt retrying creating the client because it might be a permanent error
493493
// in which case the finalizer will never get removed.
494494
if kafkaClusterAdmin, err := r.createClient(ctx, kc); err == nil && r.kafkaConfig != nil {

kafka/channel/pkg/reconciler/controller/kafkachannel_test.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import (
3535
eventingClient "knative.dev/eventing/pkg/client/injection/client"
3636
"knative.dev/eventing/pkg/utils"
3737

38-
duckv1alpha1 "knative.dev/pkg/apis/duck/v1alpha1"
38+
duckv1 "knative.dev/pkg/apis/duck/v1"
3939
kubeclient "knative.dev/pkg/client/injection/kube/client"
4040
"knative.dev/pkg/configmap"
4141
"knative.dev/pkg/controller"
@@ -44,9 +44,9 @@ import (
4444
logtesting "knative.dev/pkg/logging/testing"
4545
. "knative.dev/pkg/reconciler/testing"
4646

47-
"knative.dev/eventing-contrib/kafka/channel/pkg/apis/messaging/v1alpha1"
47+
"knative.dev/eventing-contrib/kafka/channel/pkg/apis/messaging/v1beta1"
4848
fakekafkaclient "knative.dev/eventing-contrib/kafka/channel/pkg/client/injection/client/fake"
49-
"knative.dev/eventing-contrib/kafka/channel/pkg/client/injection/reconciler/messaging/v1alpha1/kafkachannel"
49+
"knative.dev/eventing-contrib/kafka/channel/pkg/client/injection/reconciler/messaging/v1beta1/kafkachannel"
5050
"knative.dev/eventing-contrib/kafka/channel/pkg/reconciler/controller/resources"
5151
reconcilekafkatesting "knative.dev/eventing-contrib/kafka/channel/pkg/reconciler/testing"
5252
reconcilertesting "knative.dev/eventing-contrib/kafka/channel/pkg/reconciler/testing"
@@ -68,8 +68,8 @@ var (
6868

6969
func init() {
7070
// Add types to scheme
71-
_ = v1alpha1.AddToScheme(scheme.Scheme)
72-
_ = duckv1alpha1.AddToScheme(scheme.Scheme)
71+
_ = v1beta1.AddToScheme(scheme.Scheme)
72+
_ = duckv1.AddToScheme(scheme.Scheme)
7373
}
7474

7575
func TestAllCases(t *testing.T) {
@@ -595,7 +595,7 @@ func makeService() *corev1.Service {
595595
return resources.MakeDispatcherService(testNS)
596596
}
597597

598-
func makeChannelService(nc *v1alpha1.KafkaChannel) *corev1.Service {
598+
func makeChannelService(nc *v1beta1.KafkaChannel) *corev1.Service {
599599
return &corev1.Service{
600600
TypeMeta: metav1.TypeMeta{
601601
APIVersion: "v1",

kafka/channel/pkg/reconciler/controller/resources/service.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121

2222
corev1 "k8s.io/api/core/v1"
2323
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
24-
"knative.dev/eventing-contrib/kafka/channel/pkg/apis/messaging/v1alpha1"
24+
"knative.dev/eventing-contrib/kafka/channel/pkg/apis/messaging/v1beta1"
2525
"knative.dev/eventing/pkg/utils"
2626
"knative.dev/pkg/kmeta"
2727
)
@@ -60,7 +60,7 @@ func ExternalService(namespace, service string) ServiceOption {
6060
// MakeK8sService creates a new K8s Service for a Channel resource. It also sets the appropriate
6161
// OwnerReferences on the resource so handleObject can discover the Channel resource that 'owns' it.
6262
// As well as being garbage collected when the Channel is deleted.
63-
func MakeK8sService(kc *v1alpha1.KafkaChannel, opts ...ServiceOption) (*corev1.Service, error) {
63+
func MakeK8sService(kc *v1beta1.KafkaChannel, opts ...ServiceOption) (*corev1.Service, error) {
6464
// Add annotations
6565
svc := &corev1.Service{
6666
TypeMeta: metav1.TypeMeta{

kafka/channel/pkg/reconciler/controller/resources/service_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
"github.com/google/go-cmp/cmp"
2525
corev1 "k8s.io/api/core/v1"
2626
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
27-
"knative.dev/eventing-contrib/kafka/channel/pkg/apis/messaging/v1alpha1"
27+
"knative.dev/eventing-contrib/kafka/channel/pkg/apis/messaging/v1beta1"
2828
"knative.dev/pkg/kmeta"
2929
)
3030

@@ -49,7 +49,7 @@ func TestMakeChannelServiceAddress(t *testing.T) {
4949
}
5050

5151
func TestMakeService(t *testing.T) {
52-
imc := &v1alpha1.KafkaChannel{
52+
imc := &v1beta1.KafkaChannel{
5353
ObjectMeta: metav1.ObjectMeta{
5454
Name: kcName,
5555
Namespace: testNS,
@@ -92,7 +92,7 @@ func TestMakeService(t *testing.T) {
9292
}
9393

9494
func TestMakeServiceWithExternal(t *testing.T) {
95-
imc := &v1alpha1.KafkaChannel{
95+
imc := &v1beta1.KafkaChannel{
9696
ObjectMeta: metav1.ObjectMeta{
9797
Name: kcName,
9898
Namespace: testNS,
@@ -130,7 +130,7 @@ func TestMakeServiceWithExternal(t *testing.T) {
130130
}
131131

132132
func TestMakeServiceWithFailingOption(t *testing.T) {
133-
imc := &v1alpha1.KafkaChannel{
133+
imc := &v1beta1.KafkaChannel{
134134
ObjectMeta: metav1.ObjectMeta{
135135
Name: kcName,
136136
Namespace: testNS,

0 commit comments

Comments
 (0)