This is an automated email from the ASF dual-hosted git repository.
heneveld pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/brooklyn-server.git
The following commit(s) were added to refs/heads/master by this push:
new 2d00588536 prevent legacy mode from allowing blueprints that it
shouldn't
2d00588536 is described below
commit 2d005885363ba825922d410d23ef5ec42d87cc17
Author: Alex Heneveld <[email protected]>
AuthorDate: Fri Nov 4 20:28:02 2022 +0000
prevent legacy mode from allowing blueprints that it shouldn't
if there is a services block, don't take enricher or other thing from that
block.
would only apply if services block didn't resolve first time, but where
there were
references to yet-unresolved items, it could trigger the wrong type being
resolved.
---
.../brooklyn/camp/brooklyn/ApplicationsYamlTest.java | 18 ++++++++++++++++++
.../core/catalog/internal/BasicBrooklynCatalog.java | 10 +++++++---
2 files changed, 25 insertions(+), 3 deletions(-)
diff --git
a/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/ApplicationsYamlTest.java
b/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/ApplicationsYamlTest.java
index 6bd8a2ed2d..656a478962 100644
---
a/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/ApplicationsYamlTest.java
+++
b/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/ApplicationsYamlTest.java
@@ -429,6 +429,24 @@ public class ApplicationsYamlTest extends AbstractYamlTest
{
Assert.assertEquals(Iterables.getOnlyElement(retrievedItems).getVersion(),
TEST_VERSION);
}
+ @Test
+ public void testGoodErrorFromServicesEvenWhenEnricherBlockOkay() throws
Exception {
+ Asserts.assertFailsWith(() -> {
+ addCatalogItems(
+ "brooklyn.catalog:",
+ " id: simple-test",
+ " version: " + TEST_VERSION,
+ "brooklyn.enrichers:",
+ "- type: " + TestEnricher.class.getName(),
+ "services:",
+ "- type: not_a_real_service");
+ RegisteredType t =
mgmt().getTypeRegistry().get("simple-test", TEST_VERSION);
+ return t+" - "+t.getSuperTypes();
+ },
+ e -> Asserts.expectedFailureContains(e, "not_a_real_service"));
+ }
+
+
@Override
protected Logger getLogger() {
return log;
diff --git
a/core/src/main/java/org/apache/brooklyn/core/catalog/internal/BasicBrooklynCatalog.java
b/core/src/main/java/org/apache/brooklyn/core/catalog/internal/BasicBrooklynCatalog.java
index 7a6f3d28b3..2956e24861 100644
---
a/core/src/main/java/org/apache/brooklyn/core/catalog/internal/BasicBrooklynCatalog.java
+++
b/core/src/main/java/org/apache/brooklyn/core/catalog/internal/BasicBrooklynCatalog.java
@@ -1410,9 +1410,13 @@ public class BasicBrooklynCatalog implements
BrooklynCatalog {
// as we parse using CAMP and need that
// so prefer those for now (may change with YOML)
- attemptLegacySpecTransformersForType(CatalogItemType.POLICY,
POLICIES_KEY);
- attemptLegacySpecTransformersForType(CatalogItemType.ENRICHER,
ENRICHERS_KEY);
- attemptLegacySpecTransformersForType(CatalogItemType.LOCATION,
LOCATIONS_KEY);
+ if (item.containsKey("services")) {
+ // other legacy types not permitted if there is a services
block
+ } else {
+ attemptLegacySpecTransformersForType(CatalogItemType.POLICY,
POLICIES_KEY);
+ attemptLegacySpecTransformersForType(CatalogItemType.ENRICHER,
ENRICHERS_KEY);
+ attemptLegacySpecTransformersForType(CatalogItemType.LOCATION,
LOCATIONS_KEY);
+ }
}
boolean suspicionOfABean = false;