Skip to content

Commit

Permalink
Update apis
Browse files Browse the repository at this point in the history
Signed-off-by: obaydullahmhs <[email protected]>
  • Loading branch information
obaydullahmhs committed Jan 15, 2025
1 parent 6db591e commit f6ade11
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 27 deletions.
34 changes: 24 additions & 10 deletions apis/kafka/v1alpha1/openapi_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 15 additions & 9 deletions apis/kafka/v1alpha1/restproxy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,10 @@ type RestProxySpec struct {
// +optional
PodTemplate ofst.PodTemplateSpec `json:"podTemplate,omitempty"`

// EnableSchemaRegistry indicates whether the REST Proxy should connect to a Schema Registry.
// If set to true, the REST Proxy will establish a connection to the Schema Registry before communicating with Kafka.
// This is necessary when producing or consuming messages that use Avro or other schema-based formats.
// +optional
EnableSchemaRegistry bool `json:"enableSchemaRegistry,omitempty"`

// SchemaRegistryRef provides a reference to the Schema Registry configuration.
// If EnableSchemaRegistry and SchemaRegistryRef are both set, the REST Proxy will connect to the external Schema Registry.
// Otherwise, the REST Proxy will use the internal Schema Registry.
// the REST Proxy will connect to the Schema Registry if SchemaRegistryRef is provided.
// +optional
SchemaRegistryRef *kmapi.ObjectReference `json:"schemaRegistryRef,omitempty"`
SchemaRegistryRef *SchemaRegistryRef `json:"schemaRegistryRef,omitempty"`

// ServiceTemplates is an optional configuration for services used to expose database
// +optional
Expand All @@ -96,6 +89,19 @@ type RestProxySpec struct {
HealthChecker kmapi.HealthCheckSpec `json:"healthChecker"`
}

// SchemaRegistryRef provides a reference to the Schema Registry configuration.
type SchemaRegistryRef struct {
// Name and namespace of appbinding of schema registry
// If this is provided, the REST Proxy will connect to the Schema Registry
// InternallyManaged must be set to false in this case
// +optional
*kmapi.ObjectReference `json:",omitempty"`

// InternallyManaged true specifies if the schema registry runs internally along with the rest proxy
// +optional
InternallyManaged bool `json:"internallyManaged,omitempty"`
}

// RestProxyStatus defines the observed state of RestProxy
type RestProxyStatus struct {
// Specifies the current phase of the database
Expand Down
13 changes: 9 additions & 4 deletions apis/kafka/v1alpha1/restproxy_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,16 @@ func (k *RestProxy) ValidateCreateOrUpdate() field.ErrorList {
return allErr
}

if !k.Spec.EnableSchemaRegistry {
if k.Spec.SchemaRegistryRef != nil {
allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("enableSchemaRegistry"),
if k.Spec.SchemaRegistryRef != nil {
if k.Spec.SchemaRegistryRef.InternallyManaged && k.Spec.SchemaRegistryRef.ObjectReference != nil {
allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("schemaRegistryRef").Child("objectReference"),
k.Name,
"SchemaRegistryRef can only be set when EnableSchemaRegistry is true"))
"ObjectReference should be nil when InternallyManaged is true"))
}
if !k.Spec.SchemaRegistryRef.InternallyManaged && k.Spec.SchemaRegistryRef.ObjectReference == nil {
allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("schemaRegistryRef").Child("objectReference"),
k.Name,
"ObjectReference should not be nil when InternallyManaged is false"))
}
}

Expand Down
25 changes: 23 additions & 2 deletions apis/kafka/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions crds/kafka.kubedb.com_restproxies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ spec:
- WipeOut
- DoNotTerminate
type: string
enableSchemaRegistry:
type: boolean
healthChecker:
default:
failureThreshold: 3
Expand Down Expand Up @@ -3156,6 +3154,8 @@ spec:
type: integer
schemaRegistryRef:
properties:
internallyManaged:
type: boolean
name:
type: string
namespace:
Expand Down

0 comments on commit f6ade11

Please sign in to comment.