brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From henev...@apache.org
Subject [1/4] brooklyn-server git commit: add out of box support for `$brooklyn:external("brooklyn-demo-sample", "hidden-brooklyn-password")`
Date Wed, 13 Sep 2017 17:06:54 GMT
Repository: brooklyn-server
Updated Branches:
  refs/heads/master fe84df9db -> 16c788edc


add out of box support for `$brooklyn:external("brooklyn-demo-sample", "hidden-brooklyn-password")`

so we can use this in examples rather than a plain-text password


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/5a505e13
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/5a505e13
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/5a505e13

Branch: refs/heads/master
Commit: 5a505e13807f03d71f33f22ba07d3ac55f652a3d
Parents: 36de666
Author: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Authored: Fri Sep 8 13:01:55 2017 +0100
Committer: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Committed: Fri Sep 8 13:06:37 2017 +0100

----------------------------------------------------------------------
 .../internal/BasicExternalConfigSupplierRegistry.java   | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/5a505e13/core/src/main/java/org/apache/brooklyn/core/mgmt/internal/BasicExternalConfigSupplierRegistry.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/mgmt/internal/BasicExternalConfigSupplierRegistry.java
b/core/src/main/java/org/apache/brooklyn/core/mgmt/internal/BasicExternalConfigSupplierRegistry.java
index 7d303a3..3e7fa43 100644
--- a/core/src/main/java/org/apache/brooklyn/core/mgmt/internal/BasicExternalConfigSupplierRegistry.java
+++ b/core/src/main/java/org/apache/brooklyn/core/mgmt/internal/BasicExternalConfigSupplierRegistry.java
@@ -26,7 +26,9 @@ import org.apache.brooklyn.api.mgmt.ManagementContext;
 import org.apache.brooklyn.core.config.ConfigPredicates;
 import org.apache.brooklyn.core.config.ConfigUtils;
 import org.apache.brooklyn.core.config.external.ExternalConfigSupplier;
+import org.apache.brooklyn.core.config.external.InPlaceExternalConfigSupplier;
 import org.apache.brooklyn.core.internal.BrooklynProperties;
+import org.apache.brooklyn.util.collections.MutableMap;
 import org.apache.brooklyn.util.core.ClassLoaderUtils;
 import org.apache.brooklyn.util.exceptions.Exceptions;
 import org.apache.brooklyn.util.guava.Maybe;
@@ -46,18 +48,26 @@ public class BasicExternalConfigSupplierRegistry implements ExternalConfigSuppli
 
     private static final Logger LOG = LoggerFactory.getLogger(BasicExternalConfigSupplierRegistry.class);
 
+    public static final String DEMO_SAMPLE_PROVIDER = "brooklyn-demo-sample";
+    public static final String DEMO_SAMPLE_PROVIDER_PASSWORD_KEY = "hidden-brooklyn-password";
+    public static final String DEMO_SAMPLE_PROVIDER_PASSWORD_VALUE = "br00k11n";
+    
     private final Map<String, ExternalConfigSupplier> providersByName = Maps.newLinkedHashMap();
     private final Object providersMapMutex = new Object();
 
     public BasicExternalConfigSupplierRegistry(ManagementContext mgmt) {
+        addProvider(DEMO_SAMPLE_PROVIDER, new InPlaceExternalConfigSupplier(mgmt, DEMO_SAMPLE_PROVIDER,
+            MutableMap.of(DEMO_SAMPLE_PROVIDER_PASSWORD_KEY, DEMO_SAMPLE_PROVIDER_PASSWORD_VALUE)));
         updateFromBrooklynProperties(mgmt);
     }
 
     @Override
     public void addProvider(String name, ExternalConfigSupplier supplier) {
         synchronized (providersMapMutex) {
-            if (providersByName.containsKey(name))
+            if (providersByName.containsKey(name) && !DEMO_SAMPLE_PROVIDER.equals(name))
{
+                // allow demo to be overridden
                 throw new IllegalArgumentException("Provider already registered with name
'" + name + "'");
+            }
             providersByName.put(name, supplier);
         }
         LOG.info("Added external config supplier named '" + name + "': " + supplier);


Mime
View raw message