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

Commit

Permalink
Fix KafkaBinding conversion (#1651)
Browse files Browse the repository at this point in the history
  • Loading branch information
aliok authored Oct 27, 2020
1 parent 10d7a7f commit 090e2b3
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
15 changes: 15 additions & 0 deletions kafka/source/config/300-kafkabinding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ metadata:
name: kafkabindings.bindings.knative.dev
spec:
group: bindings.knative.dev
preserveUnknownFields: false
validation:
openAPIV3Schema:
type: object
# this is a work around so we don't need to flush out the
# schema for each version at this time
#
# see issue: https://github.com/knative/serving/issues/912
x-kubernetes-preserve-unknown-fields: true
names:
categories:
- all
Expand All @@ -33,6 +42,12 @@ spec:
scope: Namespaced
subresources:
status: {}
conversion:
strategy: Webhook
webhookClientConfig:
service:
name: kafka-source-webhook
namespace: knative-sources
additionalPrinterColumns:
- name: BootstrapServers
type: string
Expand Down
6 changes: 2 additions & 4 deletions kafka/source/pkg/apis/bindings/v1alpha1/kafka_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ func (source *KafkaBinding) ConvertTo(ctx context.Context, obj apis.Convertible)
BindingSpec: source.Spec.BindingSpec,
KafkaAuthSpec: kafkaAuthSpec,
}
sink.Status.Status = source.Status.Status
source.Status.Status.ConvertTo(ctx, &sink.Status.Status)
source.Status.Status.DeepCopyInto(&sink.Status.Status)
return nil
default:
return fmt.Errorf("Unknown conversion, got: %T", sink)
Expand All @@ -63,8 +62,7 @@ func (sink *KafkaBinding) ConvertFrom(ctx context.Context, obj apis.Convertible)
BindingSpec: source.Spec.BindingSpec,
KafkaAuthSpec: kafkaAuthSpec,
}
sink.Status.Status = source.Status.Status
source.Status.Status.ConvertTo(ctx, &source.Status.Status)
source.Status.Status.DeepCopyInto(&sink.Status.Status)
return nil
default:
return fmt.Errorf("Unknown conversion, got: %T", source)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ func TestKafkaBindingConversionRoundTripV1alpha1(t *testing.T) {
Conditions: duckv1.Conditions{{
Type: "Ready",
Status: "True",
}, {
Type: "DoesNotReallyExistButHereItIsForTestingStatusCopy",
Status: "False",
}},
Annotations: map[string]string{
"foo": "bar",
Expand Down Expand Up @@ -285,6 +288,9 @@ func TestKafkaBindingConversionRoundTripV1beta1(t *testing.T) {
Conditions: duckv1.Conditions{{
Type: "Ready",
Status: "True",
}, {
Type: "DoesNotReallyExistButHereItIsForTestingStatusCopy",
Status: "False",
}},
Annotations: map[string]string{
"foo": "bar",
Expand Down

0 comments on commit 090e2b3

Please sign in to comment.