@SafeVarargs
    public static Map<String, String> mergeLabelsOrAnnotations(Map<String, String> base, Map<String, String>... overrides) {
        Map<String, String> merged = new HashMap<>();

        if (base != null) {
            merged.putAll(base);
        }

        if (overrides != null) {
            for (Map<String, String> toMerge : overrides) {

                if (toMerge == null) {
                    continue;
                }
                List<String> bannedLabelsOrAnnotations = toMerge
                    .keySet()
                    .stream()
                    .filter(key -> key.startsWith(Labels.STRIMZI_DOMAIN))
                    .toList();
                if (bannedLabelsOrAnnotations.size() > 0) {
                    throw new InvalidResourceException("User provided labels or annotations includes a Strimzi annotation: " + bannedLabelsOrAnnotations);
                }

                Map<String, String> filteredToMerge = toMerge
                    .entrySet()
                    .stream()
                    // Remove Kubernetes Domain specific labels
                    .filter(entryset -> !entryset.getKey().startsWith(Labels.KUBERNETES_DOMAIN))
                    .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));

                merged.putAll(filteredToMerge);
            }
        }

        return merged;
    }
@Test
    public void testMergeLabelsOrAnnotations()  {
        Map<String, String> base = new HashMap<>();
        base.put("label1", "value1");
        base.put(Labels.STRIMZI_DOMAIN + "label2", "value2");

        Map<String, String> overrides1 = new HashMap<>();
        overrides1.put("override1", "value1");
        overrides1.put(Labels.KUBERNETES_DOMAIN + "override2", "value2");

        Map<String, String> overrides2 = new HashMap<>();
        overrides2.put("override3", "value3");

        Map<String, String> forbiddenOverrides = new HashMap<>();
        forbiddenOverrides.put(Labels.STRIMZI_DOMAIN + "override4", "value4");

        Map<String, String> expected = new HashMap<>();
        expected.put("label1", "value1");
        expected.put(Labels.STRIMZI_DOMAIN + "label2", "value2");
        expected.put("override1", "value1");
        expected.put("override3", "value3");

        assertThat(Util.mergeLabelsOrAnnotations(base, overrides1, overrides2), is(expected));
        assertThat(Util.mergeLabelsOrAnnotations(base, overrides1, null, overrides2), is(expected));
        assertThat(Util.mergeLabelsOrAnnotations(base, (Map<String, String>) null), is(base));
        assertThat(Util.mergeLabelsOrAnnotations(base, (Map<String, String>[]) null), is(base));
        assertThat(Util.mergeLabelsOrAnnotations(base), is(base));
        assertThat(Util.mergeLabelsOrAnnotations(null, overrides2), is(overrides2));
        assertThrows(InvalidResourceException.class, () -> Util.mergeLabelsOrAnnotations(base, forbiddenOverrides));
    }