I'm of the opinion that templates *shouldn't* access externals directly. Templates should be tied to an entity and so only rely on the config of that entity. You can then set a config key in YAML to have the external value and use that from the templates.

In theory, this makes the blueprints reusable, and not dependent on externals that you might have set up but others might not. But in practise -- wil that work for your case? e.g.

brooklyn.config:
  download_pass: $brooklyn:external("credentials", "download_pass")

and then ${download_pass} in freemarker


Valentin- Your hacky solution is cool but horrible. Tighter security models will disallow invoking java from templates as you've done -- and unless there is a good reason otherwise I'd be happy to see it deprecated in Brooklyn.

Best
Alex


On 28/03/2017 22:50, Valentin Aitken wrote:
Hi Graham,

External config supplier is not supported out of the box for templates.install config.

However I think I figured out a hacky solution similar to '$brooklyn:external' implementation which is in BrooklynDslCommon. DslExternal. ${entity.getManagementContext().getExternalConfigProviderRegistry().getConfig("credentials","download_pass")}


Other Brooklyners, what do you think about adding a TemplateHashModel for external properties so we support in freemarker things like ${external("credentials","download_pass")}?

On 28/03/17 20:42, Graham Ashby wrote:
So, I have a couple of external properties specified in
brooklyn.properties in place:

brooklyn.external.credentials=org.apache.brooklyn.core.config.external.InPlaceExternalConfigSupplier
brooklyn.external.credentials.download_user=userID
brooklyn.external.credentials.download_pass=BigSecret!

I know how I can access these in YAML, but how do I access them in a
freemarker template?
How about if I want access in Java?

Thanks
Graham




Reply via email to