brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From drigod...@apache.org
Subject [1/2] brooklyn-docs git commit: BROOKLYN-433: docs for yaml config key constraints
Date Tue, 28 Feb 2017 17:00:34 GMT
Repository: brooklyn-docs
Updated Branches:
  refs/heads/master 9ffd04919 -> 5366a125f


BROOKLYN-433: docs for yaml config key constraints


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

Branch: refs/heads/master
Commit: d4650670dee257e33ca0cf595718ef7a796cde79
Parents: 9ffd049
Author: Aled Sage <aled.sage@gmail.com>
Authored: Tue Feb 28 16:01:36 2017 +0000
Committer: Aled Sage <aled.sage@gmail.com>
Committed: Tue Feb 28 16:06:30 2017 +0000

----------------------------------------------------------------------
 guide/yaml/entity-configuration.md | 66 +++++++++++++++++++++++++++++++--
 guide/yaml/yaml-reference.md       |  2 +-
 2 files changed, 63 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-docs/blob/d4650670/guide/yaml/entity-configuration.md
----------------------------------------------------------------------
diff --git a/guide/yaml/entity-configuration.md b/guide/yaml/entity-configuration.md
index b8e4625..ae07699 100644
--- a/guide/yaml/entity-configuration.md
+++ b/guide/yaml/entity-configuration.md
@@ -39,11 +39,10 @@ such as for inheriting configuration from a parent entity.
 ### Configuration in a Catalog Item
 
 When defining an entity in the catalog, it can include configuration values like any other

-blueprint. It can also explicitly declare config keys. For details of how to write and add
-catalog items, see [Catalog]({{ site.path.guide }}/ops/catalog/). For more details of 
-declaring config keys, see the [Custom Entities]({{ site.path.guide }}/yaml/custom-entities.html#declaring-new-config-keys)
page.
+blueprint (i.e. inside the `brooklyn.config` block).
 
-The example below illustrates the principles:
+It can also explicitly declare config keys, using the `brooklyn.parameters` block. The example

+below illustrates the principle:
 
 {% highlight yaml %}
 brooklyn.catalog:
@@ -56,6 +55,7 @@ brooklyn.catalog:
       brooklyn.parameters:
       - name: custom.message
         type: string
+        description: Message to be displayed
         default: Hello
       brooklyn.config:
         shell.env:
@@ -76,6 +76,64 @@ services:
 - type: entity-config-example
 {% endhighlight %}
 
+For details of how to write and add catalog items, see [Catalog]({{ site.path.guide }}/ops/catalog/).

+
+
+#### Config Key Constraints
+
+The config keys in the `brooklyn.parameters` can also have constraints defined, for what
values
+are valid. If more than one constraint is defined, then they must all be satisfied. The constraints

+can be any of:
+
+* `required`: deployment will fail if no value is supplied for this config key.
+* `regex: ...`: the value will be compared against the given regular expression.
+* A predicate, declared using the DSL `$brooklyn:object`.  
+
+This is illustrated in the example below:
+
+{% highlight yaml %}
+brooklyn.catalog:
+  items:
+  - id: entity-constraint-example
+    itemType: entity
+    name: Entity Config Example
+    item:
+      type: org.apache.brooklyn.entity.stock.BasicEntity
+      brooklyn.parameters:
+      - name: compulsoryExample
+        type: string
+        constraints:
+        - required
+      - name: addressExample
+        type: string
+        constraints:
+        - regex: ^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$
+      - name: numberExample
+        type: double
+        constraints:
+        - $brooklyn:object:
+            type: org.apache.brooklyn.util.math.MathPredicates
+            factoryMethod.name: greaterThan
+            factoryMethod.args:
+            - 0.0
+        - $brooklyn:object:
+            type: org.apache.brooklyn.util.math.MathPredicates
+            factoryMethod.name: lessThan
+            factoryMethod.args:
+            - 256.0
+{% endhighlight %}
+
+An example usage of this toy example, once added to the catalog, is shown below:
+
+{% highlight yaml %}
+services:
+- type: entity-constraint-example
+  brooklyn.config:
+    compulsoryExample: foo
+    addressExample: 1.1.1.1
+    numberExample: 2.0
+{% endhighlight %}
+
 
 ### Inheriting Configuration
 

http://git-wip-us.apache.org/repos/asf/brooklyn-docs/blob/d4650670/guide/yaml/yaml-reference.md
----------------------------------------------------------------------
diff --git a/guide/yaml/yaml-reference.md b/guide/yaml/yaml-reference.md
index 6e7df7a..3ac975e 100644
--- a/guide/yaml/yaml-reference.md
+++ b/guide/yaml/yaml-reference.md
@@ -74,7 +74,7 @@ the entity being defined, with these being the most common:
   * `default`: a default value; this will be coerced to the declared `type`
   * `pinned`: mark the parameter as pinned (always displayed) for the UI. The default is
`true`
   * `constraints`: a list of constraints the parameter should meet;
-    currently `required` is supported, with the default being not required
+    for details, see [Entity Configuration]({{ site.path.guide }}/yaml/entity-configuration.html#config-key-constraints).

 
   A shorthand notation is also supported where just the name of the parameter is supplied
   as an item in the list, with the other values being unset or the default.


Mime
View raw message