Skip to content

Commit

Permalink
Add security related webhook validator for kafka
Browse files Browse the repository at this point in the history
Signed-off-by: obaydullahmhs <obaydullah@appscode.com>
  • Loading branch information
obaydullahmhs committed Nov 23, 2023
1 parent 15523cf commit 42f5eb5
Showing 1 changed file with 14 additions and 0 deletions.
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,20 @@ 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.DisableSecurity {
if k.Spec.EnableSSL {
allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("enableSSL"),
k.Name,
".spec.enableSSL can't be true, if .spec.disableSecurity is enabled"))
}
}
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"))
}
}
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

0 comments on commit 42f5eb5

Please sign in to comment.