Skip to content

Commit

Permalink
Remove redundant helper functions for Kafka and Update constants (#1074)
Browse files Browse the repository at this point in the history
  • Loading branch information
obaydullahmhs authored Nov 27, 2023
1 parent b28463f commit 449a4e0
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 15 deletions.
8 changes: 3 additions & 5 deletions apis/kubedb/v1alpha2/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -518,15 +518,13 @@ const (
KafkaPortNameCruiseControlREST = "cc-rest"
KafkaBrokerClientPortName = "broker"
KafkaControllerClientPortName = "controller"
KafkaPortNameInternal = "internal"
KafkaPortNameExternal = "external"
KafkaPortNameLocal = "local"
KafkaTopicNameHealth = "kafka-health"
KafkaTopicDeletionThresholdOffset = 1000
KafkaControllerMaxID = 1000
KafkaBrokerMaxID = 1000
KafkaRESTPort = 9092
KafkaControllerRESTPort = 9093
KafkaInternalRESTPort = 29092
KafkaExternalRESTPort = 19092
KafkaLocalRESTPort = 29092
KafkaCruiseControlRESTPort = 9090
KafkaCruiseControlListenerPort = 9094
KafkaCCDefaultInNetwork = 500000
Expand Down
8 changes: 0 additions & 8 deletions apis/kubedb/v1alpha2/kafka_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,6 @@ func (k *Kafka) GoverningServiceName() string {
return meta_util.NameWithSuffix(k.ServiceName(), "pods")
}

func (k *Kafka) GoverningServiceNameController() string {
return meta_util.NameWithSuffix(k.ServiceName(), KafkaNodeRolesController)
}

func (k *Kafka) GoverningServiceNameBroker() string {
return meta_util.NameWithSuffix(k.ServiceName(), KafkaNodeRolesBrokers)
}

func (k *Kafka) GoverningServiceNameCruiseControl() string {
return meta_util.NameWithSuffix(k.ServiceName(), KafkaNodeRolesCruiseControl)
}
Expand Down
3 changes: 1 addition & 2 deletions apis/kubedb/v1alpha2/kafka_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,7 @@ type KafkaListenerType string
const (
KafkaListenerBroker KafkaListenerType = "BROKER"
KafkaListenerController KafkaListenerType = "CONTROLLER"
KafkaListenerInternal KafkaListenerType = "INTERNAL"
KafkaListenerExternal KafkaListenerType = "EXTERNAL"
KafkaListenerLocal KafkaListenerType = "LOCAL"
KafkaListenerCC KafkaListenerType = "CC"
)

Expand Down
14 changes: 14 additions & 0 deletions apis/kubedb/v1alpha2/kafka_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,19 @@ func (k *Kafka) ValidateDelete() error {
func (k *Kafka) ValidateCreateOrUpdate() error {
var allErr field.ErrorList
// TODO(user): fill in your validation logic upon object creation.
if k.Spec.EnableSSL {
if k.Spec.TLS == nil {
allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("enableSSL"),
k.Name,
".spec.tls can't be nil, if .spec.enableSSL is true"))
}
} else {
if k.Spec.TLS != nil {
allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("enableSSL"),
k.Name,
".spec.tls must be nil, if .spec.enableSSL is disabled"))
}
}
if k.Spec.Topology != nil {
if k.Spec.Topology.Controller == nil {
allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("topology").Child("controller"),
Expand Down Expand Up @@ -195,6 +208,7 @@ var availableVersions = []string{
"3.4.0",
"3.4.1",
"3.5.1",
"3.6.0",
}

func validateVersion(db *Kafka) error {
Expand Down

0 comments on commit 449a4e0

Please sign in to comment.