GitHub user neykov opened a pull request:
https://github.com/apache/incubator-brooklyn/pull/1001
YAML config keys (parameters)
Adds parameters to specs and catalog items, which are then added as config
keys to the entity's dynamic type.
What this allows is:
* document the possible inputs for a catalog item
* the UI can now ask the user for input when selecting a catalog item
* setting the correct type for inputs (coercing), validating
* add config keys to an entity by setting them in the spec
Parameters can be set at any level in the CAMP plan, including in the
catalog item meta info. If not set the underlying type parameters are used (if
a java class, then its config keys are used, if a catalog item, then the item's
parameters). The top level service parameters become the catalog item's
parameters.
For referencing any passed parameters new scopes are introduced:
* `$brooklyn:root()` returns the application entity (top-level one)
* `$brooklyn:scopeRoot()` returns the top level entity of the current
catalog item
Example:
```
brooklyn.catalog:
id: parameterExample
version: 0.0.1
brooklyn.parameters:
- name: maxHits
type: integer
constraints:
- required
- config2
- config3
item:
type: BasicApplication
brooklyn.children:
- type: entity1
# can be set at deeper levels when typing is needed
brooklyn.parameters:
- name: entity1Config
type: integer
brooklyn.config:
entity1Config: $brooklyn:scopeRoot().config("maxHits")
- type: entity2
brooklyn.config:
entity2Config: $brooklyn:config("maxHits") # using the inherited
config
```
Which results in the following catalog item:
<img width="598" alt="catalog item view"
src="https://cloud.githubusercontent.com/assets/3612111/10966226/c7d7bfe4-83ba-11e5-8303-c705ce68e06c.png">
When using
the Application Wizard to create an application from the above catalog
item the UI asks you to fill in the parameters:
<img width="616" alt="screen shot 2015-11-05 at 12 51 35"
src="https://cloud.githubusercontent.com/assets/3612111/10966396/fa52dd0e-83bb-11e5-94b2-fbe5d049541d.png">
creating the following app plan:
```
location: uLXQ8KFk
services:
- type: "parameterExample:0.0.1"
brooklyn.config:
maxHits: 55
```
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/neykov/incubator-brooklyn catalog-item-config
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/incubator-brooklyn/pull/1001.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #1001
----
commit 181c5a0c5762ecc3a6eab1fec8cfb8f342f8afa3
Author: Svetoslav Neykov <[email protected]>
Date: 2015-10-26T15:56:47Z
Deprecate java type based items in favor of parser dependent plans
commit 75f4ba01a0ed11c416fc783375f1c71b9ff9c6da
Author: Svetoslav Neykov <[email protected]>
Date: 2015-10-28T17:00:33Z
Fix installed test osgi jar name
Previously changed due to a copy&paste error
commit 35e1b43d6d653d78c0d8f23987979b753b73ce97
Author: Svetoslav Neykov <[email protected]>
Date: 2015-10-28T17:13:17Z
Catalog items configuration support
Functionality to let catalog items document what configuration they accept
as input. Useful for YAML plans to let users know what configuration they
support and for UIs to list available inputs and validate them.
commit 171a66f635650040e0308f3a60ae17f55650aa8a
Author: Svetoslav Neykov <[email protected]>
Date: 2015-10-29T16:44:24Z
Parameter aware specs
Let specs be aware of the parameters the underlying brooklyn object is
accepting. Catalog items return the same spec parameters derived at addition
time. The catalog item can override the underlying entity parameters by
including the list in its meta.
commit a09c399d5505cdddf52585d435990289dac41dca
Author: Svetoslav Neykov <[email protected]>
Date: 2015-10-30T16:24:46Z
Add PortRange support for the parameter types
Won't be set as an attribute though.
commit 6c84eb32ff51c1a30883986aba1ea0c5dc4330a2
Author: Svetoslav Neykov <[email protected]>
Date: 2015-11-03T15:30:13Z
Parameters rebind support
commit db8a815859136df92f2e9cd1da54321d7f1bd40d
Author: Svetoslav Neykov <[email protected]>
Date: 2015-11-03T15:31:49Z
Parameters test coverage
commit d323cfaf6e048609716f0c22d9f188e71d552c4a
Author: Svetoslav Neykov <[email protected]>
Date: 2015-11-03T15:58:23Z
Parameters docs
commit 602055531e8484d056db580781bb1f5797036c71
Author: Svetoslav Neykov <[email protected]>
Date: 2015-11-04T11:48:47Z
Improve UI handling of catalog item parameters.
commit 2a1993226fbf8cd0c52981d61693de3b9903ca60
Author: Svetoslav Neykov <[email protected]>
Date: 2015-11-04T12:57:58Z
Add root scope in CAMP DSL - the application
commit a525cdbe1b76ccf0addd9354cec72b7de3c72d60
Author: Svetoslav Neykov <[email protected]>
Date: 2015-11-04T13:59:24Z
Add scopeRoot scope in CAMP DSL
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---