From edc5274cc8e9a72c528ed9ea10245c6705b927c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wilson=20J=C3=BAnior?= Date: Thu, 13 Feb 2025 15:37:10 -0300 Subject: [PATCH] fix: ensure block existence check is performed for empty server names --- internal/pkg/rpaas/mutation.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/pkg/rpaas/mutation.go b/internal/pkg/rpaas/mutation.go index cdb0b453..3d7b5783 100644 --- a/internal/pkg/rpaas/mutation.go +++ b/internal/pkg/rpaas/mutation.go @@ -62,13 +62,13 @@ func (m *mutation) UpdateBlock(block ConfigurationBlock) error { } func (m *mutation) DeleteBlock(serverName, blockName string) error { - if m.spec.Blocks == nil { - return NotFoundError{Msg: fmt.Sprintf("block %q not found", blockName)} - } - blockType := v1alpha1.BlockType(blockName) if serverName == "" { + if m.spec.Blocks == nil { + return NotFoundError{Msg: fmt.Sprintf("block %q not found", blockName)} + } + if _, ok := m.spec.Blocks[blockType]; !ok { return NotFoundError{Msg: fmt.Sprintf("block %q not found", blockName)} }